Unverified Commit bef618ad authored by Jakob Görgen's avatar Jakob Görgen
Browse files

fixed circular import issues

parent 8eb3a0ac
......@@ -27,7 +27,6 @@ import enum
import pathlib
import shutil
from simbricks.orchestration.utils import base as util_base
from simbricks.orchestration.simulation import base as sim_base
from simbricks.orchestration.system import base as sys_base
from simbricks.orchestration.runtime_new import command_executor
......@@ -77,11 +76,9 @@ class Instantiation(util_base.IdObj):
def __init__(
self,
simulation: sim_base.Simulation,
env: InstantiationEnvironment = InstantiationEnvironment(),
):
super().__init__()
self._simulation: sim_base.Simulation = simulation
self._env: InstantiationEnvironment = env
self._socket_per_interface: dict[sys_base.Interface, Socket] = {}
......@@ -216,10 +213,6 @@ class Instantiation(util_base.IdObj):
def shm_base_dir(self) -> str:
return pathlib.Path(self._env._shm_base).absolute()
def checkpointing_enabled(self) -> bool:
# TODO: not sure if needed wanted here like this
return self._simulation.checkpointing_enabled()
def create_cp(self) -> bool:
return self._env._create_cp
......@@ -294,7 +287,7 @@ class Instantiation(util_base.IdObj):
# TODO: fixme
def cfgtar_path(self, sim: Simulator) -> str:
return f'{self.workdir}/cfg.{sim.name}.tar'
return f"{self.workdir}/cfg.{sim.name}.tar"
def join_tmp_base(self, relative_path: str) -> str:
return self._join_paths(
......
......@@ -29,6 +29,7 @@ import shutil
import typing as tp
import abc
from simbricks.orchestration.simulation import output
from simbricks.orchestration.simulation import base as sim_base
from simbricks.orchestration.instantiation import base as inst_base
from simbricks.orchestration.runtime_new import command_executor
......@@ -50,7 +51,7 @@ class Run:
self._simulation: sim_base.Simulation = simulation
self._run_nr = next(self.__run_nr)
self._instantiation: inst_base.Instantiation = instantiation
self._output: sim_base.SimulationOutput | None = output
self._output: output.SimulationOutput | None = output
self._prereq: Run | None = prereq
self._job_id: int | None = job_id
"""Slurm job id."""
......
......@@ -31,6 +31,7 @@ import abc
from simbricks.orchestration.utils import graphlib
from simbricks.orchestration.simulation import output
from simbricks.orchestration.simulation import base as sim_base
from simbricks.orchestration.instantiation import base as inst_base
from simbricks.orchestration.runtime_new import command_executor
......@@ -43,7 +44,7 @@ class ExperimentBaseRunner(abc.ABC):
self._instantiation: inst_base.Instantiation = instantiation
self._verbose: bool = verbose
self._profile_int: int | None = None
self._out = sim_base.SimulationOutput(self._simulation)
self._out = output.SimulationOutput(self._simulation)
self._running: list[tuple[sim_base.Simulator, command_executor.SimpleComponent]] = []
self._sockets: list[tuple[command_executor.Executor, inst_base.Socket]] = []
self._wait_sims: list[command_executor.Component] = []
......@@ -152,7 +153,7 @@ class ExperimentBaseRunner(abc.ABC):
for sc in self._wait_sims:
await sc.wait()
async def terminate_collect_sims(self) -> sim_base.SimulationOutput:
async def terminate_collect_sims(self) -> output.SimulationOutput:
"""Terminates all simulators and collects output."""
self._out.set_end()
if self._verbose:
......@@ -187,7 +188,7 @@ class ExperimentBaseRunner(abc.ABC):
for (_, sc) in self._running:
await sc.sigusr1()
async def run(self) -> sim_base.SimulationOutput:
async def run(self) -> output.SimulationOutput:
profiler_task = None
try:
......
......@@ -27,11 +27,9 @@ import itertools
import time
import typing as tp
import simbricks.orchestration.system as sys_conf
from simbricks.orchestration.experiment import experiment_environment_new as exp_env
from simbricks.orchestration.instantiation import base as inst_base
from simbricks.orchestration.simulation import channel as sim_chan
from simbricks.orchestration.utils import base as utils_base
from simbricks.orchestration.runtime_new import command_executor
import simbricks.orchestration.instantiation.base as inst_base
import simbricks.orchestration.simulation.channel as sim_chan
import simbricks.orchestration.utils.base as utils_base
if tp.TYPE_CHECKING:
from simbricks.orchestration.simulation import (
......@@ -50,7 +48,7 @@ class Simulator(utils_base.IdObj):
self,
simulation: sim_base.Simulation,
name: str = "",
elative_executable_path: str = "",
relative_executable_path: str = "",
) -> None:
super().__init__()
self.name: str = name
......@@ -340,47 +338,3 @@ class Simulation(utils_base.IdObj):
def is_checkpointing_enabled(self) -> bool:
raise Exception("not implemented")
class SimulationOutput:
"""Manages an experiment's output."""
def __init__(self, sim: Simulation) -> None:
self._sim_name: str = sim.name
self._start_time: float = None
self._end_time: float = None
self._success: bool = True
self._interrupted: bool = False
self._metadata = exp.metadata
self._sims: dict[str, dict[str, str | list[str]]] = {}
def set_start(self) -> None:
self._start_time = time.time()
def set_end(self) -> None:
self._end_time = time.time()
def set_failed(self) -> None:
self._success = False
def set_interrupted(self) -> None:
self._success = False
self._interrupted = True
def add_sim(self, sim: Simulator, comp: command_executor.Component) -> None:
obj = {
"class": sim.__class__.__name__,
"cmd": comp.cmd_parts,
"stdout": comp.stdout,
"stderr": comp.stderr,
}
self._sims[sim.full_name()] = obj
def dump(self, outpath: str) -> None:
pathlib.Path(outpath).parent.mkdir(parents=True, exist_ok=True)
with open(outpath, "w", encoding="utf-8") as file:
json.dump(self.__dict__, file, indent=4)
def load(self, file: str) -> None:
with open(file, "r", encoding="utf-8") as fp:
for k, v in json.load(fp).items():
self.__dict__[k] = v
......@@ -20,15 +20,12 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import typing as tp
import simbricks.orchestration.system.base as system_base
import simbricks.orchestration.simulation.base as sim_base
from simbricks.orchestration.system import base as system_base
class Channel(sim_base.Simulator):
class Channel:
def __init__(self, e: sim_base.Simulation, chan: system_base.Channel):
super().__init__(e)
def __init__(self, chan: system_base.Channel):
self._synchronized: bool = True
self.sync_period: int = 500 # nano second
self.sys_channel: system_base.Channel = chan
......
......@@ -56,8 +56,9 @@ class HostSim(sim_base.Simulator):
def add(self, host: 'Host'):
self.hosts.append(host)
self.name = f'{self._id}'
self.experiment.add_host(self)
self.experiment.sys_sim_map[host] = self
# TODO: FIXME, call super method...
# self.experiment.add_host(self)
# self.experiment.sys_sim_map[host] = self
def config_str(self) -> str:
return []
......@@ -170,8 +171,8 @@ class Gem5Sim(HostSim):
f':latency={dev.channel.latency}ns'
f':sync_interval={chn_sim.sync_period}ns'
)
if cpu_type == 'TimingSimpleCPU' and: #TODO
cmd += ':sync'
# if cpu_type == 'TimingSimpleCPU' and: #TODO: FIXME
# cmd += ':sync'
cmd += ' '
return cmd
......
......@@ -65,8 +65,9 @@ class NICSim(PCIDevSim):
def add(self, nic: sys_conf.SimplePCIeNIC):
self.nics.append(nic)
# nic.sim = self
self.experiment.add_nic(self)
self.experiment.sys_sim_map[nic] = self
# TODO: FIXME, call super method...
#self.experiment.add_nic(self)
#self.experiment.sys_sim_map[nic] = self
self.name = f'{nic._id}'
def basic_args(self, env: ExpEnv, extra: tp.Optional[str] = None) -> str:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment