Skip to content

Commit f75f559

Browse files
Worker: Fix file URLs in submission worker for dev,test & prod environments(#2876)
* Fix file URLs in submission worker * Fix file URLs for dev and test environment
1 parent a8f52e1 commit f75f559

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
python_files=test*.py
33
DJANGO_SETTINGS_MODULE=settings.test
44
DJANGO_SERVER=django
5+
DJANGO_SERVER_PORT=8000
56
norecursedirs=env venv node_modules bower_components

scripts/workers/submission_worker.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
LIMIT_CONCURRENT_SUBMISSION_PROCESSING = os.environ.get(
4949
"LIMIT_CONCURRENT_SUBMISSION_PROCESSING"
5050
)
51+
DJANGO_SETTINGS_MODULE = os.environ.get(
52+
"DJANGO_SETTINGS_MODULE", "settings.dev"
53+
)
5154

5255
CHALLENGE_DATA_BASE_DIR = join(COMPUTE_DIRECTORY_PATH, "challenge_data")
5356
SUBMISSION_DATA_BASE_DIR = join(COMPUTE_DIRECTORY_PATH, "submission_files")
@@ -198,8 +201,14 @@ def create_dir_as_python_package(directory):
198201

199202

200203
def return_file_url_per_environment(url):
201-
base_url = f"http://{settings.DJANGO_SERVER}:{settings.DJANGO_SERVER_PORT}"
202-
url = "{0}{1}".format(base_url, url)
204+
if (
205+
DJANGO_SETTINGS_MODULE == "settings.dev"
206+
or DJANGO_SETTINGS_MODULE == "settings.test"
207+
):
208+
base_url = (
209+
f"http://{settings.DJANGO_SERVER}:{settings.DJANGO_SERVER_PORT}"
210+
)
211+
url = "{0}{1}".format(base_url, url)
203212
return url
204213

205214

0 commit comments

Comments
 (0)