-
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
Contributor
Author
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. Good idea. To avoid scope creep in the PR, I've made an issue to track the fact we can do this as #162. |
||
|
|
||
| # 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
Contributor
Author
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. I think that probably makes sense (and I confess that my change here was "just making stuff work"). I've just opened up #163 to track doing it properly. |
||
| 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 😅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.
I'm not sure about the first bit: I think that the code in
deploy.pyonly modifies theFlowCfgin one place, which is the constructor ofCovAnalyze(a horrible hack! We can probably eventually get rid of that too)The idea of extracting the "stuff Deploy cares about" into a dictionary is a good one, though. Indeed, we can do even better than that because we can define some "DeployCfg" class and unconditionally fill everything out, so that the typing is a bit less magical.
Does that sound sensible to you? (as a follow-up)
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.
(I've made issue #161 to track the possible improvement)
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.
Ah, I grepped for
"self.sim_cfg"instead of"sim_cfg", so I missed that instance.I think the case that you mention (
sim_cfg.gui = Trueto enforce GUI mode for coverage analysis) could also be very easily fixed by just moving this attribute set onto the sim flow itself, before it creates theCovAnalyze(since it knows it needs it at this point). Even better, this should probably either be an implicit conversion with a clear warning log, or just aValueError/RuntimeErrorifself.gui == False. Definitely no need for this hacky code in the Deploy! 😄And with your reference to
DeployCfg, yes that seems reasonable - this is similar to the "more rigid type schemas" I mentioned in my second point, where we would use Pydantic models or dataclasses instead of an untyped dictionary.Thanks for making the issue!