Skip to content

Commit

Permalink
finish making tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
sunildkumar committed Oct 16, 2023
1 parent 2318671 commit 52f4503
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion generated/docs/ImageQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Name | Type | Description | Notes
**query** | **str** | A question about the image. | [readonly]
**detector_id** | **str** | Which detector was used on this image query? | [readonly]
**result_type** | **bool, date, datetime, dict, float, int, list, str, none_type** | What type of result are we returning? | [readonly]
**result** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [readonly]
**result** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] [readonly]
**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]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
4 changes: 2 additions & 2 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: 2023-10-16T22:49:17+00:00
# timestamp: 2023-10-16T23:29:00+00:00

from __future__ import annotations

Expand Down Expand Up @@ -69,7 +69,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: ClassificationResult
result: Optional[ClassificationResult] = None


class PaginatedDetectorList(BaseModel):
Expand Down
8 changes: 3 additions & 5 deletions generated/openapi_client/model/image_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ def discriminator():

@classmethod
@convert_js_args_to_python_args
def _from_openapi_data(
cls, id, type, created_at, query, detector_id, result_type, result, *args, **kwargs
): # noqa: E501
def _from_openapi_data(cls, id, type, created_at, query, detector_id, result_type, *args, **kwargs): # noqa: E501
"""ImageQuery - a model defined in OpenAPI
Args:
Expand All @@ -180,7 +178,6 @@ def _from_openapi_data(
query (str): A question about the image.
detector_id (str): Which detector was used on this image query?
result_type (bool, date, datetime, dict, float, int, list, str, none_type): What type of result are we returning?
result (bool, date, datetime, dict, float, int, list, str, none_type):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down Expand Up @@ -213,6 +210,7 @@ def _from_openapi_data(
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
result (bool, date, datetime, dict, float, int, list, str, none_type): [optional] # noqa: E501
"""

_check_type = kwargs.pop("_check_type", True)
Expand Down Expand Up @@ -247,7 +245,6 @@ def _from_openapi_data(
self.query = query
self.detector_id = detector_id
self.result_type = result_type
self.result = result
for var_name, var_value in kwargs.items():
if (
var_name not in self.attribute_map
Expand Down Expand Up @@ -306,6 +303,7 @@ def __init__(self, *args, **kwargs): # noqa: E501
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
result (bool, date, datetime, dict, float, int, list, str, none_type): [optional] # noqa: E501
"""

_check_type = kwargs.pop("_check_type", True)
Expand Down
1 change: 0 additions & 1 deletion spec/public-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ components:
- detector_id
- id
- query
- result
- result_type
- type
x-internal: true
Expand Down
9 changes: 6 additions & 3 deletions test/integration/test_groundlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# ruff: noqa: F403,F405
# pylint: disable=wildcard-import,unused-wildcard-import,redefined-outer-name,import-outside-toplevel
from datetime import datetime
import time
from typing import Any

import openapi_client
Expand Down Expand Up @@ -265,11 +266,11 @@ def test_submit_image_query_with_want_async_workflow(gl: Groundlight, detector:
assert _image_query.result is None

# attempting to access fields within the result should raise an exception
with pytest.raises(ValueError):
with pytest.raises(AttributeError):
_ = _image_query.result.label # type: ignore
with pytest.raises(ValueError):
with pytest.raises(AttributeError):
_ = _image_query.result.confidence # type: ignore

time.sleep(5)
# you should be able to get a "real" result by retrieving an updated image query object from the server
_image_query = gl.get_image_query(id=_image_query.id)
assert _image_query.result is not None
Expand All @@ -291,6 +292,8 @@ def test_ask_async_workflow(gl: Groundlight, detector: Detector):
with pytest.raises(AttributeError):
_ = _image_query.result.confidence # type: ignore

time.sleep(5)

# you should be able to get a "real" result by retrieving an updated image query object from the server
_image_query = gl.get_image_query(id=_image_query.id)
assert _image_query.result is not None
Expand Down

0 comments on commit 52f4503

Please sign in to comment.