@@ -28,6 +28,7 @@ def writeScoreCode(
28
28
scoreCAS = True ,
29
29
isBinaryModel = False ,
30
30
binaryString = None ,
31
+ pickleType = None
31
32
):
32
33
"""
33
34
Writes a Python score code file based on training data used to generate the model
@@ -107,6 +108,8 @@ def writeScoreCode(
107
108
Sets whether the H2O model provided is a binary model or a MOJO model. By default False.
108
109
binaryString : string, optional
109
110
Binary string representation of the model object. By default None.
111
+ pickleType : string optional
112
+ Indicator for MLFlow models, which may pickle by non-standard methods. By default None.
110
113
"""
111
114
# Check if binary string model
112
115
if binaryString is not None :
@@ -174,10 +177,10 @@ def upload_and_copy_score_resources(model, files):
174
177
cls .pyFile .write (
175
178
"""\n
176
179
import math
177
- import pickle
180
+ import {pickleType}
178
181
import pandas as pd
179
182
import numpy as np"""
180
- )
183
+ ). format ( pickleType = pickleType )
181
184
# In SAS Viya 4.0 and SAS Open Model Manager, a settings.py file is generated that points to the resource
182
185
# location
183
186
if not isViya35 :
@@ -226,8 +229,8 @@ def upload_and_copy_score_resources(model, files):
226
229
cls .pyFile .write (
227
230
"""\n
228
231
with open('/models/resources/viya/{modelID}/{modelFileName}', 'rb') as _pFile:
229
- _thisModelFit = pickle .load(_pFile)""" .format (
230
- modelID = modelID , modelFileName = modelFileName
232
+ _thisModelFit = {pickleType} .load(_pFile)""" .format (
233
+ modelID = modelID , modelFileName = modelFileName , pickleType = pickleType
231
234
)
232
235
)
233
236
elif isViya35 and isBinaryModel :
@@ -241,8 +244,8 @@ def upload_and_copy_score_resources(model, files):
241
244
cls .pyFile .write (
242
245
"""\n
243
246
with open(settings.pickle_path + '{modelFileName}', 'rb') as _pFile:
244
- _thisModelFit = pickle .load(_pFile)""" .format (
245
- modelFileName = modelFileName
247
+ _thisModelFit = {pickleType} .load(_pFile)""" .format (
248
+ modelFileName = modelFileName , pickleType = pickleType
246
249
)
247
250
)
248
251
elif not isViya35 and isBinaryModel :
@@ -286,8 +289,8 @@ def score{modelPrefix}({inputVarList}):
286
289
cls .pyFile .write (
287
290
"""
288
291
with open('/models/resources/viya/{modelID}/{modelFileName}', 'rb') as _pFile:
289
- _thisModelFit = pickle .load(_pFile)""" .format (
290
- modelID = modelID , modelFileName = modelFileName
292
+ _thisModelFit = {pickleType} .load(_pFile)""" .format (
293
+ modelID = modelID , modelFileName = modelFileName , pickleType = pickleType
291
294
)
292
295
)
293
296
elif isViya35 and isH2OModel and not isBinaryModel :
@@ -309,8 +312,8 @@ def score{modelPrefix}({inputVarList}):
309
312
cls .pyFile .write (
310
313
"""
311
314
with open(settings.pickle_path + '{modelFileName}', 'rb') as _pFile:
312
- _thisModelFit = pickle .load(_pFile)""" .format (
313
- modelFileName = modelFileName
315
+ _thisModelFit = {pickleType} .load(_pFile)""" .format (
316
+ modelFileName = modelFileName , pickleType = pickleType
314
317
)
315
318
)
316
319
elif not isViya35 and isH2OModel :
0 commit comments