-
Notifications
You must be signed in to change notification settings - Fork 5
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
introduce environment_variable_groups to Step class #160
base: master
Are you sure you want to change the base?
introduce environment_variable_groups to Step class #160
Conversation
@@ -38,6 +38,7 @@ def __init__( | |||
outputs: Iterable[Any] = (), | |||
mounts: Iterable[Mount] = (), | |||
environment_variables: Iterable[EnvironmentVariable] = (), | |||
environment_variable_groups: List[str] = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
environment_variable_groups: List[str] = [], | |
environment_variable_groups: Iterable[str] = (), |
Having a list as the type is too restrictive, and especially having a list as the default argument leads to unintuitive behavior.
@@ -68,6 +69,7 @@ def __init__( | |||
EnvironmentVariable, | |||
"name", | |||
) | |||
self.environment_variable_groups = environment_variable_groups |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.environment_variable_groups = environment_variable_groups | |
self.environment_variable_groups = list(environment_variable_groups) |
The argument can be listified here. Calling list()
ensures we take a copy of a list, or iterate an iterable into a new list.
Otherwise, doing
foo = []
s1 = Step(..., environment_variable_groups=foo)
s2 = Step(..., environment_variable_groups=foo)
foo.append("bar")
would end up the EVGs for both steps being modified.
That said, we could do better still:
self.environment_variable_groups = environment_variable_groups | |
self.environment_variable_groups = [str(evg) for evg in environment_variable_groups if evg] |
This would implicitly filter out falsy values, and ensure everything else actually is str
.
@@ -85,6 +87,7 @@ def parse(cls, data: SerializedDict) -> "Step": | |||
kwargs["stop_condition"] = kwargs.pop("stop-condition", None) | |||
kwargs["upload_store"] = kwargs.pop("upload-store", None) | |||
kwargs["resources"] = WorkloadResources.parse(kwargs.pop("resources", {})) | |||
kwargs["environment_variable_groups"] = kwargs.pop("environment-variable-groups", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As currently is, None
would not be a valid argument for Step()
. An empty tuple would be.
kwargs["environment_variable_groups"] = kwargs.pop("environment-variable-groups", None) | |
kwargs["environment_variable_groups"] = kwargs.pop("environment-variable-groups", ()) |
I want to make the environment_variable_groups setting accessible from the CLI and from the valohai yaml.
To achieve this, I have created a PR in valohai-cli as well (valohai-cli#323).
I could test my changes on valohai-cli and the local linting here on valohai-yaml, however, the API endpoint seems to validate with an older valohai-yaml version as well, causing an API validation error.