Skip to content

Commit 1a93373

Browse files
committed
migrated new tasks
1 parent c4dfa71 commit 1a93373

File tree

2 files changed

+10
-44
lines changed

2 files changed

+10
-44
lines changed

src/sasctl/pzmm/writeScoreCode.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
import numpy as np
66
import re
7-
from ..tasks import get_software_version, upload_and_copy_score_resources
7+
from ..core import platform_version
88
from .._services.model_repository import ModelRepository as modelRepo
99

1010
# %%
@@ -94,11 +94,18 @@ def writeScoreCode(cls, inputDF, targetDF, modelPrefix,
9494
Python score code wrapped in DS2 and prepared for SAS Microanalyic Service scoring or publishing.
9595
'''
9696
# Call REST API to check SAS Viya version
97-
isViya35 = (get_software_version() == '3.5')
97+
isViya35 = (platform_version() == '3.5')
9898

9999
# Initialize modelID to remove unbound variable warnings
100100
modelID = None
101-
101+
102+
# Helper method for uploading & migrating files
103+
# TODO: Integrate with register_model() or publish_model() task.
104+
def upload_and_copy_score_resources(model, files):
105+
for file in files:
106+
modelRepo.add_model_content(model, **file)
107+
return modelRepo.copy_python_resources(model)
108+
102109
# For SAS Viya 3.5, either return an error or return the model UUID as a string
103110
if isViya35:
104111
if model == None:

src/sasctl/tasks.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -708,44 +708,3 @@ def _parse_module_url(msg):
708708
module_url = match.group(1) if match else None
709709

710710
return module_url
711-
712-
713-
714-
def upload_and_copy_score_resources(model, files, name=None):
715-
'''Upload Python score resources to a model and copy the score resources
716-
to the Compute Server.
717-
718-
For SAS Model Manager installations on SAS Viya 3.5, Python score resources
719-
are not automatically copied to the Compute server and a valid DS2 wrapper is not
720-
automatically generated for Python score code. After registering a new
721-
model or attempting to update an old model, pzmm.writeScoreCode.py creates
722-
Python score code and the DS2 wrapper, which can then be uploaded to the model and
723-
copied to the Compute Server using this function.
724-
725-
In order to copy score resources to the Compute server, include the role key for
726-
each file.
727-
728-
Parameters
729-
----------
730-
model : str or dict
731-
The name or id of the model, or a dictionary representation of
732-
the model.
733-
files : list
734-
A list of dictionaries of the form {'name': filename, 'file': filecontent}.
735-
An optional 'role' key is supported for designating a file as score
736-
code, astore, etc.
737-
name : str
738-
Name of the file related to the model. The default is None.
739-
740-
Returns
741-
-------
742-
response : list of RestObj
743-
A list of uploaded file contents as instances of ``RestObj``s.
744-
'''
745-
for file in files:
746-
if isinstance(file, dict):
747-
mr.add_model_content(model, **file)
748-
else:
749-
mr.add_model_content(model, file, name)
750-
751-
return mr.copy_python_resources(model)

0 commit comments

Comments
 (0)