Skip to content
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

[AGENT-6608][AGENT-6612][AGENT-6613] Add use_datarobot_predict and time series args to server and score command parsers. #1240

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kijimoshib
Copy link

This repository is public. Do not put here any private DataRobot or customer's data: code, datasets, model artifacts, .etc.

Rationale

The changes ensure that time series parameters:

  • Only work with the score command
  • Require --use-datarobot-predict flag
  • Support proper ISO-8601 timestamp validation
  • Have proper mutually exclusive options validation
  • Are properly passed through the entire pipeline

Summary

Here's a summary of the main changes to implement time series parameters:

  1. args_parser.py:

    • Added time series validation to only allow in score command
    • Modified _reg_arg_time_series to check command type
    • Updated register_args to only attach time series args to score_parser
    • Added command validation in verify_options
  2. drum_score_adapter.py:

    • Added new time series parameters:
      • forecast_point
      • predictions_start_date
      • predictions_end_date
    • Added documentation for new parameters
    • Added instance variables for time series parameters
  3. predict_mixin.py:

    • Added request.args as param to predict

@devexp-slackbot
Copy link

The Needs Review labels were added based on the following file changes.

Team @datarobot/core-modeling (#core-modeling) was assigned because of changes in files:

custom_model_runner/datarobot_drum/drum/adapters/cli/drum_score_adapter.py
custom_model_runner/datarobot_drum/drum/args_parser.py
custom_model_runner/datarobot_drum/drum/drum.py
custom_model_runner/datarobot_drum/drum/enum.py
custom_model_runner/datarobot_drum/drum/root_predictors/drum_server_utils.py
custom_model_runner/datarobot_drum/drum/root_predictors/predict_mixin.py
custom_model_runner/datarobot_drum/resource/pipelines/prediction_pipeline.json.j2
custom_model_runner/datarobot_drum/resource/pipelines/prediction_server_pipeline.json.j2

Team @datarobot/custom-models (#custom-models) was assigned because of changes in files:

custom_model_runner/datarobot_drum/drum/adapters/cli/drum_score_adapter.py
custom_model_runner/datarobot_drum/drum/args_parser.py
custom_model_runner/datarobot_drum/drum/drum.py
custom_model_runner/datarobot_drum/drum/enum.py
custom_model_runner/datarobot_drum/drum/root_predictors/drum_server_utils.py
custom_model_runner/datarobot_drum/drum/root_predictors/predict_mixin.py
custom_model_runner/datarobot_drum/resource/pipelines/prediction_pipeline.json.j2
custom_model_runner/datarobot_drum/resource/pipelines/prediction_server_pipeline.json.j2
tests/unit/datarobot_drum/drum/test_args_parser.py
tests/unit/datarobot_drum/drum/test_drum.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.

@kijimoshib kijimoshib changed the title [AGENT-6608][AGENT-6612][AGENT-6613] Add use_datarobot_predict ang time series args to server and score command parsers. [AGENT-6608][AGENT-6612][AGENT-6613] Add use_datarobot_predict and time series args to server and score command parsers. Feb 1, 2025
Copy link
Contributor

@akshoop akshoop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM Core Modeling

@akshoop
Copy link
Contributor

akshoop commented Feb 3, 2025

CC @elatt for awareness

@devexp-slackbot
Copy link

Label Needs Review: Custom Models was removed because @yakov-g is part of Custom Models domain.

def _reg_arg_time_series(*parsers):
def require_both_dates(arg):
# First check if this is score command
if ArgumentsOptions.SCORE not in sys.argv[1]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commonly how we do this type of argument validation in DRUM, e.g. we manually parse through sys.argv looking for other options? I see you doing this below but this will break down if there is a mixture of things set as env vars and things set and CLI arguments right?

If this is the existing pattern then so-be-it but if this is the first time we have such interdependencies may I suggest instead to let the args all get parsed (and only include validation that is local to the specific flag, such as parsing ISO-8601 format) and then verify_options() is the place to make sure the set of options as a whole are logically consistent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think it breaks down if users do stuff like --myflag=12356 vs --myflag 123456 where I think Python's argparse will accept both styles equally? So yeah, I think it is always best to do pure argument parsing in one phase and then logical validation in a second phase.

Comment on lines +1285 to +1295
# Add validation for time series args requiring use_datarobot_predict
time_series_args = ["forecast_point", "predictions_start_date", "predictions_end_date"]
if any(getattr(options, arg, None) is not None for arg in time_series_args):
if options.subparser_name != ArgumentsOptions.SCORE:
print("\nError: Time series arguments can only be used with the score command")
exit(1)
if not getattr(options, "use_datarobot_predict", False):
print(
"\nError: Time series arguments require --use-datarobot-predict to be enabled"
)
exit(1)
Copy link
Member

@elatt elatt Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this get moved into a helper function: CMRunnerArgsRegistry.verify_timeseries_args(...)

Copy link
Member

@elatt elatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor note about CLI arg verification style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants