Skip to content

Commit 0c97a2a

Browse files
Publish to public pypi (#3)
* Prepare for public pypi * Wording on UserGuide * Feedback
1 parent e84184c commit 0c97a2a

File tree

6 files changed

+45
-59
lines changed

6 files changed

+45
-59
lines changed

.github/workflows/publish.yaml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# When a release is created on github, publish the groundlight package to our internal pypi repository
1+
# When a release is created on github, publish the groundlight package to public pypi
22
# (Similar to https://github.com/positronix-ai/predictors/blob/main/.github/workflows/publish.yaml)
33
name: publish package
44
on:
@@ -8,7 +8,7 @@ jobs:
88
publish-python-package:
99
runs-on: ubuntu-latest
1010
env:
11-
INTERNAL_REPO_URL: https://positronix-723181461334.d.codeartifact.us-west-2.amazonaws.com/pypi/internal/
11+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_PUBLISH_TOKEN }}
1212
steps:
1313
- name: install python
1414
uses: actions/setup-python@v2
@@ -18,19 +18,9 @@ jobs:
1818
run: |
1919
pip install -U pip
2020
pip install poetry
21-
- name: configure AWS credentials
22-
uses: aws-actions/configure-aws-credentials@v1
23-
with:
24-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26-
aws-region: us-west-2
2721
- name: get code
2822
uses: actions/checkout@v2
2923
- name: build package
3024
run: poetry build
3125
- name: configure poetry and publish
32-
run: |
33-
export POETRY_HTTP_BASIC_INTERNAL_USERNAME=aws
34-
export POETRY_HTTP_BASIC_INTERNAL_PASSWORD=$(aws codeartifact get-authorization-token --domain positronix --query authorizationToken --output text)
35-
poetry config repositories.internal $INTERNAL_REPO_URL
36-
poetry publish -r internal
26+
run: poetry publish

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Groundlight AI
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This package holds an SDK for accessing the Groundlight public API.
44

55
### Installation
66

7-
[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`.
7+
Install with `pip` or `poetry`.
88

99
```Bash
1010
# pip
@@ -16,26 +16,22 @@ $ poetry add groundlight
1616

1717
### Basic Usage
1818

19-
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`:
20-
21-
```Bash
22-
$ export GROUNDLIGHT_API_TOKEN=tok_abc123
23-
```
24-
25-
Now you can use the python SDK!
19+
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). Then, you're ready to use the SDK!
2620

2721
```Python
2822
from groundlight import Groundlight
2923

3024
# Load the API client. This defaults to the prod endpoint,
3125
# but you can specify a different endpoint like so:
3226
# gl = Groundlight(endpoint="https://device.integ.positronix.ai/device-api")
33-
gl = Groundlight()
27+
gl = Groundlight(api_token="<YOUR_API_TOKEN>")
3428

3529
# Call an API method (e.g., retrieve a list of detectors)
3630
detectors = gl.list_detectors()
3731
```
3832

33+
(Alternatively, you can use the token by setting the `GROUNDLIGHT_API_TOKEN` environment variable.)
34+
3935
### What API methods are available?
4036

4137
Check out the [User Guide](UserGuide.md)!

UserGuide.md

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
# User Guide
22

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.*
46

5-
For all the examples, there are 3 pre-reqs:
7+
## Pre-reqs
68

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.
810

911
```Bash
10-
# pip
1112
$ pip install groundlight
12-
13-
# poetry
14-
$ poetry add groundlight
1513
```
1614

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).
1816

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!
2418

2519
```Python
2620
from groundlight import Groundlight
27-
gl = Groundlight()
21+
gl = Groundlight(api_token="<YOUR_API_TOKEN>")
2822
```
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+
2926
## Basics
3027

3128
#### Create a new detector
@@ -76,24 +73,6 @@ image_queries = gl.list_image_queries(page=3, page_size=25)
7673

7774
## Advanced
7875

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-
9776
### Handling HTTP errors
9877

9978
If there is an HTTP error during an API call, it will raise an `ApiException`. You can access different metadata from that exception:

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[tool.poetry]
22
name = "groundlight"
3-
version = "0.1.7"
3+
version = "0.2.0"
4+
license = "MIT"
5+
readme = "UserGuide.md"
6+
homepage = "https://app.positronix.ai"
47
description = "Call the Groundlight API from python"
58
authors = ["Groundlight AI <[email protected]>"]
69
packages = [

src/groundlight/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ class Groundlight:
3232

3333
def __init__(self, endpoint: str = "https://device.positronix.ai/device-api", api_token: str = None):
3434
"""
35-
:param endpoint: optionally specify a different endpoint. E.g.
36-
- Prod (default): https://device.positronix.ai/device-api
37-
- Integ: https://device.integ.positronix.ai/device-api
38-
- Localhost tunnel to a GPU instance: http://localhost:8000/device-api
35+
:param endpoint: optionally specify a different endpoint
3936
:param api_token: use this API token for your API calls. If unset, fallback to the
4037
environment variable "GROUNDLIGHT_API_TOKEN".
4138
"""

0 commit comments

Comments
 (0)