Skip to content

Commit 82a29e5

Browse files
committed
generate ep score code
1 parent 67107d2 commit 82a29e5

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
Unreleased
33
----------
44

5-
-
5+
**Bugfixes**
6+
- The `register_model` task now generates dmcas_epscorecode.sas files for ASTORE models.
7+
68

79
v1.1.3 (2019-8-14)
810
-----------------
911

10-
**Bugfixes**
12+
**Bugfixes**
1113
- Fixed problem causing `register_model` task to include output variables in the input variables list.
1214

1315

src/sasctl/utils/astore.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,26 @@
1919

2020

2121
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+
"""
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

@@ -36,10 +54,13 @@ def create_package_from_astore(table):
3654
raise RuntimeError(result)
3755

3856
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)
4059
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()]
4364
astore_filename = '_' + uuid.uuid4().hex[:25].upper()
4465

4566
# Copy the ASTORE table to the ModelStore.
@@ -67,7 +88,11 @@ def json_file(data, filename):
6788

6889
filename = os.path.join(folder, 'dmcas_packagescorecode.sas')
6990
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)
7196

7297
filename = os.path.join(folder, astore_filename)
7398
with open(filename, 'wb') as f:
@@ -125,12 +150,12 @@ def _get_model_properties(result):
125150
"tool": "",
126151
"toolVersion": "",
127152
"targetVariable": "",
128-
"scoreCodeType": "ds2Package",
153+
"scoreCodeType": "ds2MultiType",
129154
"externalModelId": "",
130155
"function": "",
131156
"eventProbVar": "",
132157
"modeler": "",
133-
"name": "CustomerLifetimeValueScore",
158+
"name": "",
134159
"targetEvent": "",
135160
"targetLevel": "",
136161
"algorithm": ""

0 commit comments

Comments
 (0)