-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix worker to load multiple challenges in dev env #2277
Conversation
@@ -38,8 +39,8 @@ | |||
"DJANGO_SETTINGS_MODULE", "settings.dev" | |||
) | |||
DJANGO_SERVER = os.environ.get("DJANGO_SERVER", "localhost") | |||
LIMIT_CONCURRENT_SUBMISSION_PROCESSING = os.environ.get( | |||
"LIMIT_CONCURRENT_SUBMISSION_PROCESSING" | |||
LIMIT_CONCURRENT_SUBMISSION_PROCESSING = eval( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of eval()
, it would definitely be a better idea to do int()
since this is always going to be integer. By doing eval()
, you are opening doors for bugs later in the codebase.
if isinstance(challenge_module, ModuleType): | ||
return | ||
else: | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why exiting the process? So basically what will happen here is that if the module is not loaded then the process will exit without showing any error. This doesn't sound right to me.
@@ -249,6 +250,7 @@ def extract_challenge_data(challenge, phases): | |||
CHALLENGE_IMPORT_STRING.format(challenge_id=challenge.id) | |||
) | |||
EVALUATION_SCRIPTS[challenge.id] = challenge_module | |||
return challenge_module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I don't think I understand exactly how returning the challenge module here will help solve the problem of loading multiple modules. Can you please elaborate more on how this is solving the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a temporary hack but I found a permanent fix for this while loading the modules dunamically: https://docs.python.org/3/library/importlib.html#importlib.invalidate_caches
Closing this PR. |
This PR fixes -
CHALLENGE_PK
from docker.env file to load multiple challenges in a single worker for dev env.