Skip to content

Commit

Permalink
Disable MPI for non-mpi interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Mar 22, 2024
1 parent 57ffa4a commit 2213729
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/miv_simulator/interface/h5_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from miv_simulator import config
from mpi4py import MPI
from miv_simulator.utils import io as io_utils, from_yaml
from typing import Dict, List
from typing import Dict, Optional


class H5Types(Component):
Expand All @@ -12,6 +12,7 @@ class Config(BaseModel):

cell_distributions: config.CellDistributions = Field("???")
projections: config.SynapticProjections = Field("???")
mpi: Optional[str] = None

def config_from_file(self, filename: str) -> Dict:
return from_yaml(filename)
Expand All @@ -31,3 +32,8 @@ def __call__(self) -> None:
},
)
MPI.COMM_WORLD.barrier()

def compute_context(self):
context = super().compute_context()
del context["config"]["mpi"]
return context
6 changes: 5 additions & 1 deletion src/miv_simulator/interface/neuroh5_graph.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from machinable import Component
from neuroh5.io import read_population_names
from typing import Dict
from typing import Dict, Optional
from miv_simulator.utils.io import H5FileManager


class NeuroH5Graph(Component):
class Config:
mpi: Optional[str] = None

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._graph = None
Expand Down Expand Up @@ -98,5 +101,6 @@ def files(self) -> Dict[str, str]:

def compute_context(self):
context = super().compute_context()
del context["config"]["mpi"]
context["predicate"]["uses"] = sorted([u.hash for u in self.uses])
return context
3 changes: 3 additions & 0 deletions src/miv_simulator/interface/synapse_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from miv_simulator import config, simulator
from pydantic import BaseModel, Field, ConfigDict
from machinable.utils import file_hash
from typing import Optional


class GenerateSynapseForest(Component):
Expand All @@ -11,6 +12,7 @@ class Config(BaseModel):
filepath: str = Field("???")
population: config.PopulationName = Field("???")
morphology: config.SWCFilePath = Field("???")
mpi: Optional[str] = None

@property
def tree_output_filepath(self) -> str:
Expand All @@ -33,6 +35,7 @@ def __call__(self) -> None:
def compute_context(self):
# remove filepath in favor of uses
context = super().compute_context()
del context["config"]["mpi"]
del context["config"]["filepath"]
context["config"]["morphology"] = file_hash(
context["config"]["morphology"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_interface(tmp_path):
with get("machinable.index", storage_directory), get(
"machinable.project", wd
):
with get("mpi", {"ranks": -1}) as run:
with get("mpi") as run:
get(
"miv_simulator.interface.network",
{
Expand Down

0 comments on commit 2213729

Please sign in to comment.