Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions src/dvsim/job/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

# A list of jobs on which this job depends.
self.dependencies = []
Expand Down Expand Up @@ -106,6 +110,32 @@ 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", {})

# Get commit and commit_short arguments to pass to JobSpec. We don't
# necessarily know that self.sim_cfg is actually a SimCfg object, so it
# might not have them defined. If it doesn't, we can't generate a
# meaningful job spec.
commit: str = self.sim_cfg.commit
commit_short: str = self.sim_cfg.commit_short
if not (commit and commit_short):
msg = (
"Cannot generate job spec. FlowCfg object "
"commit/commit_short is {commit}/{commit_short}."
)
raise TypeError(msg)

# The FlowCfg object in self.sim_cfg had better have a "tool" value,
# otherwise we won't know how to deploy anything.
tool = getattr(self.sim_cfg, "tool", None)
if not isinstance(tool, str):
msg = (
"Cannot generate job spec because sim_cfg does not have a "
'string for its "tool" variable.'
)
raise TypeError(msg)

return JobSpec(
name=self.name,
job_type=self.__class__.__name__,
Expand All @@ -115,15 +145,15 @@ def get_job_spec(self) -> "JobSpec":
qual_name=self.qual_name,
block=IPMeta(
name=self.sim_cfg.name,
variant=self.sim_cfg.variant,
commit=self.sim_cfg.commit,
commit_short=self.sim_cfg.commit_short,
variant=self._variant,
commit=commit,
commit_short=commit_short,
branch=self.sim_cfg.branch,
url="",
revision_info=self.sim_cfg.revision,
),
tool=ToolMeta(
name=self.sim_cfg.tool,
name=tool,
version="",
),
workspace_cfg=WorkspaceConfig(
Expand All @@ -143,7 +173,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,
pre_launch=self.pre_launch(),
post_finish=self.post_finish(),
pass_patterns=self.pass_patterns,
Expand Down
Loading