Skip to content

Commit

Permalink
results can be none with asyc calls
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-groundlight committed Oct 5, 2024
1 parent e7b11dd commit 03e283d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ generate: install-generator ## Generate the SDK from our public openapi spec
-o ./generated \
--additional-properties=packageName=groundlight_openapi_client
# strict-nullable makes nullable fields Optional in the generated Pydantic classes: https://github.com/koxudaxi/datamodel-code-generator/issues/327
poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py --strict-nullable --use-schema-description --output-model-type pydantic_v2.BaseModel
poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py --strict-nullable --use-schema-description --output-model-type pydantic_v2.BaseModel --use-subclass-enum
poetry run black .

PYTEST=poetry run pytest -v
Expand Down
7 changes: 0 additions & 7 deletions generated/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,4 @@ setup.cfg
setup.py
test-requirements.txt
test/__init__.py
test/test_blank_enum.py
test/test_count_mode_configuration.py
test/test_escalation_type_enum.py
test/test_multi_class_mode_configuration.py
test/test_multi_classification_result.py
test/test_patched_detector_request.py
test/test_status_enum.py
tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ class BinaryClassificationResult(ModelNormal):

allowed_values = {
("source",): {
"INITIALPLACEHOLDER": "InitialPlaceholder",
"HUMANCLOUD": "HumanCloud",
"HUMANCUSTOMER": "HumanCustomer",
"HUMANCLOUDENSEMBLE": "HumanCloudEnsemble",
"ALGORITHM": "Algorithm",
"ALGORITHMRECONCILED": "AlgorithmReconciled",
"ALGORITHMUNCLEAR": "AlgorithmUnclear",
"STILL_PROCESSING": "STILL_PROCESSING",
"CLOUD": "CLOUD",
"USER": "USER",
"CLOUD_ENSEMBLE": "CLOUD_ENSEMBLE",
"ALGORITHM": "ALGORITHM",
},
("label",): {
"YES": "YES",
Expand Down
12 changes: 5 additions & 7 deletions generated/groundlight_openapi_client/model/counting_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ class CountingResult(ModelNormal):

allowed_values = {
("source",): {
"INITIALPLACEHOLDER": "InitialPlaceholder",
"HUMANCLOUD": "HumanCloud",
"HUMANCUSTOMER": "HumanCustomer",
"HUMANCLOUDENSEMBLE": "HumanCloudEnsemble",
"ALGORITHM": "Algorithm",
"ALGORITHMRECONCILED": "AlgorithmReconciled",
"ALGORITHMUNCLEAR": "AlgorithmUnclear",
"STILL_PROCESSING": "STILL_PROCESSING",
"CLOUD": "CLOUD",
"USER": "USER",
"CLOUD_ENSEMBLE": "CLOUD_ENSEMBLE",
"ALGORITHM": "ALGORITHM",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ class MultiClassificationResult(ModelNormal):

allowed_values = {
("source",): {
"INITIALPLACEHOLDER": "InitialPlaceholder",
"HUMANCLOUD": "HumanCloud",
"HUMANCUSTOMER": "HumanCustomer",
"HUMANCLOUDENSEMBLE": "HumanCloudEnsemble",
"ALGORITHM": "Algorithm",
"ALGORITHMRECONCILED": "AlgorithmReconciled",
"ALGORITHMUNCLEAR": "AlgorithmUnclear",
"STILL_PROCESSING": "STILL_PROCESSING",
"CLOUD": "CLOUD",
"USER": "USER",
"CLOUD_ENSEMBLE": "CLOUD_ENSEMBLE",
"ALGORITHM": "ALGORITHM",
},
}

Expand Down
42 changes: 20 additions & 22 deletions generated/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: public-api.yaml
# timestamp: 2024-10-04T20:49:02+00:00
# timestamp: 2024-10-05T01:13:27+00:00

from __future__ import annotations

Expand All @@ -11,7 +11,7 @@
from pydantic import AnyUrl, BaseModel, Field, RootModel, confloat, conint, constr


class AnnotationsRequestedEnum(Enum):
class AnnotationsRequestedEnum(str, Enum):
"""
* `BINARY_CLASSIFICATION` - Binary Classification
* `BOUNDING_BOXES` - Bounding Boxes
Expand Down Expand Up @@ -58,11 +58,11 @@ class DetectorGroupRequest(BaseModel):
name: constr(min_length=1, max_length=100)


class DetectorTypeEnum(Enum):
class DetectorTypeEnum(str, Enum):
detector = "detector"


class EscalationTypeEnum(Enum):
class EscalationTypeEnum(str, Enum):
"""
* `STANDARD` - STANDARD
* `NO_HUMAN_LABELING` - NO_HUMAN_LABELING
Expand All @@ -72,11 +72,11 @@ class EscalationTypeEnum(Enum):
NO_HUMAN_LABELING = "NO_HUMAN_LABELING"


class ImageQueryTypeEnum(Enum):
class ImageQueryTypeEnum(str, Enum):
image_query = "image_query"


class ModeEnum(Enum):
class ModeEnum(str, Enum):
BINARY = "BINARY"
COUNT = "COUNT"
MULTI_CLASS = "MULTI_CLASS"
Expand Down Expand Up @@ -111,13 +111,13 @@ class ROIRequest(BaseModel):
geometry: BBoxGeometryRequest


class ResultTypeEnum(Enum):
class ResultTypeEnum(str, Enum):
binary_classification = "binary_classification"
counting = "counting"
multi_classification = "multi_classification"


class SnoozeTimeUnitEnum(Enum):
class SnoozeTimeUnitEnum(str, Enum):
"""
* `DAYS` - DAYS
* `HOURS` - HOURS
Expand All @@ -131,7 +131,7 @@ class SnoozeTimeUnitEnum(Enum):
SECONDS = "SECONDS"


class SourceEnum(Enum):
class SourceEnum(str, Enum):
"""
* `INITIAL_PLACEHOLDER` - InitialPlaceholder
* `CLOUD` - HumanCloud
Expand All @@ -151,7 +151,7 @@ class SourceEnum(Enum):
ALG_UNCLEAR = "ALG_UNCLEAR"


class StatusEnum(Enum):
class StatusEnum(str, Enum):
"""
* `ON` - ON
* `OFF` - OFF
Expand All @@ -161,7 +161,7 @@ class StatusEnum(Enum):
OFF = "OFF"


class VerbEnum(Enum):
class VerbEnum(str, Enum):
"""
* `ANSWERED_CONSECUTIVELY` - ANSWERED_CONSECUTIVELY
* `ANSWERED_WITHIN_TIME` - ANSWERED_WITHIN_TIME
Expand All @@ -177,17 +177,15 @@ class VerbEnum(Enum):
NO_QUERIES = "NO_QUERIES"


class Source(Enum):
InitialPlaceholder = "InitialPlaceholder"
HumanCloud = "HumanCloud"
HumanCustomer = "HumanCustomer"
HumanCloudEnsemble = "HumanCloudEnsemble"
Algorithm = "Algorithm"
AlgorithmReconciled = "AlgorithmReconciled"
AlgorithmUnclear = "AlgorithmUnclear"
class Source(str, Enum):
STILL_PROCESSING = "STILL_PROCESSING"
CLOUD = "CLOUD"
USER = "USER"
CLOUD_ENSEMBLE = "CLOUD_ENSEMBLE"
ALGORITHM = "ALGORITHM"


class Label(Enum):
class Label(str, Enum):
YES = "YES"
NO = "NO"
UNCLEAR = "UNCLEAR"
Expand Down Expand Up @@ -221,7 +219,7 @@ class MultiClassModeConfiguration(BaseModel):
num_classes: Optional[int] = None


class ChannelEnum(Enum):
class ChannelEnum(str, Enum):
TEXT = "TEXT"
EMAIL = "EMAIL"

Expand Down Expand Up @@ -348,7 +346,7 @@ class ImageQuery(BaseModel):
query: str = Field(..., description="A question about the image.")
detector_id: str = Field(..., description="Which detector was used on this image query?")
result_type: ResultTypeEnum = Field(..., description="What type of result are we returning?")
result: Union[BinaryClassificationResult, CountingResult, MultiClassificationResult]
result: Optional[Union[BinaryClassificationResult, CountingResult, MultiClassificationResult]] = Field(...)
patience_time: float = Field(..., description="How long to wait for a confident response.")
confidence_threshold: float = Field(
..., description="Min confidence needed to accept the response of the image query."
Expand Down
37 changes: 16 additions & 21 deletions spec/public-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ components:
- $ref: '#/components/schemas/BinaryClassificationResult'
- $ref: '#/components/schemas/CountingResult'
- $ref: '#/components/schemas/MultiClassificationResult'
nullable: true
patience_time:
type: number
format: double
Expand Down Expand Up @@ -1332,13 +1333,11 @@ components:
source:
type: string
enum:
- InitialPlaceholder
- HumanCloud
- HumanCustomer
- HumanCloudEnsemble
- Algorithm
- AlgorithmReconciled
- AlgorithmUnclear
- STILL_PROCESSING
- CLOUD
- USER
- CLOUD_ENSEMBLE
- ALGORITHM
label:
type: string
enum:
Expand All @@ -1359,13 +1358,11 @@ components:
source:
type: string
enum:
- InitialPlaceholder
- HumanCloud
- HumanCustomer
- HumanCloudEnsemble
- Algorithm
- AlgorithmReconciled
- AlgorithmUnclear
- STILL_PROCESSING
- CLOUD
- USER
- CLOUD_ENSEMBLE
- ALGORITHM
count:
type: integer
minimum: null
Expand All @@ -1386,13 +1383,11 @@ components:
source:
type: string
enum:
- InitialPlaceholder
- HumanCloud
- HumanCustomer
- HumanCloudEnsemble
- Algorithm
- AlgorithmReconciled
- AlgorithmUnclear
- STILL_PROCESSING
- CLOUD
- USER
- CLOUD_ENSEMBLE
- ALGORITHM
label:
type: string
required:
Expand Down

0 comments on commit 03e283d

Please sign in to comment.