highlighter-sdk 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. highlighter_sdk-0.5.0/.gitignore +6 -0
  2. highlighter_sdk-0.5.0/LICENSE +201 -0
  3. highlighter_sdk-0.5.0/PKG-INFO +215 -0
  4. highlighter_sdk-0.5.0/README.md +177 -0
  5. highlighter_sdk-0.5.0/highlighter/__init__.py +18 -0
  6. highlighter_sdk-0.5.0/highlighter/_colors.py +83 -0
  7. highlighter_sdk-0.5.0/highlighter/assessments.py +52 -0
  8. highlighter_sdk-0.5.0/highlighter/aws_s3.py +326 -0
  9. highlighter_sdk-0.5.0/highlighter/base_models.py +472 -0
  10. highlighter_sdk-0.5.0/highlighter/capabilities.py +167 -0
  11. highlighter_sdk-0.5.0/highlighter/cli/__init__.py +0 -0
  12. highlighter_sdk-0.5.0/highlighter/cli/assessment.py +460 -0
  13. highlighter_sdk-0.5.0/highlighter/cli/common.py +47 -0
  14. highlighter_sdk-0.5.0/highlighter/cli/config.py +156 -0
  15. highlighter_sdk-0.5.0/highlighter/cli/data_files.py +264 -0
  16. highlighter_sdk-0.5.0/highlighter/cli/dataset.py +271 -0
  17. highlighter_sdk-0.5.0/highlighter/cli/experiment.py +62 -0
  18. highlighter_sdk-0.5.0/highlighter/cli/highlighter.py +128 -0
  19. highlighter_sdk-0.5.0/highlighter/cli/object_class.py +48 -0
  20. highlighter_sdk-0.5.0/highlighter/cli/step.py +68 -0
  21. highlighter_sdk-0.5.0/highlighter/cli/task.py +545 -0
  22. highlighter_sdk-0.5.0/highlighter/cli/training_run.py +302 -0
  23. highlighter_sdk-0.5.0/highlighter/const.py +26 -0
  24. highlighter_sdk-0.5.0/highlighter/cropping.py +254 -0
  25. highlighter_sdk-0.5.0/highlighter/data_files.py +97 -0
  26. highlighter_sdk-0.5.0/highlighter/datasets/__init__.py +69 -0
  27. highlighter_sdk-0.5.0/highlighter/datasets/base_models.py +275 -0
  28. highlighter_sdk-0.5.0/highlighter/datasets/dataset.py +1090 -0
  29. highlighter_sdk-0.5.0/highlighter/datasets/formats/__init__.py +27 -0
  30. highlighter_sdk-0.5.0/highlighter/datasets/formats/aws_s3/__init__.py +0 -0
  31. highlighter_sdk-0.5.0/highlighter/datasets/formats/aws_s3/writer.py +119 -0
  32. highlighter_sdk-0.5.0/highlighter/datasets/formats/coco/__init__.py +2 -0
  33. highlighter_sdk-0.5.0/highlighter/datasets/formats/coco/common.py +218 -0
  34. highlighter_sdk-0.5.0/highlighter/datasets/formats/coco/reader.py +130 -0
  35. highlighter_sdk-0.5.0/highlighter/datasets/formats/coco/writer.py +239 -0
  36. highlighter_sdk-0.5.0/highlighter/datasets/formats/highlighter/__init__.py +1 -0
  37. highlighter_sdk-0.5.0/highlighter/datasets/formats/highlighter/reader.py +128 -0
  38. highlighter_sdk-0.5.0/highlighter/datasets/formats/highlighter/writer.py +195 -0
  39. highlighter_sdk-0.5.0/highlighter/datasets/formats/torch_image_folder/__init__.py +0 -0
  40. highlighter_sdk-0.5.0/highlighter/datasets/formats/torch_image_folder/reader.py +86 -0
  41. highlighter_sdk-0.5.0/highlighter/datasets/formats/torch_image_folder/writer.py +231 -0
  42. highlighter_sdk-0.5.0/highlighter/datasets/interfaces.py +20 -0
  43. highlighter_sdk-0.5.0/highlighter/entity_avro_schema.py +156 -0
  44. highlighter_sdk-0.5.0/highlighter/gql_base.py +573 -0
  45. highlighter_sdk-0.5.0/highlighter/gql_client.py +413 -0
  46. highlighter_sdk-0.5.0/highlighter/io.py +420 -0
  47. highlighter_sdk-0.5.0/highlighter/itertools.py +16 -0
  48. highlighter_sdk-0.5.0/highlighter/labeled_uuid.py +89 -0
  49. highlighter_sdk-0.5.0/highlighter/logging.py +15 -0
  50. highlighter_sdk-0.5.0/highlighter/object_classes.py +74 -0
  51. highlighter_sdk-0.5.0/highlighter/pagination.py +67 -0
  52. highlighter_sdk-0.5.0/highlighter/presigned_url.py +44 -0
  53. highlighter_sdk-0.5.0/highlighter/splits/__init__.py +8 -0
  54. highlighter_sdk-0.5.0/highlighter/splits/random_split.py +36 -0
  55. highlighter_sdk-0.5.0/highlighter/tasks.py +30 -0
  56. highlighter_sdk-0.5.0/highlighter/training_config.py +332 -0
  57. highlighter_sdk-0.5.0/highlighter/training_runs.py +267 -0
  58. highlighter_sdk-0.5.0/highlighter/workflow.py +45 -0
  59. highlighter_sdk-0.5.0/pyproject.toml +139 -0
@@ -0,0 +1,6 @@
1
+ */__pycache__
2
+ *.pyc
3
+ *.swp
4
+ dist/*
5
+ hl/*
6
+ venv/*
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.3
2
+ Name: highlighter-sdk
3
+ Version: 0.5.0
4
+ Summary: Package to interact with the Highlighter Perception System
5
+ Project-URL: Documentation, https://highlighter-docs.netlify.app/
6
+ Author-email: Joshua Patterson <joshua.patterson@silverpond.com.au>, Jono Chang <jonathan.chang@silverpond.com.au>, Simon Hudson <simon.hudson@silverpond.com.au>
7
+ License-File: LICENSE
8
+ Keywords: enterprise perception system
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Operating System :: Unix
12
+ Classifier: Programming Language :: Python :: 3.7
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Requires-Python: <4.0,>=3.7
17
+ Requires-Dist: aiohttp~=3.7
18
+ Requires-Dist: boto3~=1.26.30
19
+ Requires-Dist: click!=8.0.0,<9,>=7
20
+ Requires-Dist: colorama~=0.4.4
21
+ Requires-Dist: fastavro~=1.8
22
+ Requires-Dist: gql~=3.4.0
23
+ Requires-Dist: jupyterlab~=3.2
24
+ Requires-Dist: opencv-python~=4.7
25
+ Requires-Dist: pandas~=1.0
26
+ Requires-Dist: pillow>=6.0
27
+ Requires-Dist: pooch~=1.5
28
+ Requires-Dist: pydantic<2.0,>=1.6
29
+ Requires-Dist: python-magic~=0.4.0
30
+ Requires-Dist: pyyaml>=5.0
31
+ Requires-Dist: requests-toolbelt
32
+ Requires-Dist: requests~=2.22
33
+ Requires-Dist: shapely>2.0.1
34
+ Requires-Dist: tables~=3.7
35
+ Requires-Dist: tqdm~=4.0
36
+ Requires-Dist: websockets~=10.0
37
+ Description-Content-Type: text/markdown
38
+
39
+ # Highlighter SDK
40
+
41
+ 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.
42
+
43
+ The library also provides other features. For example:
44
+
45
+ * Easy configuration for fast setup and use across multiple Highlighter accounts.
46
+ * Functions to help work with datasets from Highlighter
47
+ * Helpers for pagination.
48
+
49
+ **For developer docs see: [here](docs/dev.md)**
50
+
51
+ # API Tokens, Environment Variables and Profiles
52
+
53
+ If you have just a single set of Highlighter credentials you can simply set
54
+ the appropriate environment variables.
55
+
56
+ ```
57
+ export HL_WEB_GRAPHQL_ENDPOINT="https://<client-account>.highlighter.ai/graphql"
58
+ export HL_WEB_GRAPHQL_API_TOKEN="###"
59
+
60
+ # Only required if you have datasets stored outside Highlighter's managed
61
+ # aws s3 storage
62
+ export AWS_ACCESS_KEY_ID=###
63
+ export AWS_SECRET_ACCESS_KEY=###
64
+ export AWS_DEFAULT_REGION=###
65
+ ```
66
+
67
+ If you have several Highlighter credentials we suggest you use the
68
+ **profiles** option. You can create a `~/.highlighter-profiles.yaml` via the
69
+ cli.
70
+
71
+ ```console
72
+ hl config create --name my-profile --api-token ### --endpoint https://...
73
+ ```
74
+
75
+ Other commands for managing your profiles can be seen with the `--help` flag,
76
+
77
+ If you're a *Maverick Renegade* you can manage the `~/.highlighter-profiles.yaml`
78
+ manually. Below is an example,
79
+
80
+ ```yaml
81
+ # Example ~/.highlighter-profiles.yaml
82
+
83
+ my_profile:
84
+ endpoint_url: https://<client-account>.highlighter.ai/graphql
85
+ api_token: ###
86
+
87
+ # Only required if you have datasets stored outside Highlighter's managed
88
+ # aws s3 storage
89
+ cloud:
90
+ - type: aws-s3
91
+ aws_access_key_id: ###
92
+ aws_secret_access_key: ###
93
+ aws_default_region: ###
94
+ ```
95
+
96
+ To use as a profile in the cli simply use,
97
+
98
+ ```console
99
+ hl --profile <profile-name> <command>
100
+ ```
101
+
102
+ In a script you can use,
103
+
104
+ ```python
105
+ # in a script
106
+ from highlighter import HLClient
107
+
108
+ client = HLClient.from_profile("profile-name")
109
+ ```
110
+
111
+ Additionally `HLClient` can be initialized using environment variables or
112
+ by passing credentials direcly
113
+
114
+ ```python
115
+ from highlighter import HLClient
116
+
117
+ client = HLClient.from_env()
118
+
119
+ # or
120
+
121
+ api_token = "###"
122
+ endpoint_url = "https://...highligher.ai/graphql
123
+ client = HLCient.from_credential(api_token, endpoint_url)
124
+ ```
125
+
126
+ Finally, if you are in the position where you want to write a specified profile's
127
+ credentials to an evnironment file such as `.env` or `.envrc` you can use
128
+ the `write` command. This will create or append to the specified file.
129
+
130
+ ```console
131
+ hl --profile my-profile write .envrc
132
+ ```
133
+
134
+ ## Python API
135
+
136
+ Once you have a `HLClient` object you can use it perform queries or mutations. Here is a simple example.
137
+
138
+ ```python
139
+ from highlighter import HLClient
140
+ from pydantic import BaseModel
141
+
142
+ client = HLClient.from_env()
143
+
144
+ # You don't always need to define your own BaseModels
145
+ # many common BaseModels are defined in highlighter.base_models
146
+ # this is simply for completeness
147
+ class ObjectClassType(BaseModel):
148
+ id: int
149
+ name: str
150
+
151
+ id = 1234 # add an object class id from you account
152
+
153
+ result = client.ObjectClass(
154
+ return_type=ObjectClassType,
155
+ id=id,
156
+ )
157
+
158
+ print(result)
159
+ ```
160
+
161
+ Some queries may return arbitrarily many results. These queries are
162
+ paginated and are called `Connections` and the queries are named accordingly.
163
+ We have provided a `paginate` function to help with these `Connections`
164
+
165
+ ```python
166
+ from highlighter import HLClient, paginate
167
+ from pydantic import BaseModel
168
+
169
+ client = HLClient.from_env()
170
+ uuids = [
171
+ "abc123-abc123-abc123-abc123",
172
+ "xyz456-xyz456-xyz456-xyz456",
173
+ ]
174
+
175
+ # The following BaseModels are all defined in
176
+ # highlighter.base_models. They are simply here
177
+ # for completeness
178
+ class PageInfo(BaseModel):
179
+ hasNextPage: bool
180
+ endCursor: Optional[str]
181
+
182
+ class ObjectClass(BaseModel):
183
+ id: str
184
+ uuid: str
185
+ name: str
186
+
187
+ class ObjectClassTypeConnection(BaseModel):
188
+ pageInfo: PageInfo
189
+ nodes: List[ObjectClass]
190
+
191
+ generator = paginate(
192
+ client..objectClassConnection,
193
+ ObjectClassTypeConnection,
194
+ uuid=uuids,
195
+ )
196
+
197
+ for object_class in generator:
198
+ print(object_class)
199
+
200
+ ```
201
+
202
+ ## Datasets
203
+
204
+ Highlighter SDK provides a dataset representation that can populated
205
+ from several sources `{HighlighterWeb.Assessments | Local files {.hdf, records.json, coco.json} | S3Bucket}`.
206
+ Once populated the `Highlighter.Datasets` object contains 2 `Pandas.DataFrames`
207
+ (`data_files_df` and `annotations_df`) that you can manipulate as required. When you're
208
+ ready you can write to disk or upload to Highligher using one of the `Writer` classes
209
+ to dump your data to disk in a format that can be consumed by your downstream code.
210
+ If you need you can also roll-your-own `Writer` by implementing the `highlighter.datasets.interfaces.IWriter` interface.
211
+
212
+
213
+ ## Documentation
214
+
215
+ See https://highlighter-docs.netlify.app/
@@ -0,0 +1,177 @@
1
+ # Highlighter SDK
2
+
3
+ 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.
4
+
5
+ The library also provides other features. For example:
6
+
7
+ * Easy configuration for fast setup and use across multiple Highlighter accounts.
8
+ * Functions to help work with datasets from Highlighter
9
+ * Helpers for pagination.
10
+
11
+ **For developer docs see: [here](docs/dev.md)**
12
+
13
+ # API Tokens, Environment Variables and Profiles
14
+
15
+ If you have just a single set of Highlighter credentials you can simply set
16
+ the appropriate environment variables.
17
+
18
+ ```
19
+ export HL_WEB_GRAPHQL_ENDPOINT="https://<client-account>.highlighter.ai/graphql"
20
+ export HL_WEB_GRAPHQL_API_TOKEN="###"
21
+
22
+ # Only required if you have datasets stored outside Highlighter's managed
23
+ # aws s3 storage
24
+ export AWS_ACCESS_KEY_ID=###
25
+ export AWS_SECRET_ACCESS_KEY=###
26
+ export AWS_DEFAULT_REGION=###
27
+ ```
28
+
29
+ If you have several Highlighter credentials we suggest you use the
30
+ **profiles** option. You can create a `~/.highlighter-profiles.yaml` via the
31
+ cli.
32
+
33
+ ```console
34
+ hl config create --name my-profile --api-token ### --endpoint https://...
35
+ ```
36
+
37
+ Other commands for managing your profiles can be seen with the `--help` flag,
38
+
39
+ If you're a *Maverick Renegade* you can manage the `~/.highlighter-profiles.yaml`
40
+ manually. Below is an example,
41
+
42
+ ```yaml
43
+ # Example ~/.highlighter-profiles.yaml
44
+
45
+ my_profile:
46
+ endpoint_url: https://<client-account>.highlighter.ai/graphql
47
+ api_token: ###
48
+
49
+ # Only required if you have datasets stored outside Highlighter's managed
50
+ # aws s3 storage
51
+ cloud:
52
+ - type: aws-s3
53
+ aws_access_key_id: ###
54
+ aws_secret_access_key: ###
55
+ aws_default_region: ###
56
+ ```
57
+
58
+ To use as a profile in the cli simply use,
59
+
60
+ ```console
61
+ hl --profile <profile-name> <command>
62
+ ```
63
+
64
+ In a script you can use,
65
+
66
+ ```python
67
+ # in a script
68
+ from highlighter import HLClient
69
+
70
+ client = HLClient.from_profile("profile-name")
71
+ ```
72
+
73
+ Additionally `HLClient` can be initialized using environment variables or
74
+ by passing credentials direcly
75
+
76
+ ```python
77
+ from highlighter import HLClient
78
+
79
+ client = HLClient.from_env()
80
+
81
+ # or
82
+
83
+ api_token = "###"
84
+ endpoint_url = "https://...highligher.ai/graphql
85
+ client = HLCient.from_credential(api_token, endpoint_url)
86
+ ```
87
+
88
+ Finally, if you are in the position where you want to write a specified profile's
89
+ credentials to an evnironment file such as `.env` or `.envrc` you can use
90
+ the `write` command. This will create or append to the specified file.
91
+
92
+ ```console
93
+ hl --profile my-profile write .envrc
94
+ ```
95
+
96
+ ## Python API
97
+
98
+ Once you have a `HLClient` object you can use it perform queries or mutations. Here is a simple example.
99
+
100
+ ```python
101
+ from highlighter import HLClient
102
+ from pydantic import BaseModel
103
+
104
+ client = HLClient.from_env()
105
+
106
+ # You don't always need to define your own BaseModels
107
+ # many common BaseModels are defined in highlighter.base_models
108
+ # this is simply for completeness
109
+ class ObjectClassType(BaseModel):
110
+ id: int
111
+ name: str
112
+
113
+ id = 1234 # add an object class id from you account
114
+
115
+ result = client.ObjectClass(
116
+ return_type=ObjectClassType,
117
+ id=id,
118
+ )
119
+
120
+ print(result)
121
+ ```
122
+
123
+ Some queries may return arbitrarily many results. These queries are
124
+ paginated and are called `Connections` and the queries are named accordingly.
125
+ We have provided a `paginate` function to help with these `Connections`
126
+
127
+ ```python
128
+ from highlighter import HLClient, paginate
129
+ from pydantic import BaseModel
130
+
131
+ client = HLClient.from_env()
132
+ uuids = [
133
+ "abc123-abc123-abc123-abc123",
134
+ "xyz456-xyz456-xyz456-xyz456",
135
+ ]
136
+
137
+ # The following BaseModels are all defined in
138
+ # highlighter.base_models. They are simply here
139
+ # for completeness
140
+ class PageInfo(BaseModel):
141
+ hasNextPage: bool
142
+ endCursor: Optional[str]
143
+
144
+ class ObjectClass(BaseModel):
145
+ id: str
146
+ uuid: str
147
+ name: str
148
+
149
+ class ObjectClassTypeConnection(BaseModel):
150
+ pageInfo: PageInfo
151
+ nodes: List[ObjectClass]
152
+
153
+ generator = paginate(
154
+ client..objectClassConnection,
155
+ ObjectClassTypeConnection,
156
+ uuid=uuids,
157
+ )
158
+
159
+ for object_class in generator:
160
+ print(object_class)
161
+
162
+ ```
163
+
164
+ ## Datasets
165
+
166
+ Highlighter SDK provides a dataset representation that can populated
167
+ from several sources `{HighlighterWeb.Assessments | Local files {.hdf, records.json, coco.json} | S3Bucket}`.
168
+ Once populated the `Highlighter.Datasets` object contains 2 `Pandas.DataFrames`
169
+ (`data_files_df` and `annotations_df`) that you can manipulate as required. When you're
170
+ ready you can write to disk or upload to Highligher using one of the `Writer` classes
171
+ to dump your data to disk in a format that can be consumed by your downstream code.
172
+ If you need you can also roll-your-own `Writer` by implementing the `highlighter.datasets.interfaces.IWriter` interface.
173
+
174
+
175
+ ## Documentation
176
+
177
+ See https://highlighter-docs.netlify.app/
@@ -0,0 +1,18 @@
1
+ # isort: skip_file
2
+
3
+ from highlighter.const import *
4
+ from highlighter.base_models import *
5
+ from highlighter.gql_client import HLClient
6
+
7
+ from highlighter.entity_avro_schema import *
8
+ from highlighter.data_files import *
9
+ from highlighter.labeled_uuid import *
10
+ from highlighter.object_classes import *
11
+ from highlighter.pagination import paginate
12
+ from highlighter.presigned_url import *
13
+ from highlighter.assessments import *
14
+ from highlighter.tasks import *
15
+ from highlighter.training_runs import *
16
+ from highlighter import io
17
+ from highlighter.capabilities import *
18
+ from highlighter.workflow import *