19
19
20
20
21
21
def 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
+ """
22
39
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." )
24
42
25
43
assert isinstance (table , swat .CASTable )
26
44
@@ -36,10 +54,13 @@ def create_package_from_astore(table):
36
54
raise RuntimeError (result )
37
55
38
56
astore_key = result .Key .Key [0 ].strip ()
39
- ds2 = _generate_package_code (result )
57
+ ep_ds2 = result .epcode
58
+ package_ds2 = _generate_package_code (result )
40
59
model_properties = _get_model_properties (result )
41
- input_vars = [get_variable_properties (var ) for var in result .InputVariables .itertuples ()]
42
- output_vars = [get_variable_properties (var ) for var in result .OutputVariables .itertuples ()]
60
+ input_vars = [get_variable_properties (var )
61
+ for var in result .InputVariables .itertuples ()]
62
+ output_vars = [get_variable_properties (var )
63
+ for var in result .OutputVariables .itertuples ()]
43
64
astore_filename = '_' + uuid .uuid4 ().hex [:25 ].upper ()
44
65
45
66
# Copy the ASTORE table to the ModelStore.
@@ -67,7 +88,11 @@ def json_file(data, filename):
67
88
68
89
filename = os .path .join (folder , 'dmcas_packagescorecode.sas' )
69
90
with open (filename , 'w' ) as f :
70
- f .write ('\n ' .join (ds2 ))
91
+ f .write ('\n ' .join (package_ds2 ))
92
+
93
+ filename = os .path .join (folder , 'dmcas_epscorecode.sas' )
94
+ with open (filename , 'w' ) as f :
95
+ f .write (ep_ds2 )
71
96
72
97
filename = os .path .join (folder , astore_filename )
73
98
with open (filename , 'wb' ) as f :
@@ -125,12 +150,12 @@ def _get_model_properties(result):
125
150
"tool" : "" ,
126
151
"toolVersion" : "" ,
127
152
"targetVariable" : "" ,
128
- "scoreCodeType" : "ds2Package " ,
153
+ "scoreCodeType" : "ds2MultiType " ,
129
154
"externalModelId" : "" ,
130
155
"function" : "" ,
131
156
"eventProbVar" : "" ,
132
157
"modeler" : "" ,
133
- "name" : "CustomerLifetimeValueScore " ,
158
+ "name" : "" ,
134
159
"targetEvent" : "" ,
135
160
"targetLevel" : "" ,
136
161
"algorithm" : ""
0 commit comments