Skip to content

Commit de30c99

Browse files
committed
Fix 500 error when importing in Viya 3.5
1 parent b4c60c6 commit de30c99

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/sasctl/pzmm/importModel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def getFiles(extensions):
255255
Path(pyPath) / (modelPrefix + "Score.py")
256256
)
257257
)
258-
zipIOFile = zm.zipFiles(Path(zPath), modelPrefix)
258+
zipIOFile = zm.zipFiles(Path(zPath), modelPrefix, isViya4=True)
259259
print("All model files were zipped to {}.".format(Path(zPath)))
260260

261261
# Check if project name provided exists and raise an error or create a new project
@@ -276,7 +276,7 @@ def getFiles(extensions):
276276
print("Model failed to import to SAS Model Manager.")
277277
# For SAS Viya 3.5, the score code is written after upload in order to know the model UUID
278278
else:
279-
zipIOFile = zm.zipFiles(Path(zPath), modelPrefix)
279+
zipIOFile = zm.zipFiles(Path(zPath), modelPrefix, isViya4=False)
280280
print("All model files were zipped to {}.".format(Path(zPath)))
281281

282282
# Check if project name provided exists and raise an error or create a new project

src/sasctl/pzmm/zipModel.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class ZipModel:
1313
@staticmethod
14-
def zipFiles(fileDir, modelPrefix):
14+
def zipFiles(fileDir, modelPrefix, isViya4=False):
1515
"""
1616
Combines all JSON files with the model pickle file and associated score code file
1717
into a single archive ZIP file.
@@ -23,6 +23,10 @@ def zipFiles(fileDir, modelPrefix):
2323
modelPrefix : string
2424
Variable name for the model to be displayed in SAS Open Model Manager
2525
(i.e. hmeqClassTree + [Score.py || .pickle]).
26+
isViya4 : boolean, optional
27+
Boolean to indicate difference in logic between SAS Viya 3.5 and SAS Viya 4.
28+
For Viya 3.5 models, ignore score code that is already in place in the file
29+
directory provided. Default value is False.
2630
2731
Yields
2832
---------------
@@ -33,7 +37,8 @@ def zipFiles(fileDir, modelPrefix):
3337

3438
fileNames = []
3539
fileNames.extend(sorted(Path(fileDir).glob("*.json")))
36-
fileNames.extend(sorted(Path(fileDir).glob("*Score.py")))
40+
if isViya4:
41+
fileNames.extend(sorted(Path(fileDir).glob("*Score.py")))
3742
fileNames.extend(sorted(Path(fileDir).glob("*.pickle")))
3843
# Include H2O.ai MOJO files
3944
fileNames.extend(sorted(Path(fileDir).glob("*.mojo")))

0 commit comments

Comments
 (0)