Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ dependencies = [
"pyyaml>=6.0.2",
"tabulate>=0.9.0",
"toml>=0.10.2",
# Needed for Self while supporting Python 3.10
"typing-extensions>=4.15.0",
]

[project.optional-dependencies]
Expand Down
30 changes: 21 additions & 9 deletions src/dvsim/flow/one_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dvsim.job.deploy import CompileOneShot
from dvsim.job.status import JobStatus
from dvsim.logging import log
from dvsim.modes import BuildMode, Mode
from dvsim.modes import BuildMode
from dvsim.utils import rm_path


Expand Down Expand Up @@ -52,7 +52,7 @@ def __init__(self, flow_cfg_file, hjson_data, args, mk_config) -> None:
self.dut = ""
self.fusesoc_core = ""
self.ral_spec = ""
self.build_modes = []
self.build_modes: Sequence[BuildMode] = []
self.run_modes = []
self.regressions = []
self.max_msg_count = -1
Expand Down Expand Up @@ -109,16 +109,28 @@ def _expand(self) -> None:
def _purge(self) -> None:
assert self.scratch_path
log.info("Purging scratch path %s", self.scratch_path)
rm_path(self.scratch_path)
rm_path(Path(self.scratch_path))

def _create_objects(self) -> None:
# Create build and run modes objects
build_modes = Mode.create_modes(BuildMode, self.build_modes)
self.build_modes = build_modes
# Create build modes objects based on the names that were stored in
# self.build_modes by the superclass constructor's call to
# _merge_hjson.
#
# We've lied to the type checker about the type of self.build_modes,
# giving it the type that it will contain after this function is
# complete.
mode_dicts: list[dict[str, object]] = []
for mode_dict in self.build_modes:
if not isinstance(mode_dict, dict):
msg = f"Found a build mode item of {type(mode_dict)} when we expected a dict."
raise TypeError(msg)

mode_dicts.append(mode_dict)

self.build_modes = BuildMode.create_modes(mode_dicts)

# All defined build modes are being built, h
# ence extend all with the global opts.
for build_mode in build_modes:
# Extend all of the build modes (that are being built) with the global build_opts.
for build_mode in self.build_modes:
build_mode.build_opts.extend(self.build_opts)

def _print_list(self) -> None:
Expand Down
19 changes: 11 additions & 8 deletions src/dvsim/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"""Modes are an abstraction for a collection of options and configuration for a dvsim job."""

import sys
from collections.abc import Mapping, Sequence
from collections.abc import Iterable, Mapping, Sequence
from typing import Any

from typing_extensions import Self
Comment thread
AlexJones0 marked this conversation as resolved.
Resolved

from dvsim.logging import log

Expand Down Expand Up @@ -145,13 +148,13 @@ def merge_mode(self, mode: "Mode") -> None:

return True

@staticmethod
def create_modes(mode_type: "type[Mode]", mdicts: Mapping) -> Sequence["Mode"]:
"""Create modes of type mode_type.
@classmethod
def create_modes(cls, mdicts: Iterable[Mapping[str, Any]]) -> list[Self]:
"""Create modes of type cls.

Use the given list of raw dicts Process dependencies.

Return a list of modes objects.
Return a list of created objects.
"""

def merge_sub_modes(mode, parent, objs) -> None:
Expand Down Expand Up @@ -189,7 +192,7 @@ def merge_sub_modes(mode, parent, objs) -> None:

modes_objs = []
# create a default mode if available
default_mode = mode_type.get_default_mode()
default_mode = cls.get_default_mode()
if default_mode is not None:
modes_objs.append(default_mode)

Expand All @@ -198,7 +201,7 @@ def merge_sub_modes(mode, parent, objs) -> None:
for mdict in mdicts:
# Create a new item
new_mode_merged = False
new_mode = mode_type(mdict)
new_mode = cls(mdict)
for mode in modes_objs:
# Merge new one with existing if available
if mode.name == new_mode.name:
Expand All @@ -209,7 +212,7 @@ def merge_sub_modes(mode, parent, objs) -> None:
# Add the new mode to the list if not already appended
if not new_mode_merged:
modes_objs.append(new_mode)
mode_type.item_names.append(new_mode.name)
cls.item_names.append(new_mode.name)

# Pass 2: Recursively expand sub modes within parent modes
for mode in modes_objs:
Expand Down
4 changes: 2 additions & 2 deletions src/dvsim/sim/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ def _purge(self) -> None:

def _create_objects(self) -> None:
# Create build and run modes objects
self.build_modes = Mode.create_modes(BuildMode, self.build_modes)
self.run_modes = Mode.create_modes(RunMode, self.run_modes)
self.build_modes = BuildMode.create_modes(self.build_modes)
self.run_modes = RunMode.create_modes(self.run_modes)

# Walk through build modes enabled on the CLI and append the opts
for en_build_mode in self.en_build_modes:
Expand Down
4 changes: 3 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading