Skip to content

Commit b09bee1

Browse files
zhiltsov-maxflopez7
authored andcommitted
[CVAT] Update cvat api uses (#3348)
* Fix possible no assignments error when there are * Update readme * Update cvat sdk versions * Address api changes * Improve performance of some cvat calls * Improve description
1 parent 83817c9 commit b09bee1

File tree

10 files changed

+42
-20
lines changed

10 files changed

+42
-20
lines changed

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/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,

packages/examples/cvat/recording-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/recording-oracle/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ google-cloud-storage = "^2.14.0"
2424
datumaro = {git = "https://github.com/cvat-ai/datumaro.git", rev = "ff83c00c2c1bc4b8fdfcc55067fcab0a9b5b6b11"}
2525
hexbytes = ">=1.2.0" # required for to_0x_hex() function
2626
starlette = ">=0.40.0" # avoid the vulnerability with multipart/form-data
27-
cvat-sdk = "2.31.0"
27+
cvat-sdk = "2.37.0"
2828
cryptography = "<44.0.0" # human-protocol-sdk -> pgpy dep requires cryptography < 45
2929
human-protocol-sdk = "^4.0.3"
3030

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ CVAT_ADMIN_PASS=
6161
CVAT_ORG_SLUG=
6262
CVAT_QUALITY_RETRIEVAL_TIMEOUT=
6363
CVAT_QUALITY_CHECK_INTERVAL=
64+
CVAT_QUALITY_REPORTS_PAGE_SIZE=
6465

6566
# Localhost
6667

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class ValidationConfig:
195195
warmup_iterations = int(getenv("WARMUP_ITERATIONS", "1"))
196196
"""
197197
The first escrow iterations where the annotation speed is checked to be big enough.
198+
Set to 0 to disable.
198199
"""
199200

200201
min_warmup_progress = float(getenv("MIN_WARMUP_PROGRESS", "10"))
@@ -234,6 +235,7 @@ class CvatConfig:
234235

235236
quality_retrieval_timeout = int(getenv("CVAT_QUALITY_RETRIEVAL_TIMEOUT", 60 * 60))
236237
quality_check_interval = int(getenv("CVAT_QUALITY_CHECK_INTERVAL", 5))
238+
quality_reports_page_size = int(getenv("CVAT_QUALITY_REPORTS_PAGE_SIZE", 100))
237239

238240

239241
class Config:

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ def get_jobs_quality_reports(parent_id: int) -> list[models.QualityReport]:
134134
with get_api_client() as api_client:
135135
try:
136136
return get_paginated_collection(
137-
api_client.quality_api.list_reports_endpoint, parent_id=parent_id, target="job"
137+
api_client.quality_api.list_reports_endpoint,
138+
parent_id=parent_id,
139+
target="job",
140+
page_size=Config.cvat_config.quality_reports_page_size,
138141
)
139142

140143
except exceptions.ApiException as e:

0 commit comments

Comments
 (0)