Skip to content

Commit 27c9743

Browse files
committed
updated formatting
1 parent 6d0b9a3 commit 27c9743

File tree

2 files changed

+42
-21
lines changed

2 files changed

+42
-21
lines changed

src/sasctl/services/model_repository.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,28 @@ def get_model_contents(model):
116116
return get(link.get('href'), headers={'Accept': link.get('itemType', '*/*')})
117117

118118

119-
def create_model(model, project, description=None, modeler=None, function=None, algorithm=None, tool=None,
120-
is_champion=False,
121-
properties={}, **kwargs):
119+
def create_model(model, project, description=None, modeler=None, function=None,
120+
algorithm=None, tool=None, is_champion=False, properties={},
121+
**kwargs):
122122
"""Creates a model into a project or folder.
123123
124124
Parameters
125125
----------
126126
model : str or dict
127-
The name or id of the model, or a dictionary representation of the model.
127+
The name or id of the model, or a dictionary representation of the
128+
model.
128129
project : str or dict
129-
The name or id of the model project, or a dictionary representation of the model project.
130+
The name or id of the model project, or a dictionary representation of
131+
the model project.
130132
description : str, optional
131133
The description of the model.
132134
modeler : str, optional
133-
Name of the user that created the model. Current user name will be used if unspecified.
135+
Name of the user that created the model. Current user name will be
136+
used if unspecified.
134137
function : str, optional
135-
The function of the model, valid values include: analytical, classification, cluster, forecasting, prediction, Text analytics, transformation.
138+
The function of the model, valid values include: analytical,
139+
classification, cluster, forecasting, prediction, Text analytics,
140+
transformation.
136141
algorithm : str, optional
137142
The name of the model algorithm.
138143
tool : str, optional
@@ -148,7 +153,8 @@ def create_model(model, project, description=None, modeler=None, function=None,
148153
champion : bool, optional
149154
Indicates whether the project has champion model or not.
150155
role : str, optional
151-
The role of the model, valid values include: plain, champion, challenger.
156+
The role of the model, valid values include: plain, champion,
157+
challenger.
152158
location : str, optional,
153159
The location of this model.
154160
targetVariable : str, optional
@@ -165,10 +171,11 @@ def create_model(model, project, description=None, modeler=None, function=None,
165171
Custom model properties that can be set: name, value, type
166172
167173
inputVariables : array_like, optional
168-
Model input variables. By default, these are the same as the model project.
174+
Model input variables. By default, these are the same as the model
175+
project.
169176
outputVariables : array_like, optional
170-
Model output variables. By default, these are the same as the model project.
171-
177+
Model output variables. By default, these are the same as the model
178+
project.
172179
173180
Returns
174181
-------

src/sasctl/tasks.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def register_model(model, name, project, repository=None, input=None, version='l
119119
model = mr.import_model_from_zip(name, project, zipfile, version=version)
120120
return model
121121

122-
# If the model is an scikit-learn model, generate the model dictionary from it and pickle the model for storage
122+
# If the model is an scikit-learn model, generate the model dictionary
123+
# from it and pickle the model for storage
123124
elif all(hasattr(model, attr) for attr in ['_estimator_type', 'get_params']):
124125
# Pickle the model so we can store it
125126
model_pkl = pickle.dumps(model)
@@ -135,23 +136,36 @@ def register_model(model, name, project, repository=None, input=None, version='l
135136
assert isinstance(mas_module, PyMAS)
136137

137138
# Include score code files from ESP and MAS
138-
files.append({'name': 'dmcas_packagescorecode.sas', 'file': mas_module.score_code(), 'role': 'Score Code'})
139-
files.append({'name': 'dmcas_espscorecode.sas', 'file': mas_module.score_code(dest='ESP'), 'role': 'Score Code'})
140-
141-
model['inputVariables'] = [var.as_model_metadata() for var in mas_module.variables if not var.out]
142-
model['outputVariables'] = [var.as_model_metadata() for var in mas_module.variables if var.out]
139+
files.append({'name': 'dmcas_packagescorecode.sas',
140+
'file': mas_module.score_code(),
141+
'role': 'Score Code'})
142+
files.append({'name': 'dmcas_espscorecode.sas',
143+
'file': mas_module.score_code(dest='ESP'),
144+
'role': 'Score Code'})
145+
146+
model['inputVariables'] = [var.as_model_metadata()
147+
for var in mas_module.variables
148+
if not var.out]
149+
150+
model['outputVariables'] = [var.as_model_metadata()
151+
for var in mas_module.variables
152+
if var.out
153+
and var.name not in ('rc', 'msg')]
143154
except ValueError:
144-
# PyMAS creation failed, most likely because input data wasn't provided
145-
warnings.warn('Unable to determine input/output variables. Model variables will not be specified.')
146-
155+
# PyMAS creation failed, most likely because input data wasn't
156+
# provided
157+
warnings.warn('Unable to determine input/output variables. '
158+
' Model variables will not be specified.')
147159
else:
148160
# Otherwise, the model better be a dictionary of metadata
149161
assert isinstance(model, dict)
150162

151163
if create_project:
152164
vars = model.get('inputVariables', []) + model.get('outputVariables', [])
153165
target_level = 'Interval' if model.get('function') == 'Regression' else None
154-
project = mr.create_project(project, repository, variables=vars, targetLevel=target_level)
166+
project = mr.create_project(project, repository,
167+
variables=vars,
168+
targetLevel=target_level)
155169

156170
model = mr.create_model(model, project)
157171

0 commit comments

Comments
 (0)