File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
packages/examples/cvat/exchange-oracle Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 55from typing import Any
66
77import uvicorn
8+ from httpx import URL
89
910from src .chain .kvstore import register_in_kvstore
1011from src .core .config import Config
@@ -25,7 +26,27 @@ def apply_local_development_patches():
2526 - Generates ECDSA keys if not already present for local JWT signing,
2627 and sets the public key in `Config.human_app_config`.
2728 """
28- import src .utils .webhooks
29+ import src .handlers .job_creation
30+
31+ original_make_cvat_cloud_storage_params = (
32+ src .handlers .job_creation ._make_cvat_cloud_storage_params
33+ )
34+
35+ def patched_make_cvat_cloud_storage_params (bucket_info : BucketAccessInfo ) -> dict :
36+ original_host_url = bucket_info .host_url
37+
38+ if Config .development_config .cvat_in_docker :
39+ bucket_info .host_url = str (
40+ URL (original_host_url ).copy_with (host = Config .development_config .cvat_local_host )
41+ )
42+ try :
43+ return original_make_cvat_cloud_storage_params (bucket_info )
44+ finally :
45+ bucket_info .host_url = original_host_url
46+
47+ src .handlers .job_creation ._make_cvat_cloud_storage_params = (
48+ patched_make_cvat_cloud_storage_params
49+ )
2950
3051 def prepare_signed_message (
3152 escrow_address ,
Original file line number Diff line number Diff line change @@ -121,3 +121,7 @@ LOCALHOST_REPUTATION_ORACLE_URL=
121121PGP_PRIVATE_KEY =
122122PGP_PASSPHRASE =
123123PGP_PUBLIC_KEY_URL =
124+
125+
126+ # Development
127+ DEV_CVAT_IN_DOCKER =
Original file line number Diff line number Diff line change @@ -313,6 +313,12 @@ def _missing_(cls, value: str) -> Optional["Environment"]:
313313 return None
314314
315315
316+ class Development :
317+ cvat_in_docker = bool (int (os .environ .get ("CVAT_IN_DOCKER" , "0" )))
318+ # might be `host.docker.internal` or `172.22.0.1` if CVAT is running in docker
319+ cvat_local_host = os .environ .get ("CVAT_LOCAL_HOST" , "localhost" )
320+
321+
316322class Config :
317323 debug = to_bool (os .environ .get ("DEBUG" , "false" ))
318324 port = int (os .environ .get ("PORT" , 8000 ))
@@ -337,6 +343,7 @@ class Config:
337343 features = FeaturesConfig
338344 core_config = CoreConfig
339345 encryption_config = EncryptionConfig
346+ development_config = Development
340347
341348 @classmethod
342349 def is_development_mode (cls ) -> bool :
You can’t perform that action at this time.
0 commit comments