Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/examples/cvat/exchange-oracle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ Available at `/docs` route

To run tests
```
docker compose -f docker-compose.test.yml up --build test --attach test --exit-code-from test
docker compose -f docker-compose.test.yml up --build test --attach test --exit-code-from test && \
docker compose -f docker-compose.test.yml down
```
8 changes: 4 additions & 4 deletions packages/examples/cvat/exchange-oracle/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/examples/cvat/exchange-oracle/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sqlalchemy-utils = "^0.41.1"
alembic = "^1.11.1"
httpx = "^0.24.1"
pytest = "^7.2.2"
cvat-sdk = "2.31.0"
cvat-sdk = "2.37.0"
sqlalchemy = "^2.0.16"
apscheduler = "^3.10.1"
xmltodict = "^0.13.0"
Expand Down
2 changes: 2 additions & 0 deletions packages/examples/cvat/exchange-oracle/src/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ CVAT_IOU_THRESHOLD=
CVAT_OKS_SIGMA=
CVAT_EXPORT_TIMEOUT=
CVAT_IMPORT_TIMEOUT=
CVAT_PROJECTS_PAGE_SIZE=
CVAT_JOBS_PAGE_SIZE=

# Storage Config (S3/GCS)

Expand Down
5 changes: 4 additions & 1 deletion packages/examples/cvat/exchange-oracle/src/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class CronConfig:
"Maximum number of downloading attempts per job or project during results downloading"

track_completed_escrows_jobs_downloading_batch_size = int(
getenv("TRACK_COMPLETED_ESCROWS_JOBS_DOWNLOADING_BATCH_SIZE", 500)
getenv("TRACK_COMPLETED_ESCROWS_JOBS_DOWNLOADING_BATCH_SIZE", 10)
)
"Maximum number of parallel downloading requests during results downloading"

Expand Down Expand Up @@ -183,6 +183,9 @@ class CvatConfig:
incoming_webhooks_url = getenv("CVAT_INCOMING_WEBHOOKS_URL")
webhook_secret = getenv("CVAT_WEBHOOK_SECRET", "thisisasamplesecret")

projects_page_size = int(getenv("CVAT_PROJECTS_PAGE_SIZE", 100))
jobs_page_size = int(getenv("CVAT_JOBS_PAGE_SIZE", 100))


class StorageConfig:
provider: ClassVar[str] = os.environ["STORAGE_PROVIDER"].lower()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class RoiInfo:
bbox_y: int
bbox_label: int

point_x: int
point_y: int

# RoI is centered on the bbox center
# Coordinates can be out of image boundaries.
# In this case RoI includes extra margins to be centered on bbox center
Expand Down Expand Up @@ -117,7 +120,10 @@ def parse_skeleton_bbox_mapping(self, skeleton_bbox_mapping_data: bytes) -> Skel
return {int(k): int(v) for k, v in parse_json(skeleton_bbox_mapping_data).items()}

def parse_roi_info(self, rois_info_data: bytes) -> RoiInfos:
return [RoiInfo(**roi_info) for roi_info in parse_json(rois_info_data)]
return [
RoiInfo(**{"point_x": 0, "point_y": 0, **roi_info})
for roi_info in parse_json(rois_info_data)
]

def parse_roi_filenames(self, roi_filenames_data: bytes) -> RoiFilenames:
return {int(k): v for k, v in parse_json(roi_filenames_data).items()}
Expand Down
27 changes: 19 additions & 8 deletions packages/examples/cvat/exchange-oracle/src/cvat/api_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,23 @@ def _request_annotations(endpoint: Endpoint, cvat_id: int, format_name: str) ->
_get_annotations(request_id, ...)
"""

(_, response) = endpoint.call_with_http_info(
id=cvat_id,
format=format_name,
save_images=False,
_parse_response=False,
)
try:
(_, response) = endpoint.call_with_http_info(
id=cvat_id,
format=format_name,
save_images=False,
_parse_response=False,
)

assert response.status in [HTTPStatus.ACCEPTED, HTTPStatus.CREATED]
rq_id = response.json()["rq_id"]
except exceptions.ApiException as e:
if e.status == HTTPStatus.CONFLICT:
rq_id = json.loads(e.body)["rq_id"]
else:
raise

assert response.status in [HTTPStatus.ACCEPTED, HTTPStatus.CREATED]
return response.json()["rq_id"]
return rq_id


def _get_annotations(
Expand Down Expand Up @@ -462,6 +470,7 @@ def fetch_task_jobs(task_id: int) -> list[models.JobRead]:
api_client.jobs_api.list_endpoint,
task_id=task_id,
type="annotation",
page_size=Config.cvat_config.jobs_page_size,
)
except exceptions.ApiException as e:
logger.exception(f"Exception when calling JobsApi.list: {e}\n")
Expand Down Expand Up @@ -535,6 +544,7 @@ def fetch_projects(assignee: str = "") -> list[models.ProjectRead]:
return get_paginated_collection(
api_client.projects_api.list_endpoint,
**({"assignee": assignee} if assignee else {}),
page_size=Config.cvat_config.projects_page_size,
)
except exceptions.ApiException as e:
logger.exception(f"Exception when calling ProjectsApi.list(): {e}\n")
Expand Down Expand Up @@ -711,6 +721,7 @@ def update_quality_control_settings(
logger = logging.getLogger("app")

params = {
"inherit": False,
"max_validations_per_job": max_validations_per_job,
"target_metric": target_metric,
"target_metric_threshold": target_metric_threshold,
Expand Down
Loading