Skip to content

Commit e798981

Browse files
committed
Merge remote-tracking branch 'origin/customKPI' into customKPI
# Conflicts: # src/sasctl/_services/model_repository.py # src/sasctl/pzmm/__init__.py # src/sasctl/pzmm/importModel.py # src/sasctl/pzmm/pickleModel.py
2 parents 6b5e6e2 + c62963b commit e798981

File tree

3 files changed

+6
-54
lines changed

3 files changed

+6
-54
lines changed

src/sasctl/_services/model_repository.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -776,47 +776,6 @@ def get_model_details(cls, model):
776776
return cls.get("/models/%s" % id_)
777777

778778
@classmethod
779-
def create_custom_kpi(cls, model, project, body):
780-
"""_summary_
781-
782-
Parameters
783-
----------
784-
model : _type_
785-
_description_
786-
project : _type_
787-
_description_
788-
body : _type_
789-
_description_
790-
'''
791-
if cls.is_uuid(project):
792-
projectId = project
793-
elif isinstance(project, dict) and "id" in project:
794-
projectId = project["id"]
795-
else:
796-
project = cls.get_project(project)
797-
projectId = project["id"]
798-
799-
if cls.is_uuid(model):
800-
modelId = model
801-
elif isinstance(model, dict) and "id" in model:
802-
modelId = model["id"]
803-
else:
804-
model = cls.list_models(filter="eq('projectId','{}')&eq('name','{}')".format(
805-
projectId, model))
806-
modelId = model["id"]
807-
808-
headers = {"Accept": "application/vnd.sas.collection+json"}
809-
customKPI = {"TimeLabel": "{}".format(body["TimeLabel"]),
810-
"TimeSK": body["TimeSK"],
811-
"KPI": "{}".format(body["KPI"]),
812-
"Value": "{}".format(body["Value"])}
813-
requestData = {"ProjectID": projectId,
814-
"ModelID": modelId,
815-
"KPIs": [customKPI]}
816-
return cls.post("/projects/{}/kpis".format(projectId),
817-
headers=headers,
818-
data=json.dumps(requestData))
819-
@classmethod
820779
def list_project_versions(cls, project):
821780
"""_summary_
822781

src/sasctl/pzmm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
from .importModel import ImportModel
99
from .gitIntegration import GitIntegrate
1010
from .mlflow_model import MLFlowModel
11-
from .modelParameters import modelParameters
11+
from .modelParameters import ModelParameters

src/sasctl/pzmm/importModel.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,14 @@ def model_exists(project, name, force, versionName="latest"):
7575
projectId = project["id"]
7676
projectVersions = mr.list_project_versions(project)
7777
if versionName == "latest":
78-
# The "latest" option specifies the most recently created version of the project. Search only in that version.
7978
modTime = [item["modified"] for item in projectVersions]
8079
latestVersion = modTime.index(max(modTime))
8180
versionId = projectVersions[latestVersion]["id"]
82-
elif versionName == "new":
83-
# The "new" option specifies a new project version, so no models with the same name will exist already.
84-
return
8581
else:
86-
# Otherwise, search for the version name specified. If the version name is not found, produce an error message.
8782
for version in projectVersions:
88-
if versionName == version["name"]:
83+
if versionName is version["name"]:
8984
versionId = version["id"]
9085
break
91-
ValueError("No version with the name specified could be found in the project.")
9286
projectModels = mr.get(
9387
"/projects/{}/projectVersions/{}/models".format(projectId, versionId)
9488
)
@@ -179,9 +173,9 @@ def pzmmImportModel(
179173
metrics : string list, optional
180174
The scoring metrics for the model. The default is a set of two
181175
metrics: EM_EVENTPROBABILITY and EM_CLASSIFICATION.
182-
projectVersion : str, optional
183-
Name of project version to check if a model of the same name already exists. Default
184-
value is "latest".
176+
projectVersion : string, optional
177+
The project version to import the model in to on SAS Model Manager. The default value
178+
is latest.
185179
modelFileName : string, optional
186180
Name of the model file that contains the model. By default None and assigned as
187181
modelPrefix + '.pickle'.
@@ -315,8 +309,7 @@ def getFiles(extensions):
315309
model_exists(project, modelPrefix, force, versionName=projectVersion)
316310

317311
response = mr.import_model_from_zip(
318-
modelPrefix, project, zipIOFile, force, version=projectVersion
319-
312+
modelPrefix, project, zipIOFile, force, projectVersion=projectVersion
320313
)
321314
try:
322315
print(

0 commit comments

Comments
 (0)