"scripts/vscode:/vscode.git/clone" did not exist on "3dd6420a4dc0234d4582cdda7e0252a2ce6d4722"
Commit c6d1fa2d authored by Jonas Kaufmann's avatar Jonas Kaufmann
Browse files

symphony: orchestration: fix multiple issues that pop up when invoking simbricks-run

- import errors
- simulators being inserted into dependency topology multiple times
- some uninitialized variables
- missing or wrong arguments in function calls
parent 03db98ba
......@@ -272,7 +272,7 @@ class Instantiation:
# Experiment does not define any simulation fragments, so
# implicitly, we create one fragment that spans the whole simulation
self._simulation_fragment = inst_fragment.Fragment()
self._simulation_fragment.add_simulators(self.simulation.all_simulators())
self._simulation_fragment.add_simulators(*self.simulation.all_simulators())
else:
fragments = [
fragment
......
......@@ -24,17 +24,19 @@ instantiated components like simulators that determines the order to start them
in."""
from __future__ import annotations
import typing
import enum
import typing
from simbricks.orchestration.instantiation import proxy as inst_proxy
from simbricks.orchestration.instantiation import socket as inst_socket
from simbricks.orchestration.simulation import base as sim_base
if typing.TYPE_CHECKING:
from simbricks.orchestration.simulation import base as sim_base
from simbricks.orchestration.instantiation import base as inst_base
from simbricks.orchestration.system import base as sys_base
from simbricks.orchestration.instantiation import socket as inst_socket
from simbricks.orchestration.instantiation import proxy as inst_proxy
class TopologyComponentType(enum.Enum):
class TopologyComponentType(enum.Enum):
SIMULATOR = enum.auto()
PROXY = enum.auto()
......@@ -49,6 +51,25 @@ class TopologyComponent:
self.type = type
self.value = value
def get_simulator(self) -> sim_base.Simulator:
if self.type != TopologyComponentType.SIMULATOR:
raise RuntimeError("Value stored is not a simulator")
return typing.cast(sim_base.Simulator, self.value)
def get_proxy(self) -> inst_proxy.Proxy:
if self.type != TopologyComponentType.PROXY:
raise RuntimeError("Value stored is not a proxy")
return typing.cast(inst_proxy.Proxy, self.value)
def __repr__(self) -> str:
match self.type:
case TopologyComponentType.SIMULATOR:
return str(("sim", self.get_simulator()))
case TopologyComponentType.PROXY:
return str(("proxy", self.get_proxy()))
case _:
raise RuntimeError("Unhandles type")
SimulationDependencyTopology = typing.NewType(
"SimulationDependencyTopology",
......@@ -66,7 +87,7 @@ def build_simulation_topology(
# start first before simulator can start
sim_dependencies: SimulationDependencyTopology = {}
def insert_dependency(topo_comp_a: TopologyComponent, depends_on: TopologyComponent):
def insert_dependency(topo_comp_a: TopologyComponent, depends_on: TopologyComponent) -> None:
if depends_on in sim_dependencies:
if topo_comp_a in sim_dependencies[depends_on]:
# TODO: FIXME
......@@ -86,7 +107,7 @@ def build_simulation_topology(
topo_comp_b: TopologyComponent,
) -> None:
a_sock = topo_comp_a.value.supported_socket_types(interface=inf_a)
b_sock = topo_comp_a.value.supported_socket_types(interface=inf_b)
b_sock = topo_comp_b.value.supported_socket_types(interface=inf_b)
if a_sock != b_sock:
if len(a_sock) == 0 or len(b_sock) == 0:
......@@ -126,6 +147,8 @@ def build_simulation_topology(
)
# build dependency graph
topo_comp_sims: dict[sim_base.Simulator, TopologyComponent] = {}
topo_comp_proxies: dict[inst_proxy.Proxy, TopologyComponent] = {}
for sim in instantiation.fragment.all_simulators():
for comp in sim.components():
for sim_inf in comp.interfaces():
......@@ -134,22 +157,35 @@ def build_simulation_topology(
# simulator
continue
topo_comp_a = TopologyComponent(
TopologyComponentType.SIMULATOR, sim
topo_comp_a = topo_comp_sims.get(
sim, TopologyComponent(TopologyComponentType.SIMULATOR, sim)
)
opposing_inf = instantiation._get_opposing_interface(interface=sim_inf)
topo_comp_sims[sim] = topo_comp_a
opposing_inf = instantiation._get_opposing_interface(interface=sim_inf)
if not instantiation.fragment.interface_handled_by_proxy(opposing_inf):
topo_comp_b = TopologyComponent(
sim_b = instantiation.find_sim_by_interface(opposing_inf)
topo_comp_b = topo_comp_sims.get(
sim_b,
TopologyComponent(
TopologyComponentType.SIMULATOR,
instantiation.find_sim_by_interface(opposing_inf),
sim_b,
),
)
topo_comp_sims[sim_b] = topo_comp_b
else:
topo_comp_b = TopologyComponent(
proxy_b = instantiation.fragment.get_proxy_by_interface(opposing_inf)
topo_comp_b = topo_comp_proxies.get(
proxy_b,
TopologyComponent(
TopologyComponentType.PROXY,
instantiation.fragment.get_proxy_by_interface(opposing_inf),
proxy_b,
),
)
topo_comp_proxies[proxy_b] = topo_comp_b
update_a_depends_on_b(sim_inf, topo_comp_a, opposing_inf, topo_comp_b)
# TODO (Jonas) Add iteration over proxies
return sim_dependencies
......@@ -19,12 +19,14 @@
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import annotations
import typing
from simbricks.utils import base as util_base
from simbricks.orchestration.instantiation import proxy
import typing as tp
from simbricks.utils import base as util_base
if tp.TYPE_CHECKING:
if typing.TYPE_CHECKING:
from simbricks.orchestration.simulation import base as sim_base
from simbricks.orchestration.system import base as sys_base
......@@ -34,8 +36,8 @@ class Fragment(util_base.IdObj):
def __init__(self):
super().__init__()
self._proxies: set[proxy.Proxy]
self._simulators: set[sim_base.Simulator]
self._proxies: set[proxy.Proxy] = set()
self._simulators: set[sim_base.Simulator] = set()
@staticmethod
def merged(*fragments: "Fragment"):
......
......@@ -20,6 +20,8 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import annotations
import typing
import simbricks.utils.base as util_base
......
......@@ -21,10 +21,6 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from simbricks.runtime.runs.base import Run, Runtime
from simbricks.runtime.runs.distributed import (
DistributedSimpleRuntime, auto_dist
)
from simbricks.runtime.runs.local import (
LocalParallelRuntime, LocalSimpleRuntime
)
from simbricks.runtime.runs.slurm import SlurmRuntime
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