Skip to content

Commit f15dbe6

Browse files
update more docstrings
1 parent a3f4a52 commit f15dbe6

23 files changed

+74
-60
lines changed

doc/conf.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
intersphinx_mapping = {
5353
"python": ("https://docs.python.org/3/", None),
5454
"pandas": ("https://pandas.pydata.org/docs/", None),
55+
"sklearn": ("https://scikit-learn.org/stable/", None),
5556
"numpy": ("https://numpy.org/doc/stable/", None),
5657
"swat": ("https://sassoftware.github.io/python-swat/", None),
5758
"pytest": ("https://docs.pytest.org/en/latest/", None),
@@ -67,7 +68,6 @@
6768
napoleon_google_docstring = False
6869
napoleon_numpy_docstring = True
6970
napoleon_use_ivar = True
70-
napoleon_use_param = False
7171
napoleon_use_rtype = False
7272

7373
todo_include_todos = True
@@ -103,7 +103,13 @@
103103

104104
# Suppress warnings 'py:class reference target not found: <type>'
105105
nitpicky = True
106-
nitpick_ignore = [('py:class','Response'),('py:class','Request'),('py:class','sasctl._services.service.Service')]
106+
nitpick_ignore = [
107+
('py:class','optional'),
108+
('py:class','json.encoder.JSONEncoder'), # I don't understand why it can't find it
109+
('py:class','Response'),
110+
('py:class','Request'),
111+
('py:class','sasctl._services.service.Service') # should the Service class be documented?
112+
]
107113

108114
# -- Options for HTML output -------------------------------------------------
109115

src/sasctl/_services/cas_management.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ def upload_file(
324324
header : bool, optional
325325
Whether the first row of data contains column headers. Defaults to
326326
True.
327-
format_ : {"csv", "xls", "xlsx", "sas7bdat", "sashdat"}, optional
327+
format_ : str, optional
328+
Choose from {"csv", "xls", "xlsx", "sas7bdat", "sashdat"}.
328329
File of input `file`. Not required if format can be discerned from
329330
the file path.
330331
detail : dict, optional

src/sasctl/_services/concepts.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def assign_concepts(
3737
3838
Parameters
3939
----------
40-
documents : str or dict or list_like
40+
documents : str or dict or list
4141
Documents to analyze. May be either the URI to a CAS table where the
4242
documents are currently stored, or an iterable of strings containing
4343
the documents' text.
@@ -55,8 +55,9 @@ def assign_concepts(
5555
model
5656
output_postfix : str, optional
5757
Text to be added to the end of all output table names.
58-
match_type : {'all', 'longest', 'best'}, optional
59-
Type of matches to return. Defaults to 'all'.
58+
match_type : str, optional
59+
Choose from ``{'all', 'longest', 'best'}``.
60+
Type of matches to return. Defaults to 'all'.
6061
enable_facts : bool, optional
6162
Whether to enable facts in the results. Defaults to False.
6263
language : str, optional

src/sasctl/_services/files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ def create_file(cls, file, folder=None, filename=None, expiration=None):
4040
4141
Parameters
4242
----------
43-
file : str or file_like
43+
file : str or io.BytesIO
4444
Path to the file to upload or a file-like object.
4545
folder : str or dict, optional
4646
Name or folder information as returned by :meth:`.get_folder`.
4747
filename : str, optional
4848
Name to assign to the uploaded file. Defaults to the filename if `file` is a path, otherwise required.
49-
expiration : datetime, optional
49+
expiration : datetime.datetime, optional
5050
A timestamp that indicates when to expire the file. Defaults to no expiration.
5151
5252
Returns

src/sasctl/_services/microanalytic_score.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def execute_module_step(cls, module, step, return_dict=True, **kwargs):
107107
108108
Returns
109109
-------
110-
any
110+
Any
111111
Results of the step execution. Returned as a dictionary if
112112
`return_dict` is True, otherwise returned as a tuple if more
113113
than one value is returned, otherwise the single value.
@@ -180,8 +180,10 @@ def create_module(
180180
name : str
181181
description : str
182182
source : str
183-
language : {'python','ds2'}
184-
scope : {'public','private'}
183+
language : str
184+
Choose from ``{'python','ds2'}``
185+
scope : str
186+
Choose from ``{'public','private'}``
185187
186188
Returns
187189
-------

src/sasctl/_services/model_management.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ def create_custom_kpi(
448448
model : str or dict
449449
The name or id of the model, or a dictionary representation of the model.
450450
project : str or dict
451-
The name or id of the project, or a dictionary representation of
452-
the project.
451+
The name or id of the project, or a dictionary representation of
452+
the project.
453453
timeLabel : str or list
454454
Label associated with the dataset used within the performance definition.
455455
kpiName : str or list

src/sasctl/_services/model_publish.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def create_destination(
230230
----------
231231
name : str
232232
Name of the publishing destination.
233-
type_ : {'cas', 'mas', 'hadoop', 'teradata'}
233+
type_ : str
234+
Choose from ``{'cas', 'mas', 'hadoop', 'teradata'}``
234235
Type of publishing definition being created
235236
cas_server : str, optional
236237
Name of the CAS server. Defaults to 'cas-shared-default'.

src/sasctl/_services/model_repository.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def get_astore(cls, model):
6565
6666
Returns
6767
----------
68-
binary?
68+
BinaryIO
6969
7070
"""
7171
# TODO: Download binary object?
@@ -296,10 +296,10 @@ def create_model(
296296
properties : dict, optional
297297
Custom model properties provided as name: value pairs.
298298
Allowed types are int, float, string, datetime.date, and datetime.datetime
299-
input_variables : array_like, optional
299+
input_variables : Iterable, optional
300300
Model input variables. By default, these are the same as the model
301301
project.
302-
output_variables : array_like, optional
302+
output_variables : Iterable, optional
303303
Model output variables. By default, these are the same as the model
304304
project.
305305
project_version : str

src/sasctl/_services/saslogon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def create_client(
4646
The ID to be assigned to the client.
4747
client_secret : str
4848
The client secret used for authentication.
49-
scopes : list of string, optional
49+
scopes : list of str, optional
5050
Specifies the levels of access that the client will be able to
5151
obtain on behalf of users when not using client credential
5252
authentication. If `allow_password` or `allow_auth_code` are
@@ -160,7 +160,7 @@ def list_clients(cls, start_index=None, count=None, descending=False):
160160
----------
161161
start_index : int, optional
162162
Index of first client to return. Defaults to 1.
163-
count : int, optiona;
163+
count : int, optional
164164
Number of clients to retrieve. Defaults to 100.
165165
descending : bool, optional
166166
Whether to clients should be returned in descending order.

src/sasctl/_services/sentiment_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def analyze_sentiment(
3737
3838
Parameters
3939
----------
40-
documents : str or dict or Iterable:
40+
documents : str or dict or Iterable
4141
Documents to analyze. May be either the URI to a CAS table where the
4242
documents are currently stored, or an iterable of strings containing
4343
the documents' text.

src/sasctl/_services/text_categorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def categorize(
3131
3232
Parameters
3333
----------
34-
documents : str or dict or list_like:
34+
documents : str or dict or Iterable
3535
Documents to parse. May be either the URI to a CAS table where the
3636
documents are currently stored, or an iterable of strings
3737
containing the documents' text.

src/sasctl/_services/text_parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def parse_documents(
5656
5757
Parameters
5858
----------
59-
documents : str or dict or list_like:
59+
documents : str or dict or Iterable
6060
Documents to parse. May be either the URI to a CAS table where the
6161
documents are currently stored, or an iterable of strings containing
6262
the documents' text.

src/sasctl/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ class Session(requests.Session):
249249
authinfo : str, optional
250250
Path to a .authinfo or .netrc file from which credentials should be
251251
pulled.
252-
protocol : {'http', 'https'}
252+
protocol : str
253+
Choose from ``{'http', 'https'}``.
253254
Whether to use HTTP or HTTPS connections. Defaults to `https`.
254255
port : int, optional
255256
Port number for the connection if a non-standard port is used.

src/sasctl/pzmm/import_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def import_model(
237237
The `DataFrame` object contains the training data, and includes only the
238238
predictor columns. The write_score_code function currently supports int(64),
239239
float(64), and string data types for scoring. The default value is None.
240-
predict_method : [function -> list, list], optional
240+
predict_method : Callable or list, optional
241241
The Python function used for model predictions and the expected output
242242
types. The expected output types can be passed as example values or as the
243243
value types. For example, if the model is a Scikit-Learn

src/sasctl/pzmm/mlflow_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def read_mlflow_model_file(cls, m_path=Path.cwd()):
1818
Parameters
1919
----------
2020
m_path : str or pathlib.Path, optional
21-
Directory path of the MLFlow model files. Default is the current working
22-
directory.
21+
Directory path of the MLFlow model files. Default is the current working
22+
directory.
2323
2424
Returns
2525
-------

src/sasctl/pzmm/write_json_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import ast
66
import importlib
77
import json
8-
import math
8+
# import math #not used
99
import pickle
1010
import pickletools
1111
import sys
@@ -1080,7 +1080,7 @@ def bias_dataframes_to_json(
10801080
A list of variable names containing the predicted probability values in the score table. The first element
10811081
should represent the predicted probability of the target class. Required for classification problems. Default
10821082
is None.
1083-
levels: list of str.
1083+
levels: list of str
10841084
Required for classification problems, otherwise not used
10851085
List of classes of a nominal target in the order they were passed in `prob_values`. Levels must be passed as a
10861086
string. Default is None.

src/sasctl/pzmm/write_score_code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def write_score_code(
9191
predictor columns. The write_score_code function currently supports int(64),
9292
float(64), and string data types for scoring. Providing a list of dict
9393
objects signals that the model files are being created from an MLFlow model.
94-
predict_method : [function -> list, list]
94+
predict_method : Callable or list of Any
9595
The Python function used for model predictions and the expected output
9696
types. The expected output types can be passed as example values or as the
9797
value types. For example, if the model is a Scikit-Learn
@@ -317,7 +317,7 @@ def upload_and_copy_score_resources(
317317
----------
318318
model : str, dict, or RestObj
319319
The name or id of the model, or a dictionary representation of the model.
320-
files : list of file objects
320+
files : list of Any
321321
The list of score resource files to upload.
322322
323323
Returns
@@ -1102,7 +1102,7 @@ def _predictions_to_metrics(
11021102
A list of target values for the target variable. The default value is None.
11031103
predict_threshold : float, optional
11041104
The prediction threshold for normalized probability score_metrics. Values
1105-
are expected to be between 0 and 1. The default value is None.
1105+
are expected to be between 0 and 1. The default value is None.
11061106
h2o_model : bool, optional
11071107
Flag to indicate that the model is an H2O.ai model. The default value is
11081108
False.

src/sasctl/pzmm/zip_model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) 2020, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3-
import io
3+
from io import BytesIO
44
import zipfile
55
from pathlib import Path
66
from typing import Optional, Union
@@ -15,7 +15,7 @@ def _filter_files(file_dir: Union[str, Path], is_viya4: Optional[bool] = False)
1515
Parameters
1616
----------
1717
file_dir : str or Path
18-
Location of *.json, *.pickle, *.mojo, and *Score.py files.
18+
Location of \*.json, \*.pickle, \*.mojo, and \*Score.py files.
1919
is_viya4 : bool, optional
2020
Boolean to indicate difference in logic between SAS Viya 3.5 and SAS Viya 4. For
2121
Viya 3.5 models, ignore score code that is already in place in the file
@@ -47,7 +47,7 @@ def zip_files(
4747
model_files: Union[dict, str, Path],
4848
model_prefix: str,
4949
is_viya4: Optional[bool] = False,
50-
) -> io.BytesIO:
50+
) -> BytesIO:
5151
"""
5252
Combines all JSON files with the model pickle file and associated score code
5353
file into a single archive ZIP file.
@@ -70,13 +70,13 @@ def zip_files(
7070
directory provided. Default value is False.
7171
"""
7272
if isinstance(model_files, dict):
73-
zip_buffer = io.BytesIO()
73+
zip_buffer = BytesIO()
7474
with zipfile.ZipFile(
7575
zip_buffer, "a", zipfile.ZIP_DEFLATED, False
7676
) as zip_file:
7777
for file_name, data in model_files.items():
7878
zip_file.writestr(file_name, str(data))
79-
return io.BytesIO(zip_buffer.getvalue())
79+
return BytesIO(zip_buffer.getvalue())
8080
else:
8181
file_names = _filter_files(model_files, is_viya4)
8282
with zipfile.ZipFile(
@@ -88,4 +88,4 @@ def zip_files(
8888
with open(
8989
str(Path(model_files) / (model_prefix + ".zip")), "rb"
9090
) as zip_file:
91-
return io.BytesIO(zip_file.read())
91+
return BytesIO(zip_file.read())

src/sasctl/tasks.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,15 @@ def register_model(
271271
repository : str or dict, optional
272272
The name or id of the repository, or a dictionary representation of
273273
the repository. If omitted, the default repository will be used.
274-
input : pandas.DataFrame, type, list of type, or dict of str: type, optional
274+
input : pandas.DataFrame, type, list of type, or dict of str, optional
275275
The expected type for each input value of the target function.
276276
Can be omitted if target function includes type hints. If a DataFrame
277277
is provided, the columns will be inspected to determine type
278278
information. If a single type is provided, all columns will be assumed
279279
to be that type, otherwise a list of column types or a dictionary of
280280
column_name: type may be provided.
281-
version : {'new', 'latest', int}, optional
281+
version : str or int, optional
282+
If str choose from ``{'new', 'latest'}``.
282283
Version number of the project in which the model should be created.
283284
Defaults to 'new'.
284285
files : list
@@ -713,7 +714,7 @@ def update_model_performance(data, model, label, refresh=True):
713714
714715
Parameters
715716
----------
716-
data : Dataframe
717+
data : pandas.DataFrame
717718
model : str or dict
718719
The name or id of the model, or a dictionary representation of
719720
the model.
@@ -726,12 +727,12 @@ def update_model_performance(data, model, label, refresh=True):
726727
727728
Returns
728729
-------
729-
CASTable
730+
swat.cas.table.CASTable
730731
The CAS table containing the performance data.
731732
732733
See Also
733734
--------
734-
:meth:`model_management.create_performance_definition <.ModelManagement.create_performance_definition>`
735+
:meth:`model_management.create_performance_definition <.ModelManagement.create_performance_definition>`
735736
736737
.. versionadded:: v1.3
737738
@@ -930,7 +931,7 @@ def get_project_kpis(
930931
Column value to be filtered, by default None
931932
Returns
932933
-------
933-
kpiTableDf : DataFrame
934+
kpiTableDf : pandas.DataFrame
934935
A pandas DataFrame representing the MM_STD_KPI table. Note that SAS
935936
missing values are replaced with pandas valid missing values.
936937
"""

0 commit comments

Comments
 (0)