Name | highlighter-sdk JSON |
Version |
0.5.2.0
JSON |
| download |
home_page | None |
Summary | Package to interact with the Highlighter Perception System |
upload_time | 2024-04-10 01:31:35 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <4.0,>=3.7 |
license | None |
keywords |
enterprise
perception
system
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<div align="center">
<img width="640" src="https://highlighter-public.s3.ap-southeast-2.amazonaws.com/web/assets/Highlighter_Logo_Primary_Horizontal_RGB.png" alt="Highlighter logo">
</div>
<br />
<a href=“”></a>
<div align="center">
<a href="https://highlighter-docs.netlify.app/">📘 Documentation</a> |
<a href="#installation">🛠️ Installation</a> |
<a href="mailto:support@highlighter.ai"> 🤔 Reporting Issues</a>
</div>
<h1>Highlighter SDK</h1>
The Highlighter SDK Python library provides convenient access to the [Highlighter](https://highlighter.ai) API from applications written in Python. There is also a CLI to access the Highlighter API in your shell.
The library also provides other features. For example:
* Easy configuration for fast setup and use across multiple Highlighter accounts.
* Functions to help get datasets in and out of Highlighter
* Helpers for pagination.
# Installation
```console
pip install highlighter-sdk
```
# API Tokens, Environment Variables and Profiles
If you have just a single set of Highlighter credentials you can simply set
the appropriate environment variables.
```
export HL_WEB_GRAPHQL_ENDPOINT="https://<client-account>.highlighter.ai/graphql"
export HL_WEB_GRAPHQL_API_TOKEN="###"
# Only required if you have datasets stored outside Highlighter's managed
# aws s3 storage
export AWS_ACCESS_KEY_ID=###
export AWS_SECRET_ACCESS_KEY=###
export AWS_DEFAULT_REGION=###
```
If you have several Highlighter credentials we suggest you use the
**profiles** option. You can create a `~/.highlighter-profiles.yaml` via the
cli.
```console
hl config create --name my-profile --api-token ### --endpoint https://...
```
Other commands for managing your profiles can be seen with the `--help` flag,
If you're a *Maverick Renegade* you can manage the `~/.highlighter-profiles.yaml`
manually. Below is an example,
```yaml
# Example ~/.highlighter-profiles.yaml
my_profile:
endpoint_url: https://<client-account>.highlighter.ai/graphql
api_token: ###
# Only required if you have datasets stored outside Highlighter's managed
# aws s3 storage
cloud:
- type: aws-s3
aws_access_key_id: ###
aws_secret_access_key: ###
aws_default_region: ###
```
To use as a profile in the cli simply use,
```console
hl --profile <profile-name> <command>
```
In a script you can use,
```python
# in a script
from highlighter import HLClient
client = HLClient.from_profile("profile-name")
```
Additionally `HLClient` can be initialized using environment variables or
by passing credentials direcly
```python
from highlighter import HLClient
client = HLClient.from_env()
# or
api_token = "###"
endpoint_url = "https://...highligher.ai/graphql
client = HLCient.from_credential(api_token, endpoint_url)
```
Finally, if you are in the position where you want to write a specified profile's
credentials to an evnironment file such as `.env` or `.envrc` you can use
the `write` command. This will create or append to the specified file.
```console
hl --profile my-profile write .envrc
```
## Python API
Once you have a `HLClient` object you can use it perform queries or mutations. Here is a simple example.
```python
from highlighter import HLClient
from pydantic import BaseModel
client = HLClient.from_env()
# You don't always need to define your own BaseModels
# many common BaseModels are defined in highlighter.base_models
# this is simply for completeness
class ObjectClassType(BaseModel):
id: int
name: str
id = 1234 # add an object class id from you account
result = client.ObjectClass(
return_type=ObjectClassType,
id=id,
)
print(result)
```
Some queries may return arbitrarily many results. These queries are
paginated and are called `Connections` and the queries are named accordingly.
We have provided a `paginate` function to help with these `Connections`
```python
from highlighter import HLClient, paginate
from pydantic import BaseModel
client = HLClient.from_env()
uuids = [
"abc123-abc123-abc123-abc123",
"xyz456-xyz456-xyz456-xyz456",
]
# The following BaseModels are all defined in
# highlighter.base_models. They are simply here
# for completeness
class PageInfo(BaseModel):
hasNextPage: bool
endCursor: Optional[str]
class ObjectClass(BaseModel):
id: str
uuid: str
name: str
class ObjectClassTypeConnection(BaseModel):
pageInfo: PageInfo
nodes: List[ObjectClass]
generator = paginate(
client..objectClassConnection,
ObjectClassTypeConnection,
uuid=uuids,
)
for object_class in generator:
print(object_class)
```
## Datasets
Highlighter SDK provides a dataset representation that can populated
from several sources `{HighlighterWeb.Assessments | Local files {.hdf, records.json, coco.json} | S3Bucket}`.
Once populated the `Highlighter.Datasets` object contains 2 `Pandas.DataFrames`
(`data_files_df` and `annotations_df`) that you can manipulate as required. When you're
ready you can write to disk or upload to Highligher using one of the `Writer` classes
to dump your data to disk in a format that can be consumed by your downstream code.
If you need you can also roll-your-own `Writer` by implementing the `highlighter.datasets.interfaces.IWriter` interface.
## Documentation
See https://highlighter-docs.netlify.app/
Raw data
{
"_id": null,
"home_page": null,
"name": "highlighter-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.7",
"maintainer_email": null,
"keywords": "enterprise perception system",
"author": null,
"author_email": "Joshua Patterson <joshua.patterson@silverpond.com.au>, Jono Chang <jonathan.chang@silverpond.com.au>, Simon Hudson <simon.hudson@silverpond.com.au>",
"download_url": "https://files.pythonhosted.org/packages/0a/4e/ff2a2d6d4d933654373118e35fe43dc837b00efa79560288ff783b6ce926/highlighter_sdk-0.5.2.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <img width=\"640\" src=\"https://highlighter-public.s3.ap-southeast-2.amazonaws.com/web/assets/Highlighter_Logo_Primary_Horizontal_RGB.png\" alt=\"Highlighter logo\">\n</div>\n\n<br />\n\n<a href=\u201c\u201d></a>\n<div align=\"center\">\n<a href=\"https://highlighter-docs.netlify.app/\">\ud83d\udcd8 Documentation</a> |\n<a href=\"#installation\">\ud83d\udee0\ufe0f Installation</a> |\n<a href=\"mailto:support@highlighter.ai\"> \ud83e\udd14 Reporting Issues</a> \n</div>\n\n<h1>Highlighter SDK</h1>\n\n\nThe Highlighter SDK Python library provides convenient access to the [Highlighter](https://highlighter.ai) API from applications written in Python. There is also a CLI to access the Highlighter API in your shell.\n\nThe library also provides other features. For example:\n\n* Easy configuration for fast setup and use across multiple Highlighter accounts.\n* Functions to help get datasets in and out of Highlighter\n* Helpers for pagination.\n\n\n# Installation\n\n```console\npip install highlighter-sdk\n```\n\n\n# API Tokens, Environment Variables and Profiles\n\nIf you have just a single set of Highlighter credentials you can simply set\nthe appropriate environment variables.\n\n```\nexport HL_WEB_GRAPHQL_ENDPOINT=\"https://<client-account>.highlighter.ai/graphql\"\nexport HL_WEB_GRAPHQL_API_TOKEN=\"###\"\n\n# Only required if you have datasets stored outside Highlighter's managed\n# aws s3 storage\nexport AWS_ACCESS_KEY_ID=###\nexport AWS_SECRET_ACCESS_KEY=###\nexport AWS_DEFAULT_REGION=###\n```\n\nIf you have several Highlighter credentials we suggest you use the\n**profiles** option. You can create a `~/.highlighter-profiles.yaml` via the\ncli.\n\n```console\nhl config create --name my-profile --api-token ### --endpoint https://...\n```\n\nOther commands for managing your profiles can be seen with the `--help` flag,\n\nIf you're a *Maverick Renegade* you can manage the `~/.highlighter-profiles.yaml`\nmanually. Below is an example,\n\n```yaml\n# Example ~/.highlighter-profiles.yaml\n\nmy_profile:\n endpoint_url: https://<client-account>.highlighter.ai/graphql\n api_token: ###\n\n # Only required if you have datasets stored outside Highlighter's managed\n # aws s3 storage\n cloud:\n - type: aws-s3\n aws_access_key_id: ###\n aws_secret_access_key: ###\n aws_default_region: ###\n```\n\nTo use as a profile in the cli simply use,\n\n```console\nhl --profile <profile-name> <command>\n```\n\nIn a script you can use,\n\n```python\n# in a script\nfrom highlighter import HLClient\n\nclient = HLClient.from_profile(\"profile-name\")\n```\n\nAdditionally `HLClient` can be initialized using environment variables or\nby passing credentials direcly\n\n```python\nfrom highlighter import HLClient\n\nclient = HLClient.from_env()\n\n# or\n\napi_token = \"###\"\nendpoint_url = \"https://...highligher.ai/graphql\nclient = HLCient.from_credential(api_token, endpoint_url)\n```\n\nFinally, if you are in the position where you want to write a specified profile's\ncredentials to an evnironment file such as `.env` or `.envrc` you can use\nthe `write` command. This will create or append to the specified file.\n\n```console\nhl --profile my-profile write .envrc\n```\n\n## Python API\n\nOnce you have a `HLClient` object you can use it perform queries or mutations. Here is a simple example.\n\n```python\nfrom highlighter import HLClient\nfrom pydantic import BaseModel\n\nclient = HLClient.from_env()\n\n# You don't always need to define your own BaseModels\n# many common BaseModels are defined in highlighter.base_models\n# this is simply for completeness\nclass ObjectClassType(BaseModel):\n id: int\n name: str\n\nid = 1234 # add an object class id from you account\n\nresult = client.ObjectClass(\n return_type=ObjectClassType,\n id=id,\n )\n\nprint(result)\n```\n\nSome queries may return arbitrarily many results. These queries are\npaginated and are called `Connections` and the queries are named accordingly.\nWe have provided a `paginate` function to help with these `Connections`\n\n```python\nfrom highlighter import HLClient, paginate\nfrom pydantic import BaseModel\n\nclient = HLClient.from_env()\nuuids = [\n \"abc123-abc123-abc123-abc123\",\n \"xyz456-xyz456-xyz456-xyz456\",\n]\n\n# The following BaseModels are all defined in\n# highlighter.base_models. They are simply here\n# for completeness\nclass PageInfo(BaseModel):\n hasNextPage: bool\n endCursor: Optional[str]\n\nclass ObjectClass(BaseModel):\n id: str\n uuid: str\n name: str\n\nclass ObjectClassTypeConnection(BaseModel):\n pageInfo: PageInfo\n nodes: List[ObjectClass]\n\ngenerator = paginate(\n client..objectClassConnection,\n ObjectClassTypeConnection,\n uuid=uuids,\n )\n\nfor object_class in generator:\n print(object_class)\n\n```\n\n## Datasets\n\nHighlighter SDK provides a dataset representation that can populated\nfrom several sources `{HighlighterWeb.Assessments | Local files {.hdf, records.json, coco.json} | S3Bucket}`.\nOnce populated the `Highlighter.Datasets` object contains 2 `Pandas.DataFrames`\n(`data_files_df` and `annotations_df`) that you can manipulate as required. When you're\nready you can write to disk or upload to Highligher using one of the `Writer` classes\nto dump your data to disk in a format that can be consumed by your downstream code.\nIf you need you can also roll-your-own `Writer` by implementing the `highlighter.datasets.interfaces.IWriter` interface.\n\n\n## Documentation\n\nSee https://highlighter-docs.netlify.app/\n",
"bugtrack_url": null,
"license": null,
"summary": "Package to interact with the Highlighter Perception System",
"version": "0.5.2.0",
"project_urls": {
"Documentation": "https://highlighter-docs.netlify.app/"
},
"split_keywords": [
"enterprise",
"perception",
"system"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "644927bab6809d97c8a4b5edc5327443bd2f4303edc35d6ab1b760f84954ab2a",
"md5": "4239c26ba2db6d6888a74e79447b5277",
"sha256": "4789b323f4fe0f02e1ca69cb5c93990df5688b3c4c053f00f564897311ca89db"
},
"downloads": -1,
"filename": "highlighter_sdk-0.5.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4239c26ba2db6d6888a74e79447b5277",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.7",
"size": 98336,
"upload_time": "2024-04-10T01:31:33",
"upload_time_iso_8601": "2024-04-10T01:31:33.117137Z",
"url": "https://files.pythonhosted.org/packages/64/49/27bab6809d97c8a4b5edc5327443bd2f4303edc35d6ab1b760f84954ab2a/highlighter_sdk-0.5.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0a4eff2a2d6d4d933654373118e35fe43dc837b00efa79560288ff783b6ce926",
"md5": "d2f6f8ddf5d9ba912d911e33dfb8dca2",
"sha256": "e8edccd7c6597ffa3aaa36795c6bc689a0a08464789cfb8eb2eef08f3d221e9f"
},
"downloads": -1,
"filename": "highlighter_sdk-0.5.2.0.tar.gz",
"has_sig": false,
"md5_digest": "d2f6f8ddf5d9ba912d911e33dfb8dca2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.7",
"size": 75570,
"upload_time": "2024-04-10T01:31:35",
"upload_time_iso_8601": "2024-04-10T01:31:35.066514Z",
"url": "https://files.pythonhosted.org/packages/0a/4e/ff2a2d6d4d933654373118e35fe43dc837b00efa79560288ff783b6ce926/highlighter_sdk-0.5.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-10 01:31:35",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "highlighter-sdk"
}