Skip to content

Commit 7d892da

Browse files
committed
Catch incorrect model formats in write score code.
1 parent 9228ef2 commit 7d892da

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/sasctl/pzmm/writeScoreCode.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,25 @@ def upload_and_copy_score_resources(model, files):
203203
)
204204
)
205205
elif isViya35 and isH2OModel and not isBinaryModel:
206-
cls.pyFile.write(
207-
"""\n
206+
try:
207+
cls.pyFile.write(
208+
"""\n
208209
with gzip.open('/models/resources/viya/{modelID}/{modelFileName}', 'r') as fileIn, open('/models/resources/viya/{
209210
modelID}/{modelZipFileName}', 'wb') as fileOut:
210211
shutil.copyfileobj(fileIn, fileOut)
211212
os.chmod('/models/resources/viya/{modelID}/{modelZipFileName}', 0o777)
212213
_thisModelFit = h2o.import_mojo('/models/resources/viya/{modelID}/{modelZipFileName}')""".format(
213-
modelID=modelID,
214-
modelFileName=modelFileName,
215-
modelZipFileName=modelFileName[:-4] + "zip",
214+
modelID=modelID,
215+
modelFileName=modelFileName,
216+
modelZipFileName=modelFileName[:-4] + "zip",
217+
)
218+
)
219+
except AttributeError:
220+
raise ValueError(
221+
"The following is not a valid model to register in this format. "
222+
+ "Please verify that the appropriate arguments have been provided "
223+
+ "to the import model function."
216224
)
217-
)
218225
elif isViya35 and not isH2OModel:
219226
cls.pyFile.write(
220227
"""\n

0 commit comments

Comments
 (0)