Skip to content

Commit 5700298

Browse files
committed
migrated
1 parent 14ae203 commit 5700298

File tree

131 files changed

+47461
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+47461
-3
lines changed

CONTRIBUTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
## How to Contribute
2+
3+
We'd love to accept your patches and contributions to this project. There are
4+
just a few small guidelines you need to follow.
5+
6+
7+
### Issues
8+
If you encounter a defect while using this software, please open up an
9+
issue to track the problem. See [SUPPORT.md](SUPPORT.md) for more information.
10+
11+
12+
### Submiting a Contribution
13+
All contributions are managed through the standard GitHub pull request process.
14+
Consult [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
15+
information on using pull requests.
16+
17+
All pull requests must include appropriate test cases to verify the changes.
18+
See the [Testing](#Testing) section below for more information on how test cases are configured.
19+
20+
Contributions to this project must be accompanied by a signed
21+
[Contributor Agreement](ContributorAgreement.txt).
22+
You (or your employer) retain the copyright to your contribution,
23+
this simply gives us permission to use and redistribute your contributions as
24+
part of the project.
25+
26+
27+
### Testing
28+
Tests are written using the [py.test](https://docs.pytest.org)
29+
framework, which also supports the standard unittest package. To enable
30+
integration testing without requiring a running SAS Viya environment, the
31+
[Betamax](https://pypi.org/project/betamax/) package is used to record and
32+
replay network interactions.
33+
34+
In addition, [Tox](https://tox.readthedocs.io) is used to test
35+
compatibility with different Python version.
36+
37+
All packages required for development and testing are listed in
38+
[test_requirements.txt](test_requirements.txt) and can be easily installed with
39+
```
40+
pip install -r test_requirements.txt
41+
```
42+
43+
44+
Before a pull request will be accepted:
45+
- contributions must pass existing regression tests located in tests/
46+
- contributions must add unit tests to tests/unit to validate any code changes
47+
- if there's already a test file where your tests would make sense, put them in there
48+
- if it's something new or you feel it needs its own file, create a new file
49+
- contributions should add integration tests to tests/integration when appropriate
50+
- all integration tests that involve network calls should also include the appropriate Betamax cassettes in tests/cassettes
51+
52+
- SASCTL_SERVER_NAME - hostname of the SAS Viya server to be used for testing
53+
- SASCTL_AUTHINFO - path to .authinfo or a .netrc file containing authentication credentials
54+
- SASCTL_USER_NAME - the user name to use when authenticating to SAS Viya services
55+
- SASCTL_PASSWORD - the password to use when authenticating to the SAS Viya services
56+
- REQUESTS_CA_BUNDLE - path to CA certificate for the SAS Viya server's SSL certificate. This is required certificates served by SAS Viya environments
57+
are almost always signed by an internal CA and the Python requests module does not pull CA certificates from the host.
58+
59+
60+
A collection of py.test fixtures has been defined in [conftest.py](tests/conftest.py) and can be
61+
used to access common resources from test cases.

ContributorAgreement.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Contributor Agreement
2+
3+
Version 1.1
4+
5+
Contributions to this software are accepted only when they are
6+
properly accompanied by a Contributor Agreement. The Contributor
7+
Agreement for this software is the Developer's Certificate of Origin
8+
1.1 (DCO) as provided with and required for accepting contributions
9+
to the Linux kernel.
10+
11+
In each contribution proposed to be included in this software, the
12+
developer must include a "sign-off" that denotes consent to the
13+
terms of the Developer's Certificate of Origin. The sign-off is
14+
a line of text in the description that accompanies the change,
15+
certifying that you have the right to provide the contribution
16+
to be included. For changes provided in source code control (for
17+
example, via a Git pull request) the sign-off must be included in
18+
the commit message in source code control. For changes provided
19+
in email or issue tracking, the sign-off must be included in the
20+
email or the issue, and the sign-off will be incorporated into the
21+
permanent commit message if the contribution is accepted into the
22+
official source code.
23+
24+
If you can certify the below:
25+
26+
Developer's Certificate of Origin 1.1
27+
28+
By making a contribution to this project, I certify that:
29+
30+
(a) The contribution was created in whole or in part by me and I
31+
have the right to submit it under the open source license
32+
indicated in the file; or
33+
34+
(b) The contribution is based upon previous work that, to the best
35+
of my knowledge, is covered under an appropriate open source
36+
license and I have the right under that license to submit that
37+
work with modifications, whether created in whole or in part
38+
by me, under the same open source license (unless I am
39+
permitted to submit under a different license), as indicated
40+
in the file; or
41+
42+
(c) The contribution was provided directly to me by some other
43+
person who certified (a), (b) or (c) and I have not modified
44+
it.
45+
46+
(d) I understand and agree that this project and the contribution
47+
are public and that a record of the contribution (including all
48+
personal information I submit with it, including my sign-off) is
49+
maintained indefinitely and may be redistributed consistent with
50+
this project or the open source license(s) involved.
51+
52+
then you just add a line saying
53+
54+
Signed-off-by: Random J Developer <[email protected]>
55+
56+
using your real name (sorry, no pseudonyms or anonymous contributions.)

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
@@ -198,4 +199,4 @@
198199
distributed under the License is distributed on an "AS IS" BASIS,
199200
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200201
See the License for the specific language governing permissions and
201-
limitations under the License.
202+
limitations under the License.

README.md

Lines changed: 179 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,179 @@
1-
# python-sasctl
2-
The sasctl package enables easy communication between the SAS Viya platform and a Python runtime.
1+
# sasctl
2+
3+
## Overview
4+
5+
The sasctl package enables easy communication between the SAS Viya
6+
platform and a Python runtime. It can be used as a module or as a command line interface.
7+
```
8+
sasctl.folders.list_folders()
9+
```
10+
11+
```
12+
sasctl folders list
13+
```
14+
15+
16+
### Prerequisites
17+
18+
sasctl requires the following Python packages be installed.
19+
If not already present, these packages will be downloaded and installed automatically.
20+
- requests
21+
- six
22+
23+
The following additional packages are recommended for full functionality:
24+
- swat
25+
- kerberos / winkerberos
26+
27+
28+
All required and recommended packages are listed in `requirements.txt` and can be installed easily with
29+
```
30+
pip install -r requirements.txt
31+
```
32+
33+
### Installation
34+
35+
```
36+
pip install git+https://github.com/sassoftware/python-sasctl
37+
```
38+
39+
40+
## Getting Started
41+
42+
Read the full documentation here: [http://xeno.glpages.sas.com/python-sasctl](http://xeno.glpages.sas.com/python-sasctl)
43+
44+
Once the sasctl package has been installed and you have a SAS Viya server to connect to,
45+
the first step is to establish a session:
46+
```
47+
>>> from sasctl import Session
48+
49+
>>> with Session(host, username, password):
50+
... pass # do something
51+
```
52+
```
53+
sasctl --help
54+
```
55+
56+
57+
Once a session has been created, all commands target that environment.
58+
The easiest way to use sasctl is often to use a pre-defined task,
59+
which can handle all necessary communication with the SAS Viya server:
60+
```
61+
>>> from sasctl import Session, register_model
62+
>>> from sklearn import linear_model as lm
63+
64+
>>> with Session('example.com', authinfo=<authinfo file>):
65+
... model = lm.LogisticRegression()
66+
... register_model('Sklearn Model', model, 'My Project')
67+
```
68+
69+
70+
A slightly more low-level way to interact with the environment is to use
71+
the service methods directly:
72+
```
73+
>>> from pprint import pprint
74+
>>> from sasctl import Session, folders
75+
76+
>>> with Session(host, username, password):
77+
... folders = folders.list_folders()
78+
... pprint(folders)
79+
80+
{'links': [{'href': '/folders/folders',
81+
'method': 'GET',
82+
'rel': 'folders',
83+
'type': 'application/vnd.sas.collection',
84+
'uri': '/folders/folders'},
85+
{'href': '/folders/folders',
86+
'method': 'POST',
87+
'rel': 'createFolder',
88+
89+
... # truncated for clarity
90+
91+
'rel': 'createSubfolder',
92+
'type': 'application/vnd.sas.content.folder',
93+
'uri': '/folders/folders?parentFolderUri=/folders/folders/{parentId}'}],
94+
'version': 1}
95+
```
96+
97+
98+
The most basic way to interact with the server is simply to call REST
99+
functions directly, though in general, this is not recommended.
100+
```
101+
>>> from pprint import pprint
102+
>>> from sasctl import Session, get
103+
104+
>>> with Session(host, username, password):
105+
... folders = get('/folders')
106+
... pprint(folders)
107+
108+
{'links': [{'href': '/folders/folders',
109+
'method': 'GET',
110+
'rel': 'folders',
111+
'type': 'application/vnd.sas.collection',
112+
'uri': '/folders/folders'},
113+
{'href': '/folders/folders',
114+
'method': 'POST',
115+
'rel': 'createFolder',
116+
117+
... # truncated for clarity
118+
119+
'rel': 'createSubfolder',
120+
'type': 'application/vnd.sas.content.folder',
121+
'uri': '/folders/folders?parentFolderUri=/folders/folders/{parentId}'}],
122+
'version': 1}
123+
```
124+
125+
126+
127+
128+
### Examples
129+
130+
A few simple examples of common scenarios are listed below. For more
131+
complete examples see the [examples](examples) folder.
132+
133+
Show models currently in Model Manager:
134+
```
135+
>>> from sasctl import Session, model_repository
136+
137+
>>> with Session(host, username, password):
138+
... models = model_repository.list_models()
139+
```
140+
141+
Register a pure Python model in Model Manager:
142+
```
143+
>>> from sasctl import Session, register_model
144+
>>> from sklearn import linear_model as lm
145+
146+
>>> with Session(host, authinfo=<authinfo file>):
147+
... model = lm.LogisticRegression()
148+
... register_model('Sklearn Model', model, 'My Project')
149+
```
150+
151+
Register a CAS model in Model Manager:
152+
```
153+
>>> import swat
154+
>>> from sasctl import Session
155+
>>> from sasctl.tasks import register_model
156+
157+
>>> s = swat.CAS(host, authinfo=<authinfo file>)
158+
>>> astore = s.CASTable('some_astore')
159+
160+
>>> with Session(s):
161+
... register_model('SAS Model', astore, 'My Project')
162+
```
163+
164+
## Contributing
165+
166+
We welcome contributions!
167+
168+
Please read [CONTRIBUTING.md](CONTRIBUTING.md)
169+
for details on how to submit contributions to this project.
170+
171+
## License
172+
173+
See the [LICENSE](LICENSE) file for details.
174+
175+
## Additional Resources
176+
177+
* [SAS Viya REST Documentation](https://developer.sas.com/apis/rest/)
178+
* [SAS Developer Community](https://communities.sas.com/t5/Developers/bd-p/developers)
179+

SUPPORT.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Support
2+
3+
We use GitHub for tracking bugs and feature requests.
4+
Please submit a GitHub issue for support. Consult
5+
[GitHub Help](https://help.github.com/en/articles/about-issues) for more
6+
information on submitting issues.
7+
8+
If you encounter an issue and fix it yourself, or implement a new
9+
feature that you'd like to see included in the project, please
10+
see [CONTRIBUTING.md](CONTRIBUTING.md) for information on how to
11+
contribute.

doc/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = sasctl
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/api/sasctl.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
sasctl package
2+
==============
3+
4+
Module contents
5+
---------------
6+
7+
.. automodule:: sasctl
8+
:members:
9+
:undoc-members:
10+
:show-inheritance:
11+
12+
Submodules
13+
----------
14+
15+
sasctl.core module
16+
~~~~~~~~~~~~~~~~~~
17+
18+
.. automodule:: sasctl.core
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
23+
24+
sasctl.tasks module
25+
~~~~~~~~~~~~~~~~~~~
26+
27+
.. automodule:: sasctl.tasks
28+
:members:
29+
:undoc-members:
30+
:show-inheritance:
31+
32+
33+
34+
Subpackages
35+
-----------
36+
37+
.. toctree::
38+
39+
sasctl.services
40+
sasctl.utils

0 commit comments

Comments
 (0)