Skip to content

Commit fcc856e

Browse files
committed
cleanup
1 parent 8f6c0cf commit fcc856e

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/sasctl/tasks.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import sys
1414
import warnings
1515

16-
from deprecated.sphinx import versionchanged
17-
1816
from . import utils
1917
from .core import RestObj, get, get_link, request_link
2018
from .services import model_management as mm
@@ -130,23 +128,28 @@ def register_model(model, name, project, repository=None, input=None,
130128
if create_project:
131129
project = mr.create_project(project, repository)
132130

133-
model = mr.import_model_from_zip(name, project, zipfile, version=version)
131+
model = mr.import_model_from_zip(name, project, zipfile,
132+
version=version)
134133
return model
135134

136135
# If the model is an scikit-learn model, generate the model dictionary
137136
# from it and pickle the model for storage
138-
elif all(hasattr(model, attr) for attr in ['_estimator_type', 'get_params']):
137+
elif all(hasattr(model, attr) for attr
138+
in ['_estimator_type', 'get_params']):
139139
# Pickle the model so we can store it
140140
model_pkl = pickle.dumps(model)
141-
files.append({'name': 'model.pkl', 'file': model_pkl, 'role': 'Python Pickle'})
141+
files.append({'name': 'model.pkl',
142+
'file': model_pkl,
143+
'role': 'Python Pickle'})
142144

143145
# Extract model properties
144146
model = _sklearn_to_dict(model)
145147
model['name'] = name
146148

147149
# Generate PyMAS wrapper
148150
try:
149-
mas_module = from_pickle(model_pkl, 'predict', input_types=input, array_input=True)
151+
mas_module = from_pickle(model_pkl, 'predict',
152+
input_types=input, array_input=True)
150153
assert isinstance(mas_module, PyMAS)
151154

152155
# Include score code files from ESP and MAS
@@ -161,10 +164,9 @@ def register_model(model, name, project, repository=None, input=None,
161164
for var in mas_module.variables
162165
if not var.out]
163166

164-
model['outputVariables'] = [var.as_model_metadata()
165-
for var in mas_module.variables
166-
if var.out
167-
and var.name not in ('rc', 'msg')]
167+
model['outputVariables'] = \
168+
[var.as_model_metadata() for var in mas_module.variables
169+
if var.out and var.name not in ('rc', 'msg')]
168170
except ValueError:
169171
# PyMAS creation failed, most likely because input data wasn't
170172
# provided
@@ -175,8 +177,14 @@ def register_model(model, name, project, repository=None, input=None,
175177
assert isinstance(model, dict)
176178

177179
if create_project:
178-
vars = model.get('inputVariables', []) + model.get('outputVariables', [])
179-
target_level = 'Interval' if model.get('function') == 'Regression' else None
180+
vars = model.get('inputVariables', [])
181+
vars += model.get('outputVariables', [])
182+
183+
if model.get('function') == 'Regression':
184+
target_level = 'Interval'
185+
else:
186+
target_level = None
187+
180188
project = mr.create_project(project, repository,
181189
variables=vars,
182190
targetLevel=target_level)
@@ -202,15 +210,17 @@ def publish_model(model, destination, code=None, max_retries=60,
202210
Parameters
203211
----------
204212
model : str or dict
205-
The name or id of the model, or a dictionary representation of the model.
213+
The name or id of the model, or a dictionary representation of
214+
the model.
206215
destination : str
207216
code : optional
208217
max_retries : int, optional
209218
replace : bool, optional
210219
Whether to overwrite the model if it already exists in
211220
the `destination`
212221
kwargs : optional
213-
additional arguments will be passed to the underlying publish functions.
222+
additional arguments will be passed to the underlying publish
223+
functions.
214224
215225
Returns
216226
-------
@@ -300,4 +310,3 @@ def submit_request():
300310
from sasctl.services import microanalytic_score as mas
301311
return mas.define_steps(module)
302312
return module
303-

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ deps =
5454
tests: pandas
5555
tests: swat
5656
tests: kerberos ; platform_system != "Windows"
57-
flake8: flake8==3.7.7
5857
codecov: codecov >= 1.4.0
5958
doc: sphinx == 1.8
6059
doc: deprecated == 1.2.6

0 commit comments

Comments
 (0)