|
1 | 1 | # User Guide
|
2 | 2 |
|
3 |
| -## Pre-reqs |
| 3 | +`groundlight` is a python SDK for working with the Groundlight API. You can send image queries and receive predictions powered by a mixture of machine learning models and human labelers in-the-loop. |
| 4 | + |
| 5 | +*Note: The SDK is currently in "alpha" phase.* |
4 | 6 |
|
5 |
| -For all the examples, there are 3 pre-reqs: |
| 7 | +## Pre-reqs |
6 | 8 |
|
7 |
| -1. [Make sure you have internal pypi credentials set up](https://github.com/positronix-ai/tools/blob/main/internal-pip-login.sh), and then install with `pip` or `poetry`. |
| 9 | +1. Install the `groundlight` sdk. |
8 | 10 |
|
9 | 11 | ```Bash
|
10 |
| - # pip |
11 | 12 | $ pip install groundlight
|
12 |
| - |
13 |
| - # poetry |
14 |
| - $ poetry add groundlight |
15 | 13 | ```
|
16 | 14 |
|
17 |
| -1. To access the API, you need an API token. You can create one at [app.groundlight.ai](https://app.positronix.ai/reef/my-account/api-tokens). Then, add it as an environment variable called `GROUNDLIGHT_API_TOKEN`: |
| 15 | +1. To access the API, you need an API token. You can create one on the [groundlight website](https://app.positronix.ai/reef/my-account/api-tokens). |
18 | 16 |
|
19 |
| - ```Bash |
20 |
| - $ export GROUNDLIGHT_API_TOKEN=tok_abc123 |
21 |
| - ``` |
22 |
| - |
23 |
| -1. Create the `Groundlight` API client. We usually use `gl` as a shorthand name, but you are free to name it what you like! |
| 17 | +1. Use the `Groundlight` client! |
24 | 18 |
|
25 | 19 | ```Python
|
26 | 20 | from groundlight import Groundlight
|
27 |
| - gl = Groundlight() |
| 21 | + gl = Groundlight(api_token="<YOUR_API_TOKEN>") |
28 | 22 | ```
|
| 23 | + |
| 24 | + The API token should be stored securely - do not commit it to version control! Alternatively, you can use the token by setting the `GROUNDLIGHT_API_TOKEN` environment variable. |
| 25 | + |
29 | 26 | ## Basics
|
30 | 27 |
|
31 | 28 | #### Create a new detector
|
@@ -76,24 +73,6 @@ image_queries = gl.list_image_queries(page=3, page_size=25)
|
76 | 73 |
|
77 | 74 | ## Advanced
|
78 | 75 |
|
79 |
| -#### Use a different API endpoint |
80 |
| - |
81 |
| -```Python |
82 |
| -from groundlight import Groundlight |
83 |
| - |
84 |
| -# Integ |
85 |
| -integ_gl = Groundlight(endpoint="https://device.integ.positronix.ai/device-api") |
86 |
| - |
87 |
| -# Local |
88 |
| -local_gl = Groundlight(endpoint="http://localhost:8000/device-api") |
89 |
| -``` |
90 |
| - |
91 |
| -#### Do more with the object models |
92 |
| - |
93 |
| -You can see the different model types [here](generated/model.py). (TODO: Use something like [autodoc_pydantic](https://github.com/mansenfranzen/autodoc_pydantic) to create docs). |
94 |
| - |
95 |
| -All of the `Groundlight` methods return [pydantic](https://pydantic-docs.helpmanual.io/) models - `Detector`, `ImageQuery`, `PaginatedDetectorList`, etc. This provides several benefits: you can access model fields with dot notation, get auto-complete in your IDE, have `model.dict()`, `model.json()`, `model.pickle()` serializers, etc. See more on the [pydantic docs](https://pydantic-docs.helpmanual.io/usage/models/). |
96 |
| - |
97 | 76 | ### Handling HTTP errors
|
98 | 77 |
|
99 | 78 | If there is an HTTP error during an API call, it will raise an `ApiException`. You can access different metadata from that exception:
|
|
0 commit comments