From f57fb1cbd3b3e343fe6c5b46f2dde7ff39d146c3 Mon Sep 17 00:00:00 2001 From: Frithjof Gressmann Date: Thu, 21 Mar 2024 03:24:02 -0500 Subject: [PATCH] Apply code style --- src/miv_simulator/interface/connections.py | 20 +++++++++---------- src/miv_simulator/interface/distances.py | 16 +++++++-------- src/miv_simulator/interface/network.py | 4 ++-- .../interface/network_architecture.py | 14 ++++++------- src/miv_simulator/interface/neuroh5_graph.py | 4 ++-- src/miv_simulator/interface/synapse_forest.py | 9 ++++++--- src/miv_simulator/interface/synapses.py | 18 ++++++++--------- tests/_machinable/project.py | 3 ++- tests/test_interface.py | 10 ++++------ 9 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/miv_simulator/interface/connections.py b/src/miv_simulator/interface/connections.py index aee0adb..4fd7fdf 100644 --- a/src/miv_simulator/interface/connections.py +++ b/src/miv_simulator/interface/connections.py @@ -62,16 +62,16 @@ def __call__(self): def on_write_meta_data(self): return MPI.COMM_WORLD.Get_rank() == 0 - + def compute_context(self): context = super().compute_context() - del context['config']['filepath'] - del context['config']['forest_filepath'] - del context['config']['io_size'] - del context['config']['chunk_size'] - del context['config']['value_chunk_size'] - del context['config']['cache_size'] - del context['config']['write_size'] - del context['config']['ranks'] - context['predicate']['uses'] = sorted([u.hash for u in self.uses]) + del context["config"]["filepath"] + del context["config"]["forest_filepath"] + del context["config"]["io_size"] + del context["config"]["chunk_size"] + del context["config"]["value_chunk_size"] + del context["config"]["cache_size"] + del context["config"]["write_size"] + del context["config"]["ranks"] + context["predicate"]["uses"] = sorted([u.hash for u in self.uses]) return context diff --git a/src/miv_simulator/interface/distances.py b/src/miv_simulator/interface/distances.py index b5a8006..e7ac99b 100644 --- a/src/miv_simulator/interface/distances.py +++ b/src/miv_simulator/interface/distances.py @@ -52,14 +52,14 @@ def __call__(self): def on_write_meta_data(self): return MPI.COMM_WORLD.Get_rank() == 0 - + def compute_context(self): context = super().compute_context() - del context['config']['filepath'] - del context['config']['io_size'] - del context['config']['chunk_size'] - del context['config']['value_chunk_size'] - del context['config']['cache_size'] - del context['config']['ranks'] - context['predicate']['uses'] = sorted([u.hash for u in self.uses]) + del context["config"]["filepath"] + del context["config"]["io_size"] + del context["config"]["chunk_size"] + del context["config"]["value_chunk_size"] + del context["config"]["cache_size"] + del context["config"]["ranks"] + context["predicate"]["uses"] = sorted([u.hash for u in self.uses]) return context diff --git a/src/miv_simulator/interface/network.py b/src/miv_simulator/interface/network.py index ffff2a1..b983513 100644 --- a/src/miv_simulator/interface/network.py +++ b/src/miv_simulator/interface/network.py @@ -105,5 +105,5 @@ def launch(self): def compute_context(self): context = super().compute_context() - del context['config'] - return context \ No newline at end of file + del context["config"] + return context diff --git a/src/miv_simulator/interface/network_architecture.py b/src/miv_simulator/interface/network_architecture.py index 825d060..3248f3b 100644 --- a/src/miv_simulator/interface/network_architecture.py +++ b/src/miv_simulator/interface/network_architecture.py @@ -131,10 +131,10 @@ def generate_connections(self, version=None, uses=None): def compute_context(self): context = super().compute_context() - del context['config']['filepath'] - del context['config']['io_size'] - del context['config']['chunk_size'] - del context['config']['value_chunk_size'] - del context['config']['ranks'] - context['predicate']['uses'] = sorted([u.hash for u in self.uses]) - return context \ No newline at end of file + del context["config"]["filepath"] + del context["config"]["io_size"] + del context["config"]["chunk_size"] + del context["config"]["value_chunk_size"] + del context["config"]["ranks"] + context["predicate"]["uses"] = sorted([u.hash for u in self.uses]) + return context diff --git a/src/miv_simulator/interface/neuroh5_graph.py b/src/miv_simulator/interface/neuroh5_graph.py index 343d0ae..48789dd 100644 --- a/src/miv_simulator/interface/neuroh5_graph.py +++ b/src/miv_simulator/interface/neuroh5_graph.py @@ -95,8 +95,8 @@ def files(self) -> Dict[str, str]: "cells": self.graph.cells_filepath, "connections": self.graph.connections_filepath, } - + def compute_context(self): context = super().compute_context() - context['predicate']['uses'] = sorted([u.hash for u in self.uses]) + context["predicate"]["uses"] = sorted([u.hash for u in self.uses]) return context diff --git a/src/miv_simulator/interface/synapse_forest.py b/src/miv_simulator/interface/synapse_forest.py index 4cc13e2..985efa1 100644 --- a/src/miv_simulator/interface/synapse_forest.py +++ b/src/miv_simulator/interface/synapse_forest.py @@ -3,6 +3,7 @@ from pydantic import BaseModel, Field, ConfigDict from machinable.utils import file_hash + class GenerateSynapseForest(Component): class Config(BaseModel): model_config = ConfigDict(extra="forbid") @@ -32,7 +33,9 @@ def __call__(self) -> None: def compute_context(self): # remove filepath in favor of uses context = super().compute_context() - del context['config']['filepath'] - context['config']['morphology'] = file_hash(context['config']['morphology']) - context['predicate']['uses'] = sorted([u.hash for u in self.uses]) + del context["config"]["filepath"] + context["config"]["morphology"] = file_hash( + context["config"]["morphology"] + ) + context["predicate"]["uses"] = sorted([u.hash for u in self.uses]) return context diff --git a/src/miv_simulator/interface/synapses.py b/src/miv_simulator/interface/synapses.py index e9a9cf8..90e9e4e 100644 --- a/src/miv_simulator/interface/synapses.py +++ b/src/miv_simulator/interface/synapses.py @@ -67,13 +67,13 @@ def on_write_meta_data(self): def compute_context(self): context = super().compute_context() - del context['config']['forest_filepath'] - del context['config']['template_path'] - del context['config']['mechanisms_path'] - del context['config']['io_size'] - del context['config']['write_size'] - del context['config']['chunk_size'] - del context['config']['value_chunk_size'] - del context['config']['ranks'] - context['predicate']['uses'] = sorted([u.hash for u in self.uses]) + del context["config"]["forest_filepath"] + del context["config"]["template_path"] + del context["config"]["mechanisms_path"] + del context["config"]["io_size"] + del context["config"]["write_size"] + del context["config"]["chunk_size"] + del context["config"]["value_chunk_size"] + del context["config"]["ranks"] + context["predicate"]["uses"] = sorted([u.hash for u in self.uses]) return context diff --git a/tests/_machinable/project.py b/tests/_machinable/project.py index 8e3cb62..0d8ba89 100644 --- a/tests/_machinable/project.py +++ b/tests/_machinable/project.py @@ -1,7 +1,8 @@ from machinable import Project + class TestEnv(Project): def on_resolve_remotes(self): return { "mpi": "url+https://raw.githubusercontent.com/machinable-org/machinable/2670e9626eb548f6ce2301923be1f49642086d8c/docs/examples/mpi-execution/mpi.py", - } \ No newline at end of file + } diff --git a/tests/test_interface.py b/tests/test_interface.py index 38a150a..eb66d11 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -12,12 +12,12 @@ def test_interface(tmp_path): source = os.environ["MIV_SIMULATOR_TEST_INTERFACE_SRC"] wd = os.path.dirname(__file__) - + debug = True - storage_directory = str(tmp_path / 'storage') + storage_directory = str(tmp_path / "storage") if debug: storage_directory = f"{wd}/_machinable/storage" - + with get("machinable.index", storage_directory), get( "machinable.project", wd ): @@ -31,9 +31,7 @@ def test_interface(tmp_path): "morphology_path": f"{source}/morphology", }, ).launch() - + for component in run.executables: print(component) assert component.cached() - -