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

updating project config to be extendable #5

Merged
merged 4 commits into from
May 17, 2024

Conversation

rpmcginty
Copy link
Collaborator

@rpmcginty rpmcginty commented May 16, 2024

What's in this Change?

  • I have made project config extendable (by making StageConfig and GlobalConfig overridable).

you can still just use the plain old ProjectConfig class (fully backwards compatible). but if you would like to use your own project sepcific Stage config, you can do so using the following pattern.

class MyStageServiceConfig(BaseModel):
    service_name: str


class ExtendedStageConfig(StageConfig):
    service: MyStageServiceConfig


class ExtendedProjectConfig(BaseProjectConfig[GlobalConfig, ExtendedStageConfig]):
    pass

Testing

  • unit tests

@rpmcginty rpmcginty requested review from njmei and sheriferson May 16, 2024 23:18
pyproject.toml Show resolved Hide resolved
@@ -119,15 +126,17 @@ def get_env_base(node: constructs.Node) -> EnvBase:
return EnvBase.from_type_and_label(env_type=env_type, env_label=env_label)


def get_config(node: constructs.Node) -> StageConfig:
def get_config(
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed get_config is not included in __all__. Is that on purpose?
I am actually using it in app.py by importing from utils, but I can see that there might be a better pattern out there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch. I will add

@rpmcginty rpmcginty merged commit 44a7438 into main May 17, 2024
4 checks passed
@rpmcginty rpmcginty deleted the feature/improve-project-config branch May 17, 2024 19:12
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.

3 participants