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

Passing pipeline parameters as yaml config #2058

Conversation

avishniakov
Copy link
Contributor

@avishniakov avishniakov commented Nov 17, 2023

Describe changes

Add ability to pass in pipeline params as yaml config:

parameters:
  environment: production

Also added a RuntimeError for the cases when runtime config conflicts with YAML config (both steps and pipeline params) - @schustmi please confirm that this is acceptable or shall I revert to config-dominant silent mode.
Docs: https://app.gitbook.com/o/-MCl1Hlw9oU4xibZ-ymf/s/9oLgDi1mkUbwQiTmrEit/user-guide/advanced-guide/pipelining-features/configure-steps-pipelines#parameters-for-your-steps

BREAKING CHANGES

  • What passed silently before now throws an error (step/pipeline params configured in file and code differently)
# config.yaml
parameters:
    some_param: 24

steps:
  my_step:
    parameters:
      input_2: 42
# run.py
@step
def my_step(input_1: int, input_2: int) -> None:
    pass

@pipeline
def my_pipeline(some_param: int):
    # here an error will be raised since `input_2` is
    # `42` in config, but `43` was provided in the code
    my_step(input_1=42, input_2=43)

if __name__=="__main__":
    # here an error will be raised since `some_param` is
    # `24` in config, but `23` was provided in the code
    my_pipeline(23)

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • If my change requires a change to docs, I have updated the documentation accordingly.
  • If I have added an integration, I have updated the integrations table and the corresponding website section.
  • I have added tests to cover my changes.
  • I have based my new branch on develop and the open PR is targeting develop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (add details above)

@avishniakov avishniakov changed the base branch from main to develop November 17, 2023 09:40
@github-actions github-actions bot added internal To filter out internal PRs and issues enhancement New feature or request labels Nov 17, 2023
@avishniakov
Copy link
Contributor Author

avishniakov commented Nov 17, 2023

@schustmi , these changes clash a bit with what you created in #1638.
Can I have your perspective on this? I made an error to be raised if a user provides confusing configurations (step input is set in code and config), but before config value just dominated it. WDYT, shall I revert to the old behavior or update the test case instead?

@avishniakov avishniakov changed the title Feature/oss 2529 passing pipeline parameters as yaml and document Passing pipeline parameters as yaml config Nov 17, 2023
Copy link
Contributor

E2E template updates in examples/e2e have been pushed.

Copy link
Contributor

E2E template updates in examples/e2e have been pushed.

@avishniakov
Copy link
Contributor Author

@bcdurak @schustmi can you have a look?

step_name()

if __name__=="__main__":
pipeline_(param_name="value2")
Copy link
Contributor

Choose a reason for hiding this comment

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

This would also need to call with_options(config_file=...) to showcase the actual error right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

parameters_ = dict_utils.recursive_update(parameters_, from_file_)
if parameters_:
for k, v_runtime in kwargs.items():
if v_config := parameters_.get(k, None):
Copy link
Contributor

Choose a reason for hiding this comment

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

None or False might also be valid parameter values which will not get detected by this logic I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

if parameters_:
for k, v_runtime in kwargs.items():
if v_config := parameters_.get(k, None):
conflicting_parameters[k] = (v_config, v_runtime)
Copy link
Contributor

Choose a reason for hiding this comment

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

In the step you added an additional check if the config and runtime parameter are different, I think that also makes sense here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

for key, value in parameters.items():
if runtime_value := runtime_parameters.get(key, None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as for the pipeline, None/False/0/... as parameter values will probably not be included in these checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@bcdurak bcdurak left a comment

Choose a reason for hiding this comment

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

Great changes and it is nice that you added the explanation to the docs as well. From what I can see all seems good 👍

@avishniakov avishniakov requested a review from schustmi December 8, 2023 14:02
@avishniakov avishniakov merged commit d5a3aef into develop Dec 11, 2023
30 checks passed
@avishniakov avishniakov deleted the feature/OSS-2529-passing-pipeline-parameters-as-yaml-and-document branch December 11, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change enhancement New feature or request internal To filter out internal PRs and issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants