Skip to content

Conversation

@yakov-g
Copy link
Collaborator

@yakov-g yakov-g commented Dec 18, 2025

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 --address cli param
gunicorn takes address only from ADDRESS env 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.

  • Server startup:
    • setup_options: When --address is provided, sets os.environ["ADDRESS"] to the CLI value.
    • gunicorn/gunicorn.conf.py: Change bind to os.environ["ADDRESS"] (require ADDRESS env var).
    • entry_point.py: Use setup_options() and ArgumentsOptions.SERVER to decide between main_gunicorn() and main().
  • Tests:
    • Functional tests: capture and assert against stdout + stderr; helpers return both streams.
    • Unit tests: add coverage for --address setting ADDRESS; reorganize tests under TestSetupOptions.

Written by Cursor Bugbot for commit 61a0609. This will update automatically on new commits. Configure here.

# Override env var from CLI parameter.
# Now only ADDRESS is supported.
if getattr(options, "address", None):
os.environ["ADDRESS"] = options.address
Copy link

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)

Fix in Cursor Fix in Web

Copy link
Collaborator Author

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.

Copy link

@cursor cursor bot left a 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

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()

Fix in Cursor Fix in Web


@engprod-2
Copy link

engprod-2 bot commented Dec 18, 2025

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.

Copy link

@GunnerGlory GunnerGlory left a 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

@devexp-slackbot
Copy link

Label Needs Review: GenAI Systems was removed because @s-gavrenkov is part of GenAI Systems domain.

@yakov-g yakov-g merged commit b30534d into master Dec 18, 2025
23 checks passed
@engprod-2 engprod-2 bot deleted the yakov/raptor-15444-fix-address-env-var-assignment branch December 18, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants