Skip to content

Commit 1d33b96

Browse files
Add "config_name" option (#11)
* Add config_name and generate code * Enable more tests * Add confidence_threshold * Nullable config_name * Update readme * Bump version 0.4.0
1 parent f07d3fc commit 1d33b96

18 files changed

+1958
-44
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,5 @@ cython_debug/
161161

162162
# This is a library, so we want clients to have more flexible dependencies. So we don't include a lockfile.
163163
poetry.lock
164+
165+
node_modules/

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
install: ## Install the package from source
44
poetry install
5+
npm install
56

6-
# Java weirdness - see https://github.com/OpenAPITools/openapi-generator/issues/11763#issuecomment-1098337960
77
generate: install ## Generate the SDK from our public openapi spec
8-
_JAVA_OPTIONS="--add-opens=java.base/java.lang=ALL-UNNAMED \
9-
--add-opens=java.base/java.util=ALL-UNNAMED" \
10-
openapi-generator generate -i spec/public-api.yaml \
8+
node_modules/.bin/openapi-generator-cli generate -i spec/public-api.yaml \
119
-g python \
1210
-o ./generated
1311
poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ from groundlight import Groundlight
2424
# gl = Groundlight(endpoint="https://device.integ.groundlight.ai/device-api")
2525
gl = Groundlight(api_token="<YOUR_API_TOKEN>")
2626

27+
# Create a detector
28+
detector = gl.create_detector(name="Dog", query="Is it a dog?")
29+
30+
# (Or, create a detector with a specific named ML config from https://github.com/positronix-ai/zuuul/blob/main/pysrc/predictor_config/binary_classification_predictors.yaml)
31+
# detector = gl.create_detector(name="Dog", query="Is it a dog?", config_name="b4mu11-mlp")
32+
2733
# Call an API method (e.g., retrieve a list of detectors)
2834
detectors = gl.list_detectors()
2935
```

generated/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ from openapi_client.api import detectors_api
5353
from openapi_client.model.detector import Detector
5454
from openapi_client.model.detector_creation_input import DetectorCreationInput
5555
from openapi_client.model.paginated_detector_list import PaginatedDetectorList
56-
# Defining the host is optional and defaults to https://device.positronix.ai/device-api
56+
# Defining the host is optional and defaults to https://api.groundlight.ai/device-api
5757
# See configuration.py for a list of all supported configuration parameters.
5858
configuration = openapi_client.Configuration(
59-
host = "https://device.positronix.ai/device-api"
59+
host = "https://api.groundlight.ai/device-api"
6060
)
6161

6262
# The client must configure the authentication and authorization parameters
@@ -80,6 +80,7 @@ with openapi_client.ApiClient(configuration) as api_client:
8080
query="query_example",
8181
group_name="group_name_example",
8282
confidence_threshold=0.9,
83+
config_name="config_name_example",
8384
) # DetectorCreationInput |
8485

8586
try:
@@ -91,7 +92,7 @@ with openapi_client.ApiClient(configuration) as api_client:
9192

9293
## Documentation for API Endpoints
9394

94-
All URIs are relative to *https://device.positronix.ai/device-api*
95+
All URIs are relative to *https://api.groundlight.ai/device-api*
9596

9697
Class | Method | HTTP request | Description
9798
------------ | ------------- | ------------- | -------------

generated/docs/DetectorCreationInput.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Name | Type | Description | Notes
99
**query** | **str** | A question about the image. |
1010
**group_name** | **str** | Which group should this detector be part of? | [optional]
1111
**confidence_threshold** | **float** | If the detector&#39;s prediction is below this confidence threshold, send the image query for human review. | [optional] if omitted the server will use the default value of 0.9
12+
**config_name** | **str, none_type** | (Advanced usage) If your account has multiple named ML configuration options enabled, you can use this field to specify which one you would like to use. | [optional]
1213
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
1314

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

generated/docs/DetectorsApi.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# openapi_client.DetectorsApi
22

3-
All URIs are relative to *https://device.positronix.ai/device-api*
3+
All URIs are relative to *https://api.groundlight.ai/device-api*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
@@ -27,10 +27,10 @@ from openapi_client.api import detectors_api
2727
from openapi_client.model.detector_creation_input import DetectorCreationInput
2828
from openapi_client.model.detector import Detector
2929
from pprint import pprint
30-
# Defining the host is optional and defaults to https://device.positronix.ai/device-api
30+
# Defining the host is optional and defaults to https://api.groundlight.ai/device-api
3131
# See configuration.py for a list of all supported configuration parameters.
3232
configuration = openapi_client.Configuration(
33-
host = "https://device.positronix.ai/device-api"
33+
host = "https://api.groundlight.ai/device-api"
3434
)
3535

3636
# The client must configure the authentication and authorization parameters
@@ -53,6 +53,7 @@ with openapi_client.ApiClient(configuration) as api_client:
5353
query="query_example",
5454
group_name="group_name_example",
5555
confidence_threshold=0.9,
56+
config_name="config_name_example",
5657
) # DetectorCreationInput |
5758

5859
# example passing only required values which don't have defaults set
@@ -109,10 +110,10 @@ import openapi_client
109110
from openapi_client.api import detectors_api
110111
from openapi_client.model.detector import Detector
111112
from pprint import pprint
112-
# Defining the host is optional and defaults to https://device.positronix.ai/device-api
113+
# Defining the host is optional and defaults to https://api.groundlight.ai/device-api
113114
# See configuration.py for a list of all supported configuration parameters.
114115
configuration = openapi_client.Configuration(
115-
host = "https://device.positronix.ai/device-api"
116+
host = "https://api.groundlight.ai/device-api"
116117
)
117118

118119
# The client must configure the authentication and authorization parameters
@@ -186,10 +187,10 @@ import openapi_client
186187
from openapi_client.api import detectors_api
187188
from openapi_client.model.paginated_detector_list import PaginatedDetectorList
188189
from pprint import pprint
189-
# Defining the host is optional and defaults to https://device.positronix.ai/device-api
190+
# Defining the host is optional and defaults to https://api.groundlight.ai/device-api
190191
# See configuration.py for a list of all supported configuration parameters.
191192
configuration = openapi_client.Configuration(
192-
host = "https://device.positronix.ai/device-api"
193+
host = "https://api.groundlight.ai/device-api"
193194
)
194195

195196
# The client must configure the authentication and authorization parameters

generated/docs/ImageQueriesApi.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# openapi_client.ImageQueriesApi
22

3-
All URIs are relative to *https://device.positronix.ai/device-api*
3+
All URIs are relative to *https://api.groundlight.ai/device-api*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**get_image_query**](ImageQueriesApi.md#get_image_query) | **GET** /v1/image-queries/{id} |
8-
[**list_image_queries**](ImageQueriesApi.md#list_image_queries) | **GET** /v1/image-queries |
9-
[**submit_image_query**](ImageQueriesApi.md#submit_image_query) | **POST** /v1/image-queries |
7+
[**get_image_query**](ImageQueriesApi.md#get_image_query) | **GET** /v1/image-queries/{id} |
8+
[**list_image_queries**](ImageQueriesApi.md#list_image_queries) | **GET** /v1/image-queries |
9+
[**submit_image_query**](ImageQueriesApi.md#submit_image_query) | **POST** /v1/image-queries |
1010

1111

1212
# **get_image_query**
@@ -26,10 +26,10 @@ import openapi_client
2626
from openapi_client.api import image_queries_api
2727
from openapi_client.model.image_query import ImageQuery
2828
from pprint import pprint
29-
# Defining the host is optional and defaults to https://device.positronix.ai/device-api
29+
# Defining the host is optional and defaults to https://api.groundlight.ai/device-api
3030
# See configuration.py for a list of all supported configuration parameters.
3131
configuration = openapi_client.Configuration(
32-
host = "https://device.positronix.ai/device-api"
32+
host = "https://api.groundlight.ai/device-api"
3333
)
3434

3535
# The client must configure the authentication and authorization parameters
@@ -103,10 +103,10 @@ import openapi_client
103103
from openapi_client.api import image_queries_api
104104
from openapi_client.model.paginated_image_query_list import PaginatedImageQueryList
105105
from pprint import pprint
106-
# Defining the host is optional and defaults to https://device.positronix.ai/device-api
106+
# Defining the host is optional and defaults to https://api.groundlight.ai/device-api
107107
# See configuration.py for a list of all supported configuration parameters.
108108
configuration = openapi_client.Configuration(
109-
host = "https://device.positronix.ai/device-api"
109+
host = "https://api.groundlight.ai/device-api"
110110
)
111111

112112
# The client must configure the authentication and authorization parameters
@@ -171,7 +171,7 @@ Name | Type | Description | Notes
171171
172172

173173

174-
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 ```
174+
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 ```
175175

176176
### Example
177177

@@ -183,10 +183,10 @@ import openapi_client
183183
from openapi_client.api import image_queries_api
184184
from openapi_client.model.image_query import ImageQuery
185185
from pprint import pprint
186-
# Defining the host is optional and defaults to https://device.positronix.ai/device-api
186+
# Defining the host is optional and defaults to https://api.groundlight.ai/device-api
187187
# See configuration.py for a list of all supported configuration parameters.
188188
configuration = openapi_client.Configuration(
189-
host = "https://device.positronix.ai/device-api"
189+
host = "https://api.groundlight.ai/device-api"
190190
)
191191

192192
# The client must configure the authentication and authorization parameters
@@ -252,3 +252,4 @@ Name | Type | Description | Notes
252252
**201** | | - |
253253

254254
[[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)
255+

generated/model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: public-api.yaml
3-
# timestamp: 2022-05-08T05:27:06+00:00
3+
# timestamp: 2022-07-30T20:30:21+00:00
44

55
from __future__ import annotations
66

@@ -33,6 +33,10 @@ class DetectorCreationInput(BaseModel):
3333
0.9,
3434
description="If the detector's prediction is below this confidence threshold, send the image query for human review.",
3535
)
36+
config_name: Optional[constr(max_length=100)] = Field(
37+
None,
38+
description='(Advanced usage) If your account has multiple named ML configuration options enabled, you can use this field to specify which one you would like to use.',
39+
)
3640

3741

3842
class DetectorTypeEnum(Enum):

generated/openapi_client/api/image_queries_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def submit_image_query(
360360
):
361361
"""submit_image_query # noqa: E501
362362
363-
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 ``` # noqa: E501
363+
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 ``` # noqa: E501
364364
This method makes a synchronous HTTP request by default. To make an
365365
asynchronous HTTP request, please pass async_req=True
366366

generated/openapi_client/configuration.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __init__(self, host=None,
113113
):
114114
"""Constructor
115115
"""
116-
self._base_path = "https://device.positronix.ai/device-api" if host is None else host
116+
self._base_path = "https://api.groundlight.ai/device-api" if host is None else host
117117
"""Default Base url
118118
"""
119119
self.server_index = 0 if server_index is None and host is None else server_index
@@ -420,20 +420,20 @@ def get_host_settings(self):
420420
"""
421421
return [
422422
{
423-
'url': "https://device.positronix.ai/device-api",
424-
'description': "Device Prod",
423+
'url': "https://api.groundlight.ai/device-api",
424+
'description': "Prod",
425425
},
426426
{
427-
'url': "https://device.integ.positronix.ai/device-api",
428-
'description': "Device Integ",
427+
'url': "https://api.integ.groundlight.ai/device-api",
428+
'description': "Integ",
429429
},
430430
{
431-
'url': "https://api.groundlight.ai",
432-
'description': "Prod",
431+
'url': "https://device.positronix.ai/device-api",
432+
'description': "Device Prod",
433433
},
434434
{
435-
'url': "https://api.integ.groundlight.ai",
436-
'description': "Integ",
435+
'url': "https://device.integ.positronix.ai/device-api",
436+
'description': "Device Integ",
437437
}
438438
]
439439

0 commit comments

Comments
 (0)