-
Notifications
You must be signed in to change notification settings - Fork 11
Tweak how we set up Deploy._variant_suffix #146
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,10 +73,14 @@ def __init__(self, sim_cfg: "SimCfg") -> None: | |
| self.sim_cfg = sim_cfg | ||
| self.flow = sim_cfg.name | ||
|
|
||
| if not hasattr(self.sim_cfg, "variant"): | ||
| self.sim_cfg.variant = "" | ||
| # The sim_cfg argument might be a SimCfg, in which case it might define | ||
| # a variant. We don't depend on this, though: if sim_cfg is an instance | ||
| # of some other subclass of FlowCfg, just take an empty "variant". | ||
| self._variant: str | None = getattr(self.sim_cfg, "variant", None) | ||
| if not (isinstance(self._variant, str) or self._variant is None): | ||
| raise TypeError("Unexpected type for variant") | ||
|
|
||
| self._variant_suffix = f"_{self.sim_cfg.variant}" if self.sim_cfg.variant else "" | ||
| self._variant_suffix = f"_{self._variant}" if self._variant is not None else "" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily for this PR: This might be a larger refactor, but there is an even better way to get rid of this So if we can figure out the right order (maybe it is difficult to do it with the chain of |
||
|
|
||
| # A list of jobs on which this job depends. | ||
| self.dependencies = [] | ||
|
|
@@ -106,6 +110,9 @@ def __init__(self, sim_cfg: "SimCfg") -> None: | |
|
|
||
| def get_job_spec(self) -> "JobSpec": | ||
| """Get the job spec for this deployment.""" | ||
| # If the FlowCfg object in self.sim_cfg doesn't have a links dictionary, default to {}. | ||
| links = getattr(self.sim_cfg, "links", {}) | ||
|
|
||
| return JobSpec( | ||
| name=self.name, | ||
| job_type=self.__class__.__name__, | ||
|
|
@@ -115,7 +122,7 @@ def get_job_spec(self) -> "JobSpec": | |
| qual_name=self.qual_name, | ||
| block=IPMeta( | ||
| name=self.sim_cfg.name, | ||
| variant=self.sim_cfg.variant, | ||
| variant=self._variant, | ||
| commit=self.sim_cfg.commit, | ||
| commit_short=self.sim_cfg.commit_short, | ||
| branch=self.sim_cfg.branch, | ||
|
|
@@ -143,7 +150,7 @@ def get_job_spec(self) -> "JobSpec": | |
| odir=self.odir, | ||
| renew_odir=self.renew_odir, | ||
| log_path=Path(f"{self.odir}/{self.target}.log"), | ||
| links=self.sim_cfg.links, | ||
| links=links, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: rather than default to an empty dict, should we instead make the links in the base Having not run any non-simulation flows - and so perhaps being completely misinformed - I would imagine that we would still want to see the logs and that the Launchers would still try to link the logs based on the status. Might it make more sense to define these links on the base |
||
| pre_launch=self.pre_launch(), | ||
| post_finish=self.post_finish(), | ||
| pass_patterns=self.pass_patterns, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
A question: from a cursory glance, it looks like this is the only case where a
Deployis modifying theFlowCfgthat is passed into it, correct? It looks like all other accesses are just to read attributes from the expanded config (so as to not pass around a bunch of args).In that case, to avoid the whole circular dependency, we could just extract the
sim_cfgattributes to a dictionary before giving just passing the dict to theDeployobjects instead. If we did this, we get a few benefits:dict.get(key, default)in the meantime instead ofgetattr(self.sim_cfg, attr, default), which I personally think looks a lot nicer to read when used everywhere 😅