You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* First pass at fleshed out README
* Remove duplicate IPython notice in README
* Improve consistency of headers
* Fix examples match output shown
* Convert existing docstrings to rst style
* revise function docstrings in client
* Module docstrings, document queries
* More test docstrings
* Refactor formatting functions to own module
This change is necessary to reduce the length of client.py in preparation
for adding examples to docstrings. Otherwise it would become unmanageably
long after examples are added.
* Add examples for all get functions in client.py
* Run black on last commit
Copy file name to clipboardExpand all lines: clients/python/README.md
+140-8Lines changed: 140 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,21 @@
1
1
# Tracker Python API Client
2
2
3
-
The Tracker Python API Client will provide a Python wrapper for key features of Tracker.
3
+
The Tracker Python API Client provides a simple Python interface for the [Tracker GraphQL API](https://github.com/canada-ca/tracker/blob/master/api-js/README.md), with the aim of allowing users to easily integrate data from Tracker into existing workflows and platforms. It allows access to the JSON data served by the API without requiring specific knowledge of [GraphQL](https://graphql.org/) or the Tracker API. This is done by providing functions that execute canned queries against the API using [gql](https://github.com/graphql-python/gql). Responses are formatted to remove pagination related structures, and to ensure useful keys are always present.
4
4
5
-
It makes use of [gql](https://github.com/graphql-python/gql), a Python GraphQL client, to query the Tracker API.
6
5
7
-
#### Installing Dependencies
6
+
##Installation
8
7
9
-
Install [pipenv](https://pypi.org/project/pipenv/) if you don't already have it.
8
+
### For Users
9
+
10
+
The client will soon be available to install as a package via pip or pipenv. Until then, follow the instructions for developers below.
11
+
12
+
### For Developers
13
+
14
+
Install [pipenv](https://pypi.org/project/pipenv/) if you don't already have it. The following instructions assume you are using pipenv.
15
+
16
+
#### Installing Dependencies
17
+
18
+
Make sure you have pulled the most recent version from the repo, then run:
10
19
11
20
```shell
12
21
pipenv install --dev
@@ -18,7 +27,12 @@ If you run into issues, ensure pipenv has installed the most recent GQL version.
You must have a Tracker account that is a member of one or more organizations to make use of the Python client. You can manage your account in the [Tracker web interface](https://tracker.alpha.canada.ca/).
22
36
23
37
The client will attempt to draw credentials from its environment in order to obtain an authentication token. Pipenv makes this easy to set up by importing environment variables from a `.env` file present in this directory whenever `pipenv run` or `pipenv shell` are used. The `.env` file can be created like so:
24
38
@@ -29,7 +43,122 @@ TRACKER_PASS=YOURPASSWORDHERE
29
43
EOF
30
44
```
31
45
32
-
#### Testing
46
+
You should be mindful that setting these variables manually can result in credentials being stored in your shell command history.
47
+
48
+
### Basic Usage
49
+
50
+
You will generally start by creating a client with `create_client(auth_token=get_auth_token())` and storing the result. All functions that make queries expect such a client to be passed as the first argument.
51
+
52
+
### Examples
53
+
54
+
#### Get all domains in my organizations
55
+
56
+
Supposing I belong to two organizations with the acronyms "FOO" and "BAR":
> **NOTE**: Because of gql limitations, the client is not currently compatible with IPython or Jupyter.
158
+
159
+
## Development
160
+
161
+
### Testing
33
162
34
163
Pytest is used for testing. To run tests, run the following in the project root (the folder containing this README.md):
35
164
@@ -41,6 +170,9 @@ Alternatively, if you are already in a pipenv shell, just run `pytest`.
41
170
42
171
If tests are failing with ModuleNotFoundError, make sure tracker_client/ is on your PYTHONPATH. The .env file used to store your credentials is a good way to set this.
43
172
44
-
#### Note about IPython/Jupyter
173
+
When additions or significant changes are made, check test coverage with:
174
+
175
+
```shell
176
+
pipenv run pytest --cov=tracker_client
177
+
```
45
178
46
-
Because of a limitation in gql, the client is not currently compatible with IPython or Jupyter.
0 commit comments