Skip to content

Commit ceb467d

Browse files
authored
Merge pull request #3349 from humanprotocol/develop
Release 2025-05-21
2 parents 7c971c8 + c8171e1 commit ceb467d

18 files changed

Lines changed: 342 additions & 181 deletions

File tree

packages/examples/cvat/exchange-oracle/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@ Available at `/docs` route
7373

7474
To run tests
7575
```
76-
docker compose -f docker-compose.test.yml up --build test --attach test --exit-code-from test
76+
docker compose -f docker-compose.test.yml up --build test --attach test --exit-code-from test && \
77+
docker compose -f docker-compose.test.yml down
7778
```

packages/examples/cvat/exchange-oracle/poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/examples/cvat/exchange-oracle/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sqlalchemy-utils = "^0.41.1"
1616
alembic = "^1.11.1"
1717
httpx = "^0.24.1"
1818
pytest = "^7.2.2"
19-
cvat-sdk = "2.31.0"
19+
cvat-sdk = "2.37.0"
2020
sqlalchemy = "^2.0.16"
2121
apscheduler = "^3.10.1"
2222
xmltodict = "^0.13.0"

packages/examples/cvat/exchange-oracle/src/.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ CVAT_IOU_THRESHOLD=
7777
CVAT_OKS_SIGMA=
7878
CVAT_EXPORT_TIMEOUT=
7979
CVAT_IMPORT_TIMEOUT=
80+
CVAT_PROJECTS_PAGE_SIZE=
81+
CVAT_JOBS_PAGE_SIZE=
8082

8183
# Storage Config (S3/GCS)
8284

packages/examples/cvat/exchange-oracle/src/core/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class CronConfig:
146146
"Maximum number of downloading attempts per job or project during results downloading"
147147

148148
track_completed_escrows_jobs_downloading_batch_size = int(
149-
getenv("TRACK_COMPLETED_ESCROWS_JOBS_DOWNLOADING_BATCH_SIZE", 500)
149+
getenv("TRACK_COMPLETED_ESCROWS_JOBS_DOWNLOADING_BATCH_SIZE", 10)
150150
)
151151
"Maximum number of parallel downloading requests during results downloading"
152152

@@ -183,6 +183,9 @@ class CvatConfig:
183183
incoming_webhooks_url = getenv("CVAT_INCOMING_WEBHOOKS_URL")
184184
webhook_secret = getenv("CVAT_WEBHOOK_SECRET", "thisisasamplesecret")
185185

186+
projects_page_size = int(getenv("CVAT_PROJECTS_PAGE_SIZE", 100))
187+
jobs_page_size = int(getenv("CVAT_JOBS_PAGE_SIZE", 100))
188+
186189

187190
class StorageConfig:
188191
provider: ClassVar[str] = os.environ["STORAGE_PROVIDER"].lower()

packages/examples/cvat/exchange-oracle/src/core/tasks/skeletons_from_boxes.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class RoiInfo:
2323
bbox_y: int
2424
bbox_label: int
2525

26+
point_x: int
27+
point_y: int
28+
2629
# RoI is centered on the bbox center
2730
# Coordinates can be out of image boundaries.
2831
# In this case RoI includes extra margins to be centered on bbox center
@@ -117,7 +120,10 @@ def parse_skeleton_bbox_mapping(self, skeleton_bbox_mapping_data: bytes) -> Skel
117120
return {int(k): int(v) for k, v in parse_json(skeleton_bbox_mapping_data).items()}
118121

119122
def parse_roi_info(self, rois_info_data: bytes) -> RoiInfos:
120-
return [RoiInfo(**roi_info) for roi_info in parse_json(rois_info_data)]
123+
return [
124+
RoiInfo(**{"point_x": 0, "point_y": 0, **roi_info})
125+
for roi_info in parse_json(rois_info_data)
126+
]
121127

122128
def parse_roi_filenames(self, roi_filenames_data: bytes) -> RoiFilenames:
123129
return {int(k): v for k, v in parse_json(roi_filenames_data).items()}

packages/examples/cvat/exchange-oracle/src/cvat/api_calls.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,23 @@ def _request_annotations(endpoint: Endpoint, cvat_id: int, format_name: str) ->
4747
_get_annotations(request_id, ...)
4848
"""
4949

50-
(_, response) = endpoint.call_with_http_info(
51-
id=cvat_id,
52-
format=format_name,
53-
save_images=False,
54-
_parse_response=False,
55-
)
50+
try:
51+
(_, response) = endpoint.call_with_http_info(
52+
id=cvat_id,
53+
format=format_name,
54+
save_images=False,
55+
_parse_response=False,
56+
)
57+
58+
assert response.status in [HTTPStatus.ACCEPTED, HTTPStatus.CREATED]
59+
rq_id = response.json()["rq_id"]
60+
except exceptions.ApiException as e:
61+
if e.status == HTTPStatus.CONFLICT:
62+
rq_id = json.loads(e.body)["rq_id"]
63+
else:
64+
raise
5665

57-
assert response.status in [HTTPStatus.ACCEPTED, HTTPStatus.CREATED]
58-
return response.json()["rq_id"]
66+
return rq_id
5967

6068

6169
def _get_annotations(
@@ -462,6 +470,7 @@ def fetch_task_jobs(task_id: int) -> list[models.JobRead]:
462470
api_client.jobs_api.list_endpoint,
463471
task_id=task_id,
464472
type="annotation",
473+
page_size=Config.cvat_config.jobs_page_size,
465474
)
466475
except exceptions.ApiException as e:
467476
logger.exception(f"Exception when calling JobsApi.list: {e}\n")
@@ -535,6 +544,7 @@ def fetch_projects(assignee: str = "") -> list[models.ProjectRead]:
535544
return get_paginated_collection(
536545
api_client.projects_api.list_endpoint,
537546
**({"assignee": assignee} if assignee else {}),
547+
page_size=Config.cvat_config.projects_page_size,
538548
)
539549
except exceptions.ApiException as e:
540550
logger.exception(f"Exception when calling ProjectsApi.list(): {e}\n")
@@ -711,6 +721,7 @@ def update_quality_control_settings(
711721
logger = logging.getLogger("app")
712722

713723
params = {
724+
"inherit": False,
714725
"max_validations_per_job": max_validations_per_job,
715726
"target_metric": target_metric,
716727
"target_metric_threshold": target_metric_threshold,

0 commit comments

Comments
 (0)