Skip to content

Commit e086176

Browse files
committed
reload model table on publish to CAS
1 parent e9c5541 commit e086176

7 files changed

+1739
-1617
lines changed

src/sasctl/_services/model_management.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@ class ModelManagement(Service):
2020
'performance tasks')
2121

2222
# TODO: set ds2MultiType
23-
def publish_model(self, model, destination, name=None, force=False, casEndPoint=False):
23+
def publish_model(self,
24+
model,
25+
destination,
26+
name=None,
27+
force=False,
28+
reload_model_table=False):
2429
"""
2530
2631
Parameters
2732
----------
2833
model
2934
destination
3035
name
31-
force
36+
force : bool, optional
37+
Whether to overwrite the model if it already exists in the
38+
publishing `destination`.
39+
reload_model_table : bool, optional
40+
Whether the model table in CAS should be reloaded. Defaults to
41+
False.
3242
3343
Returns
3444
-------
@@ -50,7 +60,8 @@ def publish_model(self, model, destination, name=None, force=False, casEndPoint=
5060

5161
# TODO: Verify allowed formats by destination type.
5262
# As of 19w04 MAS throws HTTP 500 if name is in invalid format.
53-
model_name = name or '{}_{}'.format(model_obj['name'].replace(' ', ''), model_obj['id']).replace('-', '')
63+
model_name = name or '{}_{}'.format(model_obj['name'].replace(' ', ''),
64+
model_obj['id']).replace('-', '')
5465

5566
request = {
5667
"name": model_obj.get('name'),
@@ -69,12 +80,12 @@ def publish_model(self, model, destination, name=None, force=False, casEndPoint=
6980
# Publishes a model that has already been registered in the model
7081
# repository.
7182
# Unlike model_publish service, does not require Code to be specified.
72-
if casEndPoint:
73-
r = self.post('/publish', json=request, params=dict(force=force,reloadModelTable=True),
74-
headers={'Content-Type': 'application/vnd.sas.models.publishing.request.asynchronous+json'})
75-
else:
76-
r = self.post('/publish', json=request, params=dict(force=force),
77-
headers={'Content-Type': 'application/vnd.sas.models.publishing.request.asynchronous+json'})
83+
r = self.post('/publish',
84+
json=request,
85+
params=dict(force=force,
86+
reloadModelTable=reload_model_table),
87+
headers={'Content-Type':
88+
'application/vnd.sas.models.publishing.request.asynchronous+json'})
7889
return r
7990

8091
def create_performance_definition(self,

src/sasctl/tasks.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ def register_model(model, name, project, repository=None, input=None,
219219
return model
220220

221221

222-
def publish_model(model, destination, code=None, max_retries=60,
222+
def publish_model(model,
223+
destination,
224+
code=None,
225+
max_retries=60,
223226
replace=False, **kwargs):
224227
"""Publish a model to a configured publishing destination.
225228
@@ -264,13 +267,15 @@ def publish_model(model, destination, code=None, max_retries=60,
264267
def submit_request():
265268
# Submit a publishing request
266269
if code is None:
267-
destType=mp.get_destination(destination).destinationType
268-
if destType == "cas":
270+
dest_obj = mp.get_destination(destination)
271+
272+
if dest_obj and dest_obj.destinationType == "cas":
269273
publish_req = mm.publish_model(model, destination,
270-
force=replace, casEndPoint=True, **kwargs)
274+
force=replace,
275+
reload_model_table=True)
271276
else:
272277
publish_req = mm.publish_model(model, destination,
273-
force=replace, **kwargs)
278+
force=replace)
274279
else:
275280
publish_req = mp.publish_model(model, destination,
276281
code=code, **kwargs)

tests/cassettes/tests.integration.test_examples.test_full_lifecycle.json

Lines changed: 573 additions & 395 deletions
Large diffs are not rendered by default.

tests/cassettes/tests.integration.test_examples.test_sklearn_model.json

Lines changed: 275 additions & 264 deletions
Large diffs are not rendered by default.

tests/cassettes/tests.integration.test_tasks.TestModels.test_publish_sklearn.json

Lines changed: 631 additions & 124 deletions
Large diffs are not rendered by default.

tests/cassettes/tests.integration.test_tasks.TestModels.test_publish_sklearn_again.json

Lines changed: 177 additions & 767 deletions
Large diffs are not rendered by default.

tests/cassettes/tests.integration.test_tasks.TestModels.test_register_sklearn.json

Lines changed: 53 additions & 53 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)