@@ -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 :
@@ -219,8 +222,8 @@ def upload_and_copy_score_resources(model, files):
219
222
cls .pyFile .write (
220
223
"""\n
221
224
with open('/models/resources/viya/{modelID}/{modelFileName}', 'rb') as _pFile:
222
- _thisModelFit = pickle .load(_pFile)""" .format (
223
- modelID = modelID , modelFileName = modelFileName
225
+ _thisModelFit = {pickleType} .load(_pFile)""" .format (
226
+ modelID = modelID , modelFileName = modelFileName , pickleType = pickleType
224
227
)
225
228
)
226
229
elif isViya35 and isBinaryModel :
@@ -234,8 +237,8 @@ def upload_and_copy_score_resources(model, files):
234
237
cls .pyFile .write (
235
238
"""\n
236
239
with open(settings.pickle_path + '{modelFileName}', 'rb') as _pFile:
237
- _thisModelFit = pickle .load(_pFile)""" .format (
238
- modelFileName = modelFileName
240
+ _thisModelFit = {pickleType} .load(_pFile)""" .format (
241
+ modelFileName = modelFileName , pickleType = pickleType
239
242
)
240
243
)
241
244
elif not isViya35 and isBinaryModel :
@@ -279,8 +282,8 @@ def score{modelPrefix}({inputVarList}):
279
282
cls .pyFile .write (
280
283
"""
281
284
with open('/models/resources/viya/{modelID}/{modelFileName}', 'rb') as _pFile:
282
- _thisModelFit = pickle .load(_pFile)""" .format (
283
- modelID = modelID , modelFileName = modelFileName
285
+ _thisModelFit = {pickleType} .load(_pFile)""" .format (
286
+ modelID = modelID , modelFileName = modelFileName , pickleType = pickleType
284
287
)
285
288
)
286
289
elif isViya35 and isH2OModel and not isBinaryModel :
@@ -302,8 +305,8 @@ def score{modelPrefix}({inputVarList}):
302
305
cls .pyFile .write (
303
306
"""
304
307
with open(settings.pickle_path + '{modelFileName}', 'rb') as _pFile:
305
- _thisModelFit = pickle .load(_pFile)""" .format (
306
- modelFileName = modelFileName
308
+ _thisModelFit = {pickleType} .load(_pFile)""" .format (
309
+ modelFileName = modelFileName , pickleType = pickleType
307
310
)
308
311
)
309
312
elif not isViya35 and isH2OModel :
0 commit comments