Skip to content

Commit c9317aa

Browse files
committed
refactor: improve data models
Make sure variant is available for report generation. This is done by reusing existing models better. We can still tidy this up further, but this gets us to a bit better place. Signed-off-by: James McCorrie <[email protected]>
1 parent 320b697 commit c9317aa

File tree

7 files changed

+57
-45
lines changed

7 files changed

+57
-45
lines changed

src/dvsim/flow/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
459459

460460
for item in self.cfgs:
461461
project = item.name
462-
item_results = [r for r in results if r.project == project]
462+
item_results = [r for r in results if r.block.name == project]
463463

464464
flow_results: FlowResults = item._gen_json_results(item_results)
465465
all_flow_results[project] = flow_results

src/dvsim/job/data.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from pydantic import BaseModel, ConfigDict
1616

1717
from dvsim.launcher.base import ErrorMessage, Launcher
18+
from dvsim.report.data import IPMeta, ToolMeta
1819

1920
__all__ = (
2021
"CompletedJobStatus",
@@ -28,8 +29,6 @@ class WorkspaceConfig(BaseModel):
2829

2930
model_config = ConfigDict(frozen=True, extra="forbid")
3031

31-
project: str
32-
"""Name of the project"""
3332
timestamp: str
3433
"""Time stamp of the run."""
3534

@@ -46,32 +45,31 @@ class JobSpec(BaseModel):
4645

4746
model_config = ConfigDict(frozen=True, extra="forbid")
4847

48+
name: str
49+
"""Name of the job"""
50+
4951
job_type: str
5052
"""Deployment type"""
51-
5253
target: str
5354
"""run phase [build, run, ...]"""
54-
flow: str
55-
"""Name of the flow config (e.g. tl_agent)"""
56-
tool: str
57-
"""EDA tool used"""
5855

59-
name: str
60-
"""Name of the job"""
6156
seed: int | None
6257
"""Seed if there is one."""
6358

6459
full_name: str
6560
"""Full name disambiguates across multiple cfg being run (example:
6661
'aes:default', 'uart:default' builds.
6762
"""
68-
6963
qual_name: str
7064
"""Qualified name disambiguates the instance name with other instances
7165
of the same class (example: 'uart_smoke' reseeded multiple times
7266
needs to be disambiguated using the index -> '0.uart_smoke'.
7367
"""
7468

69+
block: IPMeta
70+
"""IP block metadata."""
71+
tool: ToolMeta
72+
"""Tool used in the simulation run."""
7573
workspace_cfg: WorkspaceConfig
7674
"""Workspace configuration."""
7775

@@ -119,15 +117,20 @@ class CompletedJobStatus(BaseModel):
119117

120118
model_config = ConfigDict(frozen=True, extra="forbid")
121119

122-
project: str
123-
"""Name of the project"""
124-
job_type: str
125-
"""Deployment type"""
126120
name: str
127121
"""Name of the job"""
122+
job_type: str
123+
"""Deployment type"""
128124
seed: int | None
129125
"""Seed if there is one."""
130126

127+
block: IPMeta
128+
"""IP block metadata."""
129+
tool: ToolMeta
130+
"""Tool used in the simulation run."""
131+
workspace_cfg: WorkspaceConfig
132+
"""Workspace configuration."""
133+
131134
full_name: str
132135
"""Full name disambiguates across multiple cfg being run (example:
133136
'aes:default', 'uart:default' builds.

src/dvsim/job/deploy.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from dvsim.job.time import JobTime
1818
from dvsim.launcher.base import Launcher
1919
from dvsim.logging import log
20+
from dvsim.report.data import IPMeta, ToolMeta
2021
from dvsim.tool.utils import get_sim_tool_plugin
2122
from dvsim.utils import (
2223
clean_odirs,
@@ -101,40 +102,46 @@ def __init__(self, sim_cfg: "SimCfg") -> None:
101102
# Construct the job's command.
102103
self.cmd = self._construct_cmd()
103104

104-
self.workspace_cfg = WorkspaceConfig(
105-
project=sim_cfg.name,
106-
project_root=sim_cfg.proj_root,
107-
scratch_root=Path(sim_cfg.scratch_root),
108-
scratch_path=Path(sim_cfg.scratch_path),
109-
timestamp=sim_cfg.args.timestamp,
110-
)
111-
112105
def get_job_spec(self) -> "JobSpec":
113106
"""Get the job spec for this deployment."""
114107
return JobSpec(
108+
name=self.name,
115109
job_type=self.__class__.__name__,
116110
target=self.target,
117-
flow=self.flow,
118-
tool=self.sim_cfg.tool,
119-
name=self.name,
120111
seed=getattr(self, "seed", None),
121112
full_name=self.full_name,
122113
qual_name=self.qual_name,
123-
workspace_cfg=self.workspace_cfg,
114+
block=IPMeta(
115+
name=self.sim_cfg.name,
116+
variant=self.sim_cfg.variant,
117+
commit=self.sim_cfg.revision,
118+
branch=self.sim_cfg.branch,
119+
url="",
120+
),
121+
tool=ToolMeta(
122+
name=self.sim_cfg.tool,
123+
version="",
124+
),
125+
workspace_cfg=WorkspaceConfig(
126+
timestamp=self.sim_cfg.args.timestamp,
127+
project_root=self.sim_cfg.proj_root,
128+
scratch_root=Path(self.sim_cfg.scratch_root),
129+
scratch_path=Path(self.sim_cfg.scratch_path),
130+
),
124131
dependencies=[d.full_name for d in self.dependencies],
132+
needs_all_dependencies_passing=self.needs_all_dependencies_passing,
125133
weight=self.weight,
126134
timeout_mins=self.get_timeout_mins(),
127135
cmd=self.cmd,
128136
exports=self.exports,
129137
dry_run=self.dry_run,
130138
interactive=self.sim_cfg.interactive,
131139
gui=self.gui,
132-
needs_all_dependencies_passing=self.needs_all_dependencies_passing,
133-
pre_launch=self.pre_launch(),
134-
post_finish=self.post_finish(),
135140
odir=self.odir,
136-
links=self.sim_cfg.links,
137141
log_path=Path(f"{self.odir}/{self.target}.log"),
142+
links=self.sim_cfg.links,
143+
pre_launch=self.pre_launch(),
144+
post_finish=self.post_finish(),
138145
pass_patterns=self.pass_patterns,
139146
fail_patterns=self.fail_patterns,
140147
)

src/dvsim/launcher/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self, job_spec: "JobSpec") -> None:
107107
Launcher.workspace_prepared = True
108108

109109
# One-time preparation of the workspace, specific to the cfg.
110-
project = workspace_cfg.project
110+
project = job_spec.block.name
111111
if project not in Launcher.workspace_prepared_for_cfg:
112112
self.prepare_workspace_for_cfg(workspace_cfg)
113113
Launcher.workspace_prepared_for_cfg.add(project)
@@ -339,7 +339,7 @@ def _find_patterns(patterns: Sequence[str], line: str) -> Sequence[str] | None:
339339
# since it is devoid of the delays incurred due to infrastructure and
340340
# setup overhead.
341341

342-
plugin = get_sim_tool_plugin(tool=self.job_spec.tool)
342+
plugin = get_sim_tool_plugin(tool=self.job_spec.tool.name)
343343

344344
try:
345345
time, unit = plugin.get_job_runtime(log_text=lines)

src/dvsim/launcher/lsf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ def _do_launch(self) -> None:
214214
job_array += "%100"
215215

216216
# TODO: This needs to be moved to a HJson.
217-
if self.job_spec.tool == "vcs":
217+
if self.job_spec.tool.name == "vcs":
218218
job_rusage = "'rusage[vcssim=1,vcssim_dynamic=1:duration=1]'"
219219

220-
elif self.job_spec.tool == "xcelium":
220+
elif self.job_spec.tool.name == "xcelium":
221221
job_rusage = "'rusage[xcelium=1,xcelium_dynamic=1:duration=1]'"
222222

223223
else:

src/dvsim/launcher/nc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def create_run_sh(self, full_path, cmd) -> None:
5353
pathlib.Path(run_file).chmod(0o755)
5454

5555
def get_submit_cmd(self):
56-
exetool = self.job_spec.tool
56+
exetool = self.job_spec.tool.name
5757
job_name = self.job_spec.full_name
5858
cmd = self.job_spec.cmd
5959
odir = self.job_spec.odir

src/dvsim/scheduler.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,20 @@ def on_signal(signal_received: int, _: FrameType | None) -> None:
237237

238238
results.append(
239239
CompletedJobStatus(
240-
project=job_spec.workspace_cfg.project,
241-
job_type=job_spec.job_type,
242240
name=job_spec.name,
241+
job_type=job_spec.job_type,
243242
seed=job_spec.seed,
243+
block=job_spec.block,
244+
tool=job_spec.tool,
245+
workspace_cfg=job_spec.workspace_cfg,
244246
full_name=name,
245247
qual_name=job_spec.qual_name,
246248
target=job_spec.target,
247-
status=status,
248-
fail_msg=launcher.fail_msg,
249+
log_path=job_spec.log_path,
249250
job_runtime=launcher.job_runtime.with_unit("s").get()[0],
250251
simulated_time=launcher.simulated_time.with_unit("us").get()[0],
251-
log_path=job_spec.log_path,
252+
status=status,
253+
fail_msg=launcher.fail_msg,
252254
)
253255
)
254256

@@ -263,7 +265,7 @@ def add_to_scheduled(self, jobs: Mapping[str, JobSpec]) -> None:
263265
"""
264266
for full_name, job_spec in jobs.items():
265267
target_dict = self._scheduled.setdefault(job_spec.target, {})
266-
cfg_list = target_dict.setdefault(job_spec.flow, [])
268+
cfg_list = target_dict.setdefault(job_spec.block.name, [])
267269

268270
if job_spec not in cfg_list:
269271
cfg_list.append(full_name)
@@ -272,7 +274,7 @@ def _unschedule_item(self, job_name: str) -> None:
272274
"""Remove deploy item from the schedule."""
273275
job = self._jobs[job_name]
274276
target_dict = self._scheduled[job.target]
275-
cfg_list = target_dict.get(job.flow)
277+
cfg_list = target_dict.get(job.block.name)
276278

277279
if cfg_list is not None:
278280
with contextlib.suppress(ValueError):
@@ -281,7 +283,7 @@ def _unschedule_item(self, job_name: str) -> None:
281283
# When all items in _scheduled[target][cfg] are finally removed,
282284
# the cfg key is deleted.
283285
if not cfg_list:
284-
del target_dict[job.flow]
286+
del target_dict[job.block.name]
285287

286288
def _enqueue_successors(self, job_name: str | None = None) -> None:
287289
"""Move an item's successors from _scheduled to _queued.
@@ -363,7 +365,7 @@ def _get_successors(self, job_name: str | None = None) -> Sequence[str]:
363365
if target is None:
364366
return []
365367

366-
cfgs = {job.flow}
368+
cfgs = {job.block.name}
367369

368370
# Find item's successors that can be enqueued. We assume here that
369371
# only the immediately succeeding target can be enqueued at this

0 commit comments

Comments
 (0)