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

symphony/orchestration + symphony/runtime: users can specify artifact paths on...

symphony/orchestration + symphony/runtime: users can specify artifact paths on instantiation to create artifacts after simulation
parent 163081e5
...@@ -28,6 +28,7 @@ import shutil ...@@ -28,6 +28,7 @@ import shutil
import typing import typing
import itertools import itertools
import copy import copy
import uuid
from simbricks.utils import base as util_base from simbricks.utils import base as util_base
from simbricks.orchestration.system import base as sys_base from simbricks.orchestration.system import base as sys_base
from simbricks.orchestration.system import pcie as sys_pcie from simbricks.orchestration.system import pcie as sys_pcie
...@@ -85,12 +86,16 @@ class Instantiation(): ...@@ -85,12 +86,16 @@ class Instantiation():
self._id = next(self.__id_iter) self._id = next(self.__id_iter)
self.simulation: sim_base.Simulation = sim self.simulation: sim_base.Simulation = sim
self.env: InstantiationEnvironment | None = None self.env: InstantiationEnvironment | None = None
self.artifact_name: str = f"simbricks-artifact-{str(uuid.uuid4())}.zip"
self.artifact_paths: list[str] = []
self._executor: command_executor.Executor | None = None self._executor: command_executor.Executor | None = None
self._create_checkpoint: bool = False self._create_checkpoint: bool = False
self._restore_checkpoint: bool = False self._restore_checkpoint: bool = False
self._preserve_checkpoints: bool = True self._preserve_checkpoints: bool = True
self.preserve_tmp_folder: bool = False self.preserve_tmp_folder: bool = False
# NOTE: temporary data structure
self._socket_per_interface: dict[sys_base.Interface, Socket] = {} self._socket_per_interface: dict[sys_base.Interface, Socket] = {}
# NOTE: temporary data structure
self._sim_dependency: ( self._sim_dependency: (
dict[sim_base.Simulator, set[sim_base.Simulator]] | None dict[sim_base.Simulator, set[sim_base.Simulator]] | None
) = None ) = None
...@@ -105,6 +110,10 @@ class Instantiation(): ...@@ -105,6 +110,10 @@ class Instantiation():
if self._executor is None: if self._executor is None:
raise Exception("you must set an executor") raise Exception("you must set an executor")
return self._executor return self._executor
@property
def create_artifact(self) -> bool:
return len(self.artifact_paths) > 0
@executor.setter @executor.setter
def executor(self, executor: command_executor.Executor): def executor(self, executor: command_executor.Executor):
...@@ -330,9 +339,12 @@ class Instantiation(): ...@@ -330,9 +339,12 @@ class Instantiation():
) )
self._restore_checkpoint = restore_checkpoint self._restore_checkpoint = restore_checkpoint
# TODO: this needs fixing...
def copy(self) -> Instantiation: def copy(self) -> Instantiation:
cop = Instantiation(sim=self.simulation) cop = Instantiation(sim=self.simulation)
cop.simulation = copy.deepcopy(self.simulation) # maybe there is a smarter way of achieving this... cop.simulation = copy.deepcopy(self.simulation) # maybe there is a smarter way of achieving this...
cop.artifact_name = self.artifact_name
cop.artifact_paths = self.artifact_paths
cop._create_checkpoint = self._create_checkpoint cop._create_checkpoint = self._create_checkpoint
cop._restore_checkpoint = self._restore_checkpoint cop._restore_checkpoint = self._restore_checkpoint
cop._preserve_checkpoints = self._preserve_checkpoints cop._preserve_checkpoints = self._preserve_checkpoints
......
...@@ -27,7 +27,6 @@ import asyncio ...@@ -27,7 +27,6 @@ import asyncio
from simbricks.runtime import simulation_executor from simbricks.runtime import simulation_executor
from simbricks.runtime import command_executor from simbricks.runtime import command_executor
from simbricks.runtime.runs import base as run_base from simbricks.runtime.runs import base as run_base
from simbricks.orchestration.instantiation import base as inst_base
class LocalSimpleRuntime(run_base.Runtime): class LocalSimpleRuntime(run_base.Runtime):
......
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
import itertools
import shlex import shlex
import traceback import traceback
import abc import abc
from simbricks.utils import artifatcs as art
from simbricks.orchestration.simulation import output from simbricks.orchestration.simulation import output
from simbricks.orchestration.simulation import base as sim_base from simbricks.orchestration.simulation import base as sim_base
from simbricks.orchestration.instantiation import base as inst_base from simbricks.orchestration.instantiation import base as inst_base
...@@ -107,7 +107,11 @@ class SimulationBaseRunner(abc.ABC): ...@@ -107,7 +107,11 @@ class SimulationBaseRunner(abc.ABC):
pass pass
async def before_cleanup(self) -> None: async def before_cleanup(self) -> None:
pass if self._instantiation.create_artifact:
art.create_artifact(
artifact_name=self._instantiation.artifact_name,
paths_to_include=self._instantiation.artifact_paths
)
async def after_cleanup(self) -> None: async def after_cleanup(self) -> None:
pass pass
...@@ -125,7 +129,7 @@ class SimulationBaseRunner(abc.ABC): ...@@ -125,7 +129,7 @@ class SimulationBaseRunner(abc.ABC):
for sc in self._wait_sims: for sc in self._wait_sims:
await sc.wait() await sc.wait()
async def terminate_collect_sims(self) -> None: # output.SimulationOutput: async def terminate_collect_sims(self) -> output.SimulationOutput:
"""Terminates all simulators and collects output.""" """Terminates all simulators and collects output."""
self._out.set_end() self._out.set_end()
if self._verbose: if self._verbose:
......
...@@ -46,7 +46,7 @@ def _add_folder_to_zip(zip_file: zipfile.ZipFile, dir_path: str) -> None: ...@@ -46,7 +46,7 @@ def _add_folder_to_zip(zip_file: zipfile.ZipFile, dir_path: str) -> None:
# create an artifact containing all files and folders specified as paths. # create an artifact containing all files and folders specified as paths.
def create_artifact(artifact_name: str = "simbricks-artifact.zip", paths_to_include: list[str] = []) -> str: def create_artifact(artifact_name: str = "simbricks-artifact.zip", paths_to_include: list[str] = []) -> None:
if len(paths_to_include) < 1: if len(paths_to_include) < 1:
return return
......
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