1919
2020
2121def create_package_from_astore (table ):
22+ """Create an importable model package from an ASTORE.
23+
24+ Parameters
25+ ----------
26+ table : swat.CASTable
27+ The CAS table containing the ASTORE.
28+
29+ Returns
30+ -------
31+ BytesIO
32+ A byte stream representing a ZIP archive which can be imported.
33+
34+ See Also
35+ --------
36+ :meth:`model_repository.import_model_from_zip <.ModelRepository.import_model_from_zip>`
37+
38+ """
2239 if swat is None :
23- raise RuntimeError ("The 'swat' package is required to work with ASTORE models." )
40+ raise RuntimeError ("The 'swat' package is required to work with "
41+ "ASTORE models." )
2442
2543 assert isinstance (table , swat .CASTable )
2644
@@ -41,10 +59,13 @@ def create_package_from_astore(table):
4159 raise RuntimeError (result )
4260
4361 astore_key = result .Key .Key [0 ].strip ()
44- ds2 = _generate_package_code (result )
62+ ep_ds2 = result .epcode
63+ package_ds2 = _generate_package_code (result )
4564 model_properties = _get_model_properties (result )
46- input_vars = [get_variable_properties (var ) for var in result .InputVariables .itertuples ()]
47- output_vars = [get_variable_properties (var ) for var in result .OutputVariables .itertuples ()]
65+ input_vars = [get_variable_properties (var )
66+ for var in result .InputVariables .itertuples ()]
67+ output_vars = [get_variable_properties (var )
68+ for var in result .OutputVariables .itertuples ()]
4869 astore_filename = '_' + uuid .uuid4 ().hex [:25 ].upper ()
4970
5071 # Copy the ASTORE table to the ModelStore.
@@ -72,7 +93,11 @@ def json_file(data, filename):
7293
7394 filename = os .path .join (folder , 'dmcas_packagescorecode.sas' )
7495 with open (filename , 'w' ) as f :
75- f .write ('\n ' .join (ds2 ))
96+ f .write ('\n ' .join (package_ds2 ))
97+
98+ filename = os .path .join (folder , 'dmcas_epscorecode.sas' )
99+ with open (filename , 'w' ) as f :
100+ f .write (ep_ds2 )
76101
77102 filename = os .path .join (folder , astore_filename )
78103 with open (filename , 'wb' ) as f :
@@ -130,12 +155,12 @@ def _get_model_properties(result):
130155 "tool" : "" ,
131156 "toolVersion" : "" ,
132157 "targetVariable" : "" ,
133- "scoreCodeType" : "ds2Package " ,
158+ "scoreCodeType" : "ds2MultiType " ,
134159 "externalModelId" : "" ,
135160 "function" : "" ,
136161 "eventProbVar" : "" ,
137162 "modeler" : "" ,
138- "name" : "CustomerLifetimeValueScore " ,
163+ "name" : "" ,
139164 "targetEvent" : "" ,
140165 "targetLevel" : "" ,
141166 "algorithm" : ""
0 commit comments