Skip to content

Commit 171644c

Browse files
author
Jon Walker
authored
Merge pull request #8 from jlwalke2/docstring-changes
Docstring changes
2 parents 96cedb6 + 8dd18c2 commit 171644c

File tree

5 files changed

+178
-45
lines changed

5 files changed

+178
-45
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
<p>A user-friendly REST client for SAS Viya.</p>
66

77
<a href="https://www.sas.com/en_us/software/viya.html">
8-
<img src="https://img.shields.io/badge/SAS%20Viya-3.4-blue.svg?&colorA=0b5788&style=for-the-badge&logoWidth=30&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAABLCAYAAADd0L+GAAAJ+ElEQVR42t1beVCV1xU/z5n+VW2S2rSxjdla0zrWRGubSa21ndpO28TUJm1GsWpiVRKsCkZrFaPGojRsj4CyPUCQHQUBMbJvKoqRRaMiahaFJDqKsj3e4y1gzw/mo1CW797vvTycvPEMI/O9+93fvWf9nQN9feG7XxlxyiLjWSYuCaTvLg+mn6yPpsVBh2hHSjnFFNZS6rHzdOXz5imQYxevU3LFeTLw771iC+gvfgfpsZUh9Mjrenpgsf/YgnmQN/CzjTHkHp5LSeXnqc1o9rl37163jPDHDKC+Gcdpwe50euqNPa4H84vNcRR+9AzdvNvxAjaEjTkiPT093VabrR63t55vbfKKEHkwsur083/to4i8arLb7XexAaHNyt+Wrb2zS//WvkJ6YlUojXc2mG8vC6KVYbnU0m7ykt6gdlDW7KoG+sPOZBq/yElgfrg6nAz5NWSz25vwElcK65/NYrVVro48St9aGugYmJnrDVRx4Rph4bEUu73bGJFfTU+4h2oD86xnFBXUfkQ4nbEGo3i+fcV19NDf/OXAzFgfRU3NrXOcaeRYix1He4fZYoAXvNR4a2LJuU9IkeP1jfTpzZbpcPHwbDjE4ZzD/tJz9NiK98TAwINkn24gZ55o4+3Wmb4ZJ2jl3lyaty2Rpq+LpEf/PnhDD7OTmeIRRnO2xNOr/hn0dnIp5Zy+TBab7fSAQ8W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+Lk7vjWazSvElRgZOWxsxOtUEzhidXwQufBCQ9hWfJRRWz3hGwQVKzVii7sGaPCCKdkmnsq4jQEC6c/Y9xBSGo3ww1zKkDwkj/fhG8zQki+8wAefGi/16awJNZ4ADBR24+T5pva0/PVejmJWxWK0XVFRKim/ekVKGeRwxRhMDaT7pFQQAIy2IG0PkxUYHitVqu4obwHfVAcgDiSuuG3GMflS36Zd5ov+GxlpwOGzwHGCDtY3PT2KW3puZGPRGFD13teCDG4YzUqOr1HqFymwNCqbZjsQErUHxTrvx9aXBWSKduZHqmcENKPZKOm7e6qILa3WuAoT3YIQfHQIFiBAYUYHhvcij8Pk8Mgzjd7LqKaHACk57IXcRJi1X7EM7GFKThxnUK+8eoDimXaEGzgACL4i/FMR4PGzV5X8NiGwb3Nny0MMUX3qWkMHa2etARRThfwOke6DY2ZXXZlVdIs/ofJDyyk1oFqcnkE+57yHU4/jTkh2p5Uhf+mU7Bzv8foFvOkpkgd6NPJivjPwX66dH9VYtHvAAAAAASUVORK5CYII="
8+
<img src="https://img.shields.io/badge/SAS%20Viya-3.4-blue.svg?&colorA=0b5788&logoWidth=30&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAABLCAYAAADd0L+GAAAJ+ElEQVR42t1beVCV1xU/z5n+VW2S2rSxjdla0zrWRGubSa21ndpO28TUJm1GsWpiVRKsCkZrFaPGojRsj4CyPUCQHQUBMbJvKoqRRaMiahaFJDqKsj3e4y1gzw/mo1CW797vvTycvPEMI/O9+93fvWf9nQN9feG7XxlxyiLjWSYuCaTvLg+mn6yPpsVBh2hHSjnFFNZS6rHzdOXz5imQYxevU3LFeTLw771iC+gvfgfpsZUh9Mjrenpgsf/YgnmQN/CzjTHkHp5LSeXnqc1o9rl37163jPDHDKC+Gcdpwe50euqNPa4H84vNcRR+9AzdvNvxAjaEjTkiPT093VabrR63t55vbfKKEHkwsur083/to4i8arLb7XexAaHNyt+Wrb2zS//WvkJ6YlUojXc2mG8vC6KVYbnU0m7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g/P4Rf/e+GeNF5F8XnS+tYhD0gJTW+X0hzzGjipJYFggEjS/cPhbqLXN/8ObeMQPyPba1DN6QFiCQN8KPoHPwvzmALYklAOVyIHhneF61YvTSYjSZDTO8DBjl6gMDfcPIBobbBLljp8Unbo0AiF0LENQzIFCUbsEAUiGOPrjy+cTA7JPw9SrpuuNZA+r38LwzWm9EoZ3OvOiTOpTQmMC3AyaTfbYlr+YqvcB++8uYUMKav9+ZxBO51xV6SbPgVgcyNEOC3q3Wjj/jQVOXJXf3weMg9ZxnH7z+Lk7vjWazSvElRgZOWxsxOtUEzhidXwQufBCQ9hWfJRRWz3hGwQVKzVii7sGaPCCKdkmnsq4jQEC6c/Y9xBSGo3ww1zKkDwkj/fhG8zQki+8wAefGi/16awJNZ4ADBR24+T5pva0/PVejmJWxWK0XVFRKim/ekVKGeRwxRhMDaT7pFQQAIy2IG0PkxUYHitVqu4obwHfVAcgDiSuuG3GMflS36Zd5ov+GxlpwOGzwHGCDtY3PT2KW3puZGPRGFD13teCDG4YzUqOr1HqFymwNCqbZjsQErUHxTrvx9aXBWSKduZHqmcENKPZKOm7e6qILa3WuAoT3YIQfHQIFiBAYUYHhvcij8Pk8Mgzjd7LqKaHACk57IXcRJi1X7EM7GFKThxnUK+8eoDimXaEGzgACL4i/FMR4PGzV5X8NiGwb3Nny0MMUX3qWkMHa2etARRThfwOke6DY2ZXXZlVdIs/ofJDyyk1oFqcnkE+57yHU4/jTkh2p5Uhf+mU7Bzv8foFvOkpkgd6NPJivjPwX66dH9VYtHvAAAAAASUVORK5CYII="
99
alt="SAS Viya Version"/>
1010
</a>
1111
1212
<a href="https://www.python.org/">
13-
<img src="https://img.shields.io/badge/Python-3+-blue.svg?&style=for-the-badge&colorA=254f73" alt="Python Version">
13+
<img src="https://img.shields.io/badge/Python-3+-blue.svg" alt="Python Version">
1414
</a>
15+
16+
<img src="https://travis-ci.com/jlwalke2/python-sasctl.svg?branch=master">
1517

1618
</div>
1719

src/sasctl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
__version__ = '0.9.6'
88
__author__ = 'SAS'
9-
__credits__ = ['Lucas De Paula, Peter Tobac, Jon Walker']
9+
__credits__ = ['Yi Jian Ching, Lucas De Paula, Peter Tobac, Jon Walker']
1010
__license__ = 'Apache 2.0'
1111
__copyright__ = 'Copyright © 2019, SAS Institute Inc., ' \
1212
'Cary, NC, USA. All Rights Reserved.'

src/sasctl/services/model_management.py

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,49 @@ def publish_model(model, destination, name=None, force=False):
5050
return r
5151

5252

53-
def create_performance_definition(model, library_name, table_name, name=None, description=None, cas_server=None):
53+
def create_performance_definition(model, library_name, table_name, name=None, description=None, outputLibrary=None, cas_server=None):
54+
"""Create the performance task definition in the model project to monitor model performance.
55+
56+
Parameters
57+
----------
58+
model : str or dict
59+
The name or id of the model, or a dictionary representation of the model.
60+
library_name : str
61+
The library containing the input data, default is 'Public'.
62+
table_name : str
63+
The name used for the performance data.
64+
name : str
65+
The name of the performance task, default is 'Performance'.
66+
description : str
67+
The description of the performance task, default is 'Performance monitoring for model' + model.name.
68+
cas_server : str
69+
The CAS Server for the monitoring task, default is 'cas-shared-default'.
70+
championMonitored : bool
71+
Indicates to monitor the project champion model.
72+
challengerMonitored : bool
73+
Indicates to monitor challenger models.
74+
includeAllData : bool
75+
Indicates whether to run a performance job against all the data tables in a library.
76+
scoreExecutionRequired : bool
77+
Indicates whether the scoring task execution is required. This should be set 'False' if you have provided the scores and 'True' if not.
78+
maxBins : int
79+
The maximum bins number, default is 10.
80+
resultLibrary : str
81+
The performance output table library, default is 'ModelPerformanceData'.
82+
traceOn : bool
83+
Indicates whether to turn on tracing.
84+
performanceResultSaved : bool
85+
Indicates whether the performance results are saved.
86+
loadPerformanceResult : bool
87+
Indicates to load performance result data.
88+
89+
90+
Returns
91+
-------
92+
str
93+
Performance task definition schema in JSON format.
94+
95+
"""
5496
from .model_repository import get_model, get_project
5597

5698
model = get_model(model)
@@ -62,13 +104,21 @@ def create_performance_definition(model, library_name, table_name, name=None, de
62104
raise ValueError("Project %s must have the '%s' property set." % (project.name, required))
63105

64106
request = {'projectId': project.id,
65-
'modelIds': [model.id],
66107
'name': name or model.name + ' Performance',
108+
'modelIds': [model.id],
109+
'championMonitored': False,
110+
'challengerMonitored': False,
111+
'includeAllData': False,
112+
'scoreExecutionRequired': False,
113+
'maxBins': 10,
114+
'resultLibrary': outputLibrary or 'ModelPerformanceData',
115+
'traceOn': False,
116+
'performanceResultSaved': True,
117+
'dataLibrary': library_name or 'Public',
118+
'loadPerformanceResult': False,
67119
'description': description or 'Performance definition for model ' + model.name,
68120
'casServerId': cas_server or 'cas-shared-default',
69-
'resultLibrary': 'ModelPerformanceData',
70-
'dataLibrary': library_name,
71-
'dataTable': table_name
121+
'dataPrefix': table_name
72122
}
73123

74124
# If model doesn't specify input/output variables, try to pull from project definition
@@ -79,4 +129,4 @@ def create_performance_definition(model, library_name, table_name, name=None, de
79129
request['inputVariables'] = [v.get('name') for v in project.get('variables', []) if v.get('role') == 'input']
80130
request['outputVariables'] = [v.get('name') for v in project.get('variables', []) if v.get('role') == 'output']
81131

82-
return post(SERVICE_ROOT + '/performanceTasks', json=request, headers={'Content-Type': 'application/vnd.sas.models.performance.task+json'})
132+
return post(SERVICE_ROOT + '/performanceTasks', json=request, headers={'Content-Type': 'application/vnd.sas.models.performance.task+json'})

src/sasctl/services/model_repository.py

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

7+
import sys
78
from sasctl.core import is_uuid, get, post, get_link, _build_crud_funcs, current_session
89

910

@@ -52,6 +53,18 @@ def get_model_link(model, rel, refresh=False):
5253

5354

5455
def get_astore(model):
56+
"""Get the ASTORE for a model registered int he model repository.
57+
58+
Parameters
59+
----------
60+
model : str or dict
61+
The name or id of the model, or a dictionary representation of the model.
62+
63+
Returns
64+
----------
65+
binary?
66+
67+
"""
5568
# TODO: Download binary object?
5669

5770
link = get_model_link(model, 'analyticStore', refresh=True)
@@ -61,7 +74,7 @@ def get_astore(model):
6174

6275

6376
def get_score_code(model):
64-
"""The score code for a model registered in the model repository.
77+
"""Get the score code for a model registered in the model repository.
6578
6679
Parameters
6780
----------
@@ -83,7 +96,7 @@ def get_score_code(model):
8396

8497

8598
def get_model_contents(model):
86-
"""The additional files and data associated with the model.
99+
"""Retrieve the additional files and data associated with the model.
87100
88101
Parameters
89102
----------
@@ -106,47 +119,61 @@ def get_model_contents(model):
106119
def create_model(model, project, description=None, modeler=None, function=None, algorithm=None, tool=None,
107120
is_champion=False,
108121
properties={}, **kwargs):
109-
"""
122+
"""Creates a model into a project or folder.
110123
111124
Parameters
112125
----------
113-
model
114-
project
126+
model : str or dict
127+
The name or id of the model, or a dictionary representation of the model.
128+
project : str or dict
129+
The name or id of the model project, or a dictionary representation of the model project.
115130
description : str, optional
131+
The description of the model.
116132
modeler : str, optional
117133
Name of the user that created the model. Current user name will be used if unspecified.
134+
function : str, optional
135+
The function of the model, valid values include: analytical, classification, cluster, forecasting, prediction, Text analytics, transformation.
136+
algorithm : str, optional
137+
The name of the model algorithm.
138+
tool : str, optional
139+
The name of the model tool, can be 'Python 2' or 'Python 3'.
140+
scoreCodeType : str, optional
141+
The score code type for the model.
142+
trainTable : str, optional
143+
The train data table.
144+
classificationEventProbabilityVariableName : str, optional
145+
The name of the event probability variable.
146+
classificationTargetEventValue : str, optional
147+
The target event value.
148+
champion : bool, optional
149+
Indicates whether the project has champion model or not.
150+
role : str, optional
151+
The role of the model, valid values include: plain, champion, challenger.
152+
location : str, optional,
153+
The location of this model.
154+
targetVariable : str, optional
155+
The name of the target variable.
156+
suggestedChampion : bool
157+
Indicates the model was suggested as the champion at import time.
158+
retrainable : bool
159+
Indicates whether the model can be retrained or not.
160+
immutable : bool
161+
Indicates whether the model can be changed or not.
162+
modelVersionName : str, optional
163+
The display name for the model version.
164+
properties : array_like, optional (custom properties)
165+
Custom model properties that can be set: name, value, type
166+
167+
inputVariables : array_like, optional
168+
Model input variables. By default, these are the same as the model project.
169+
outputVariables : array_like, optional
170+
Model output variables. By default, these are the same as the model project.
118171
119-
function
120-
algorithm
121-
tool
122-
modeler
123-
scoreCodeType
124-
trainTable
125-
classificationEventProbabilityVariableName
126-
classificationTargetEventValue
127-
champion (T/F)
128-
role
129-
location
130-
targetVariable
131-
projectId, projectName, projectVersionId, projectVersionName???
132-
suggestedChampion (T/F)
133-
retrainable
134-
immutable
135-
modelVersionName
136-
properties (custom properties)
137-
name
138-
value
139-
type
140-
inputVariables
141-
-
142-
outputVariables
143-
-
144-
145-
properties
146-
kwargs
147172
148173
Returns
149174
-------
175+
str
176+
The model schema returned in JSON format.
150177
151178
"""
152179

@@ -177,6 +204,27 @@ def create_model(model, project, description=None, modeler=None, function=None,
177204

178205

179206
def add_model_content(model, file, name=None, role=None):
207+
"""Add additional files to the model.
208+
209+
Parameters
210+
----------
211+
model : str or dict
212+
The name or id of the model, or a dictionary representation of the model.
213+
file : str or bytes
214+
A file related to the model, such as the model code.
215+
name : str
216+
Name of the file related to the model.
217+
role : str
218+
Role of the model file, such as 'Python pickle'.
219+
220+
221+
Returns
222+
-------
223+
str
224+
The model content schema.
225+
226+
"""
227+
180228
if is_uuid(model):
181229
id = model
182230
elif isinstance(model, dict) and 'id' in model:
@@ -211,6 +259,22 @@ def default_repository():
211259

212260

213261
def create_project(project, repository, **kwargs):
262+
"""Create a model project in the given model repository.
263+
264+
Parameters
265+
----------
266+
project : str or dict
267+
The name or id of the model project, or a dictionary representation of the project.
268+
repository : str or dict
269+
The name or id of the model repository, or a dictionary representation of the repository.
270+
271+
Returns
272+
-------
273+
RestObj
274+
275+
"""
276+
277+
214278
if isinstance(project, str):
215279
project = {'name': project}
216280

@@ -226,6 +290,25 @@ def create_project(project, repository, **kwargs):
226290
def import_model_from_zip(name, project, file, description=None, version='latest'):
227291
# TODO: Allow import into folder if no project is given
228292
# TODO: Create new version if model already exists
293+
"""Import a model and contents as a ZIP file into a model project.
294+
295+
Parameters
296+
----------
297+
name : str or dict
298+
The name of the model.
299+
project : str or dict
300+
The name or id of the model project, or a dictionary representation of the project.
301+
description : str
302+
The description of the model.
303+
file : byte
304+
The ZIP file containing the model and contents.
305+
306+
Returns
307+
-------
308+
ResponseObj
309+
The API response after importing the model.
310+
311+
"""
229312
project = get_project(project)
230313

231314
if project is None:
@@ -244,5 +327,3 @@ def import_model_from_zip(name, project, file, description=None, version='latest
244327
headers={'Content-Type': 'application/octet-stream'})
245328

246329
return r
247-
248-

tests/unit/test_model_management.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_create_performance_definition():
6262
assert PROJECT['id'] == data['json']['projectId']
6363
assert MODEL['id'] in data['json']['modelIds']
6464
assert 'TestLibrary' == data['json']['dataLibrary']
65-
assert 'TestData' == data['json']['dataTable']
65+
assert 'TestData' == data['json']['dataPrefix']
6666
assert 'cas-shared-default' == data['json']['casServerId']
6767
assert data['json']['name'] is not None
6868
assert data['json']['description'] is not None

0 commit comments

Comments
 (0)