Skip to content

Commit

Permalink
[Recording Oracle] Update .env template, add some variables
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiltsov-max committed Nov 13, 2024
1 parent 7122809 commit 3746126
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
9 changes: 9 additions & 0 deletions packages/examples/cvat/recording-oracle/src/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ EXCHANGE_ORACLE_STORAGE_RESULTS_BUCKET_NAME=
EXCHANGE_ORACLE_STORAGE_USE_SSL=
EXCHANGE_ORACLE_STORAGE_KEY_FILE_PATH=

# CVAT

CVAT_URL=
CVAT_ADMIN=
CVAT_ADMIN_PASS=
CVAT_ORG_SLUG=
CVAT_QUALITY_RETRIEVAL_TIMEOUT=
CVAT_QUALITY_CHECK_INTERVAL=

# Localhost

LOCALHOST_EXCHANGE_ORACLE_URL=
Expand Down
3 changes: 3 additions & 0 deletions packages/examples/cvat/recording-oracle/src/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ class CvatConfig:
cvat_admin_pass = os.environ.get("CVAT_ADMIN_PASS", "admin")
cvat_org_slug = os.environ.get("CVAT_ORG_SLUG", "org1")

cvat_quality_retrieval_timeout = int(os.environ.get("CVAT_QUALITY_RETRIEVAL_TIMEOUT", 60 * 60))
cvat_quality_check_interval = int(os.environ.get("CVAT_QUALITY_CHECK_INTERVAL", 5))


class Config:
port = int(os.environ.get("PORT", 8000))
Expand Down
16 changes: 7 additions & 9 deletions packages/examples/cvat/recording-oracle/src/cvat/api_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def get_last_task_quality_report(task_id: int) -> models.QualityReport | None:
def compute_task_quality_report(
task_id: int,
*,
max_waiting_time: int = 60 * 60,
sleep_interval: float = 0.5,
timeout: int = Config.cvat_config.cvat_quality_retrieval_timeout,
check_interval: float = Config.cvat_config.cvat_quality_check_interval,
) -> models.QualityReport:
logger = logging.getLogger("app")
start_time = utcnow()
Expand All @@ -56,7 +56,7 @@ def compute_task_quality_report(
f"when creating a task({task_id}) quality report"
)

while utcnow() - start_time < timedelta(seconds=max_waiting_time):
while utcnow() - start_time < timedelta(seconds=timeout):
_, response = api_client.quality_api.create_report(
rq_id=rq_id, _check_status=False, _parse_response=False
)
Expand All @@ -68,7 +68,7 @@ def compute_task_quality_report(

return report
case HTTPStatus.ACCEPTED:
sleep(sleep_interval)
sleep(check_interval)
continue
case _:
raise Exception(f"Unexpected response status: {response.status}")
Expand All @@ -91,8 +91,8 @@ def get_task(task_id: int) -> models.TaskRead:
def get_task_quality_report(
task_id: int,
*,
max_waiting_time: int = 10 * 60,
sleep_interval: float = 0.5,
timeout: int = Config.cvat_config.cvat_quality_retrieval_timeout,
check_interval: float = Config.cvat_config.cvat_quality_check_interval,
) -> models.QualityReport:
logger = logging.getLogger("app")

Expand All @@ -111,9 +111,7 @@ def get_task_quality_report(
)
return report

return compute_task_quality_report(
task_id, max_waiting_time=max_waiting_time, sleep_interval=sleep_interval
)
return compute_task_quality_report(task_id, timeout=timeout, check_interval=check_interval)


def get_quality_report_data(report_id: int) -> QualityReportData:
Expand Down

0 comments on commit 3746126

Please sign in to comment.