Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ test-local: install ## Run integration tests against an API server running at h


test-integ: install ## Run integration tests against the integ API server (needs GROUNDLIGHT_API_TOKEN)
GROUNDLIGHT_TEST_API_ENDPOINT="https://device.integ.positronix.ai/device-api" poetry run pytest --cov=src test --log-cli-level INFO
GROUNDLIGHT_TEST_API_ENDPOINT="https://api.integ.groundlight.ai/device-api" poetry run pytest --cov=src test --log-cli-level INFO
43 changes: 29 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Groundlight Python SDK

This package holds an SDK for accessing the Groundlight public API.
This package holds an SDK for accessing the Groundlight public API.

### Installation

Install with `pip` or `poetry`.

```Bash
Expand All @@ -16,14 +14,14 @@ $ poetry add groundlight

### Basic Usage

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!
To access the API, you need an API token. You can create one on the [groundlight website](https://app.groundlight.ai/reef/my-account/api-tokens). Then, you're ready to use the SDK!

```Python
from groundlight import Groundlight

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

# Call an API method (e.g., retrieve a list of detectors)
Expand All @@ -36,26 +34,33 @@ detectors = gl.list_detectors()

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

For more details, see the [Groundlight](src/groundlight/client.py) class. This SDK closely follows the methods in our [API Docs](https://app.positronix.ai/reef/admin/api-docs).

For more details, see the [Groundlight](src/groundlight/client.py)
class. This SDK closely follows the methods in our [API
Docs](https://app.groundlight.ai/reef/admin/api-docs).

## Development

The auto-generated SDK code is in the `generated/` directory. To re-generate the client code, you'll need to install [openapi-generator](https://openapi-generator.tech/docs/installation#homebrew) (I recommend homebrew if you're on a mac). Then you can run it with:
The auto-generated SDK code is in the `generated/` directory. To
re-generate the client code, you'll need to install
[openapi-generator](https://openapi-generator.tech/docs/installation#homebrew)
(I recommend homebrew if you're on a mac). Then you can run it with:

```Bash
$ make generate
```

## Testing

Most tests need an API endpoint to run.

### Local API endpoint

1. Set up a local [janzu API endpoint](https://github.com/positronix-ai/zuuul/blob/main/deploy/README.md#development-using-local-microk8s) running (e.g., on an AWS GPU instance).
1. Set up a local [janzu API
endpoint](https://github.com/positronix-ai/zuuul/blob/main/deploy/README.md#development-using-local-microk8s)
running (e.g., on an AWS GPU instance).

1. Set up an ssh tunnel to your laptop. That way, you can access the endpoint at http://localhost:8000/device-api (and the web UI at http://localhost:8000/reef):
1. Set up an ssh tunnel to your laptop. That way, you can access the
endpoint at http://localhost:8000/device-api (and the web UI at
http://localhost:8000/reef):

```Bash
$ ssh instance-name -L 8000:localhost:80
Expand All @@ -68,7 +73,9 @@ Most tests need an API endpoint to run.
$ make test-local
```

(Note: in theory, it's possible to run the janzu API server on your laptop without microk8s - but some API methods don't work because of the dependence on GPUs)
(Note: in theory, it's possible to run the janzu API server on your
laptop without microk8s - but some API methods don't work because of
the dependence on GPUs)

### Integ API endpoint

Expand All @@ -81,7 +88,9 @@ Most tests need an API endpoint to run.

## Releases

To publish a new package version to our [internal pypi repository](https://github.com/positronix-ai/packaging/tree/main/aws), you create a release on github.
To publish a new package version to our [internal pypi
repository](https://github.com/positronix-ai/packaging/tree/main/aws),
you create a release on github.

```Bash
# Create a git tag locally. Use semver "vX.Y.Z" format.
Expand All @@ -91,7 +100,13 @@ $ git tag -a v0.1.2 -m "Short description"
$ git push origin --tags
```

Then, go to the [github repo](https://github.com/positronix-ai/groundlight-python-sdk/tags) -> choose your tag -> create a release from this tag -> type in some description -> release. A [github action](https://github.com/positronix-ai/groundlight-python-sdk/actions/workflows/publish.yaml) will trigger a release, and then `groundlight-X.Y.Z` will be available for consumers.
Then, go to the [github
repo](https://github.com/positronix-ai/groundlight-python-sdk/tags) ->
choose your tag -> create a release from this tag -> type in some
description -> release. A [github
action](https://github.com/positronix-ai/groundlight-python-sdk/actions/workflows/publish.yaml)
will trigger a release, and then `groundlight-X.Y.Z` will be available
for consumers.

## TODOs

Expand Down
5 changes: 3 additions & 2 deletions UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
$ pip install groundlight
```

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).
1. To access the API, you need an API token. You can create one on the
[groundlight website](https://app.groundlight.ai/reef/my-account/api-tokens).

1. Use the `Groundlight` client!

```Python
from groundlight import Groundlight
gl = Groundlight(api_token="<YOUR_API_TOKEN>")
Expand Down
9 changes: 4 additions & 5 deletions generated/docs/ImageQueriesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ All URIs are relative to *https://device.positronix.ai/device-api*

Method | HTTP request | Description
------------- | ------------- | -------------
[**get_image_query**](ImageQueriesApi.md#get_image_query) | **GET** /v1/image-queries/{id} |
[**list_image_queries**](ImageQueriesApi.md#list_image_queries) | **GET** /v1/image-queries |
[**submit_image_query**](ImageQueriesApi.md#submit_image_query) | **POST** /v1/image-queries |
[**get_image_query**](ImageQueriesApi.md#get_image_query) | **GET** /v1/image-queries/{id} |
[**list_image_queries**](ImageQueriesApi.md#list_image_queries) | **GET** /v1/image-queries |
[**submit_image_query**](ImageQueriesApi.md#submit_image_query) | **POST** /v1/image-queries |


# **get_image_query**
Expand Down Expand Up @@ -171,7 +171,7 @@ Name | Type | Description | Notes



Submit an image query against a detector. You must use `\"Content-Type: image/jpeg\"` for the image data. For example: ```Bash $ curl https://api.groundlight.ai/v1/image-queries?detector_id=det_abc123 \\ --header \"Content-Type: image/jpeg\" \\ --data-binary @path/to/filename.jpeg ```
Submit an image query against a detector. You must use `\"Content-Type: image/jpeg\"` for the image data. For example: ```Bash $ curl https://api.groundlight.ai/device-api/v1/image-queries?detector_id=det_abc123 \\ --header \"Content-Type: image/jpeg\" \\ --data-binary @path/to/filename.jpeg ```

### Example

Expand Down Expand Up @@ -252,4 +252,3 @@ Name | Type | Description | Notes
**201** | | - |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "groundlight"
version = "0.2.0"
license = "MIT"
readme = "UserGuide.md"
homepage = "https://app.positronix.ai"
homepage = "https://groundlight.ai"
description = "Call the Groundlight API from python"
authors = ["Groundlight AI <support@groundlight.ai>"]
packages = [
Expand Down
10 changes: 5 additions & 5 deletions spec/public-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ paths:
You must use `"Content-Type: image/jpeg"` for the image data. For example:

```Bash
$ curl https://api.groundlight.ai/v1/image-queries?detector_id=det_abc123 \
$ curl https://api.groundlight.ai/device-api/v1/image-queries?detector_id=det_abc123 \
--header "Content-Type: image/jpeg" \
--data-binary @path/to/filename.jpeg
```
Expand Down Expand Up @@ -371,11 +371,11 @@ components:
type: apiKey
in: header
servers:
- url: https://api.groundlight.ai/device-api
description: Prod
- url: https://api.integ.groundlight.ai/device-api
description: Integ
- url: https://device.positronix.ai/device-api
description: Device Prod
- url: https://device.integ.positronix.ai/device-api
description: Device Integ
- url: https://api.groundlight.ai
description: Prod
- url: https://api.integ.groundlight.ai
description: Integ
4 changes: 2 additions & 2 deletions src/groundlight/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from groundlight.images import buffer_from_jpeg_file

API_TOKEN_WEB_URL = "https://app.positronix.ai/reef/my-account/api-tokens"
API_TOKEN_WEB_URL = "https://app.groundlight.ai/reef/my-account/api-tokens"
API_TOKEN_VARIABLE_NAME = "GROUNDLIGHT_API_TOKEN"


Expand All @@ -30,7 +30,7 @@ class Groundlight:
```
"""

def __init__(self, endpoint: str = "https://device.positronix.ai/device-api", api_token: str = None):
def __init__(self, endpoint: str = "https://api.groundlight.ai/device-api", api_token: str = None):
"""
:param endpoint: optionally specify a different endpoint
:param api_token: use this API token for your API calls. If unset, fallback to the
Expand Down