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

Add APISettings setting group #15701

Merged
merged 3 commits into from
Oct 15, 2024
Merged

Add APISettings setting group #15701

merged 3 commits into from
Oct 15, 2024

Conversation

desertaxle
Copy link
Member

@desertaxle desertaxle commented Oct 15, 2024

Reintroduces changes first introduced in #15580 with fixes to ensure nested models are included when calling .to_environment_variables().

See comments below for where this PR differs from #15580.

Comment on lines +482 to +492
for key in self.model_fields.keys():
if isinstance(child_settings := getattr(self, key), PrefectBaseSettings):
child_env = child_settings.to_environment_variables(
exclude_unset=exclude_unset,
include_secrets=include_secrets,
)
env_variables.update(child_env)
elif (value := env.get(key)) is not None:
env_variables[
f"{self.model_config.get('env_prefix')}{key.upper()}"
] = str(value)
Copy link
Member Author

Choose a reason for hiding this comment

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

The fix for to_environment_variables was to iterate over the model_fields because nested model changes weren't included when exclude_unset=True.

Comment on lines +495 to +500
@model_serializer(
mode="wrap", when_used="always"
) # TODO: reconsider `when_used` default for more control
def ser_model(
self, handler: SerializerFunctionWrapHandler, info: SerializationInfo
) -> Any:
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved the model serializer to PrefectBaseSettings to ensure all nested models respect include_secrets.

Copy link

codspeed-hq bot commented Oct 15, 2024

CodSpeed Performance Report

Merging #15701 will not alter performance

Comparing reintroduce-api-setting-group (3182b52) with main (fd8cef2)

Summary

✅ 3 untouched benchmarks

@desertaxle desertaxle marked this pull request as ready for review October 15, 2024 15:00
Copy link
Collaborator

@zzstoatzz zzstoatzz 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 a couple comments

src/prefect/cli/config.py Outdated Show resolved Hide resolved
src/prefect/utilities/collections.py Outdated Show resolved Hide resolved
@desertaxle desertaxle merged commit 245d718 into main Oct 15, 2024
30 checks passed
@desertaxle desertaxle deleted the reintroduce-api-setting-group branch October 15, 2024 15:29
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.

2 participants