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

PresetDefinition.with_additional_config bugfix #3987

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion python_modules/dagster/dagster/core/definitions/preset.py
Expand Up @@ -199,10 +199,11 @@ def with_additional_config(self, run_config):
if run_config is None:
return self
else:
initial_config = self.run_config or {}
return PresetDefinition(
name=self.name,
solid_selection=self.solid_selection,
mode=self.mode,
tags=self.tags,
run_config=deep_merge_dicts(self.run_config, run_config),
run_config=deep_merge_dicts(initial_config, run_config),
)
Expand Up @@ -237,3 +237,22 @@ def a_pipeline():
# preset overwrites pipeline def
assert "defs" in pipeline_run.tags
assert pipeline_run.tags["defs"] == "preset"


@pytest.mark.parametrize("initial_run_config", [{"foo": "bar"}, None])
def test_with_additional_config(initial_run_config):
# Given: an initial preset with a run config or no run config
preset_def = PresetDefinition("example_with_config", run_config=initial_run_config)

# And: new config to be added
new_config = {"fizz": "buzz"}

# When: additional config is added
new_preset_def = preset_def.with_additional_config(new_config)

# Then: the new preset is a new preset object
assert id(preset_def) != id(new_preset_def)

# And: the preset has the expected new config
new_full_config = {"foo": "bar", "fizz": "buzz"} if initial_run_config else new_config
assert new_preset_def == PresetDefinition("example_with_config", run_config=new_full_config)