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

Fix deep merge for existing env on work-pools #15325

Merged
merged 4 commits into from
Sep 11, 2024
Merged

Conversation

zzstoatzz
Copy link
Collaborator

currently on main, we correctly deep merge env like deployment | flow_run, but this merged result totally overwrites any hardcoded env defined directly on the work pool.

this PR makes sure we deep merge the result of deployment | flow_run with any env that may be defined on the work pool itself

@zzstoatzz zzstoatzz added the fix A fix for a bug in an existing feature label Sep 10, 2024
@zzstoatzz zzstoatzz self-assigned this Sep 10, 2024
Copy link

codspeed-hq bot commented Sep 10, 2024

CodSpeed Performance Report

Merging #15325 will not alter performance

Comparing deep-merge-logic (fa027b5) with main (3a7b80a)

Summary

✅ 3 untouched benchmarks

@zzstoatzz zzstoatzz marked this pull request as ready for review September 11, 2024 00:32
Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

small request for a test tweak, otherwise this LGTM

src/prefect/server/models/workers.py Show resolved Hide resolved
tests/workers/test_base_worker.py Outdated Show resolved Hide resolved
Comment on lines +1778 to +1812
@pytest.mark.parametrize(
"work_pool_env, deployment_env, flow_run_env, expected_env",
[
(
{},
{"test-var": "foo"},
{"another-var": "boo"},
{"test-var": "foo", "another-var": "boo"},
),
(
{"A": "1", "B": "2"},
{"C": "3", "D": "4"},
{},
{"A": "1", "B": "2", "C": "3", "D": "4"},
),
(
{"A": "1", "B": "2"},
{"C": "42"},
{"C": "3", "D": "4"},
{"A": "1", "B": "2", "C": "3", "D": "4"},
),
(
{"A": "1", "B": "2"},
{"B": ""}, # will be treated as unset and not apply
{},
{"A": "1", "B": "2"},
),
],
ids=[
"flow_run_into_deployment",
"deployment_into_work_pool",
"flow_run_into_work_pool",
"try_overwrite_with_empty_str",
],
)
Copy link
Member

Choose a reason for hiding this comment

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

I like this.

@kevingrismore
Copy link
Contributor

Since this is a worker change, does this (and the previous change, probably) need to be written again for the base push pool worker so push pool behavior is consistent with this?

@zzstoatzz
Copy link
Collaborator Author

Since this is a worker change, does this (and the previous change, probably) need to be written again for the base push pool worker so push pool behavior is consistent with this?

yes, i would say that is likely. great callout

@zzstoatzz zzstoatzz enabled auto-merge (squash) September 11, 2024 15:13
@zzstoatzz zzstoatzz merged commit ee44aaa into main Sep 11, 2024
30 checks passed
@zzstoatzz zzstoatzz deleted the deep-merge-logic branch September 11, 2024 15:13
@zzstoatzz zzstoatzz mentioned this pull request Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A fix for a bug in an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants