Skip to content

Commit 17454b7

Browse files
committed
Merge branches 'dev-1.3.0' and 'master' of https://github.com/sassoftware/python-sasctl into dev-1.3.0
2 parents 28761bb + 0d0cd57 commit 17454b7

File tree

7 files changed

+382
-7
lines changed

7 files changed

+382
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Unreleased
1010
- Improved API documentation
1111

1212

13+
v1.2.4 (2019-9-20)
14+
------------------
15+
**Bugfixes**
16+
- `model_repository.get_model_contents` no longer raises an HTTP 406 error.
17+
1318
v1.2.3 (2019-8-23)
1419
------------------
1520
**Changes**

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ which can handle all necessary communication with the SAS Viya server:
8181
8282
>>> with Session('example.com', authinfo=<authinfo file>):
8383
... model = lm.LogisticRegression()
84-
... register_model('Sklearn Model', model, 'My Project')
84+
... register_model(model, 'Sklearn Model', 'My Project')
8585
```
8686

8787

@@ -165,7 +165,7 @@ Register a pure Python model in Model Manager:
165165
166166
>>> with Session(host, authinfo=<authinfo file>):
167167
... model = lm.LogisticRegression()
168-
... register_model('Sklearn Model', model, 'My Project')
168+
... register_model(model, 'Sklearn Model', 'My Project')
169169
```
170170

171171
Register a CAS model in Model Manager:

src/sasctl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
55
# SPDX-License-Identifier: Apache-2.0
66

7-
__version__ = '1.2.3'
7+
__version__ = '1.2.4'
88
__author__ = 'SAS'
99
__credits__ = ['Yi Jian Ching, Lucas De Paula, James Kochuba, Peter Tobac, '
1010
'Chris Toth, Jon Walker']

src/sasctl/_services/model_repository.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ def get_model_contents(cls, model):
143143
"""
144144
link = cls.get_model_link(model, 'contents', refresh=True)
145145

146-
if link is not None:
147-
return get(link.get('href'),
148-
headers={'Accept': link.get('itemType', '*/*')})
146+
return cls.request_link(link, 'contents')
149147

150148
@classmethod
151149
def create_model(cls, model, project,

src/sasctl/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,9 @@ def get_link(obj, rel):
792792
return links[0]
793793
elif len(links) > 1:
794794
return links
795+
elif isinstance(obj, dict) and 'rel' in obj and obj['rel'] == rel:
796+
# Object is already a link, just return it
797+
return obj
795798

796799

797800
def request_link(obj, rel, **kwargs):
@@ -813,7 +816,6 @@ def request_link(obj, rel, **kwargs):
813816
if link is None:
814817
raise ValueError("Link '%s' not found in object %s." % (rel, obj))
815818

816-
817819
return request(link['method'], link['href'], **kwargs)
818820

819821

tests/cassettes/tests.integration.test_model_repository.TestAStoreModel.test_get_model_contents.json

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

tests/integration/test_model_repository.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ def test_model_import(self, astore):
2626

2727
assert self.model_name == model.name
2828

29+
def test_get_model_contents(self):
30+
# Resolves https://github.com/sassoftware/python-sasctl/issues/33
31+
content = mr.get_model_contents(self.model_name)
32+
33+
assert isinstance(content, list)
34+
assert 'AstoreMetadata.json' in [str(c) for c in content]
35+
assert 'ModelProperties.json' in [str(c) for c in content]
36+
assert 'inputVar.json' in [str(c) for c in content]
37+
assert 'outputVar.json' in [str(c) for c in content]
38+
2939
def test_create_model_version(self):
3040
r = mr.create_model_version(self.model_name)
3141
assert r.modelVersionName == '2.0'

0 commit comments

Comments
 (0)