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
@@ -41,10 +59,13 @@ def create_package_from_astore(table):
41
59
raise RuntimeError (result )
42
60
43
61
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 )
45
64
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 ()]
48
69
astore_filename = '_' + uuid .uuid4 ().hex [:25 ].upper ()
49
70
50
71
# Copy the ASTORE table to the ModelStore.
@@ -72,7 +93,11 @@ def json_file(data, filename):
72
93
73
94
filename = os .path .join (folder , 'dmcas_packagescorecode.sas' )
74
95
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 )
76
101
77
102
filename = os .path .join (folder , astore_filename )
78
103
with open (filename , 'wb' ) as f :
@@ -130,12 +155,12 @@ def _get_model_properties(result):
130
155
"tool" : "" ,
131
156
"toolVersion" : "" ,
132
157
"targetVariable" : "" ,
133
- "scoreCodeType" : "ds2Package " ,
158
+ "scoreCodeType" : "ds2MultiType " ,
134
159
"externalModelId" : "" ,
135
160
"function" : "" ,
136
161
"eventProbVar" : "" ,
137
162
"modeler" : "" ,
138
- "name" : "CustomerLifetimeValueScore " ,
163
+ "name" : "" ,
139
164
"targetEvent" : "" ,
140
165
"targetLevel" : "" ,
141
166
"algorithm" : ""
0 commit comments