-
Notifications
You must be signed in to change notification settings - Fork 88
[RAPTOR-15444] fix ADDRESS env var assignment from cli param #1807
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
[RAPTOR-15444] fix ADDRESS env var assignment from cli param #1807
Conversation
| # Override env var from CLI parameter. | ||
| # Now only ADDRESS is supported. | ||
| if getattr(options, "address", None): | ||
| os.environ["ADDRESS"] = options.address |
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.
Bug: Empty address string causes KeyError in gunicorn config
The condition if getattr(options, "address", None) uses truthiness checking, which evaluates to False for empty strings. If a user provides an empty address like --address "", the ADDRESS environment variable won't be set. Combined with the removal of the default fallback in gunicorn.conf.py (changing from os.environ.get("ADDRESS", "0.0.0.0:8080") to os.environ["ADDRESS"]), this causes a KeyError when gunicorn starts. Consider using an explicit is not None check instead of truthiness.
Additional Locations (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.
There are different sub parsers for drum:
drum score
drum server
address is not defined for all of them, so in this case I keep the current check.
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.
Bug: Double invocation of setup_options when not using gunicorn
When not using gunicorn mode, setup_options() is called twice: first in run_drum_server() to determine which path to take, and then again inside main() at line 127. This results in RuntimeParametersLoader.setup_environment_variables() and LazyLoadingHandler.setup_environment_variables_from_values_file() being executed twice, which could cause duplicate environment variable setup or other side effects. The old code only called main() directly which handled all setup internally.
custom_model_runner/datarobot_drum/drum/entry_point.py#L9-L18
datarobot-user-models/custom_model_runner/datarobot_drum/drum/entry_point.py
Lines 9 to 18 in b95ce22
| def run_drum_server(): | |
| options = setup_options() | |
| if ( | |
| options.subparser_name == ArgumentsOptions.SERVER | |
| and RuntimeParameters.has("DRUM_SERVER_TYPE") | |
| and str(RuntimeParameters.get("DRUM_SERVER_TYPE")).lower() == "gunicorn" | |
| ): | |
| main_gunicorn() | |
| else: | |
| main() |
61a0609 to
b95ce22
Compare
|
The Needs Review labels were added based on the following file changes. Team @datarobot/core-modeling (#predictive-ai) was assigned because of changes in files:custom_model_runner/datarobot_drum/drum/entry_point.py custom_model_runner/datarobot_drum/drum/gunicorn/gunicorn.conf.py custom_model_runner/datarobot_drum/drum/utils/setup.py tests/functional/test_runtime_parameters.py Team @datarobot/genai-systems (#genai-systems) was assigned because of changes in files:custom_model_runner/datarobot_drum/drum/entry_point.py custom_model_runner/datarobot_drum/drum/gunicorn/gunicorn.conf.py custom_model_runner/datarobot_drum/drum/utils/setup.py tests/functional/test_runtime_parameters.py tests/unit/datarobot_drum/drum/utils/test_setup.py If you think that there are some issues with ownership, please discuss with C&A domain at #sdtk slack channel and create PR to update DRCODEOWNERS\CODEOWNERS file. |
GunnerGlory
left a comment
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.
LGTM. Pending addressing the issue cursor found
|
Label Needs Review: GenAI Systems was removed because @s-gavrenkov is part of GenAI Systems domain. |
This repository is public. Do not put here any private DataRobot or customer's data: code, datasets, model artifacts, .etc.
Summary
This PR is related to moving drop in envs to use gunicorn as a server.
This means that all tests will be running using gunicorn (I will likely drop werkzeug start and testing in it overall)
But there is inconsistency:
werkzeug takes address only from
--addresscli paramgunicorn takes address only from
ADDRESSenv var.According to the best practices CLI param should take precedence over the env var. That's what this PR implements.
This PR doesn't move the envs to gunicorn, but I have this in a different PR and tests pass: #1659 (Java is weird case - it will pass after these chages will be released)
Rationale
Note
CLI --address now overrides ADDRESS, gunicorn binds using mandatory ADDRESS, and server selection is based on parsed options instead of argv.
setup_options: When--addressis provided, setsos.environ["ADDRESS"]to the CLI value.gunicorn/gunicorn.conf.py: Changebindtoos.environ["ADDRESS"](require ADDRESS env var).entry_point.py: Usesetup_options()andArgumentsOptions.SERVERto decide betweenmain_gunicorn()andmain().stdout + stderr; helpers return both streams.--addresssettingADDRESS; reorganize tests underTestSetupOptions.Written by Cursor Bugbot for commit 61a0609. This will update automatically on new commits. Configure here.