From 2e5f564f0e236b4b2461ba47e107d6947cd03c25 Mon Sep 17 00:00:00 2001 From: Frithjof Gressmann Date: Thu, 19 Oct 2023 15:05:40 -0500 Subject: [PATCH] Reject erroneous extra configuration --- src/miv_simulator/interface/connections.py | 4 +++- src/miv_simulator/interface/distances.py | 4 +++- src/miv_simulator/interface/h5_types.py | 4 +++- src/miv_simulator/interface/network_architecture.py | 4 +++- src/miv_simulator/interface/synapse_forest.py | 4 +++- src/miv_simulator/interface/synapses.py | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/miv_simulator/interface/connections.py b/src/miv_simulator/interface/connections.py index 0048c47..17eb47f 100644 --- a/src/miv_simulator/interface/connections.py +++ b/src/miv_simulator/interface/connections.py @@ -3,7 +3,7 @@ import logging from machinable import Component -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, ConfigDict from miv_simulator import config, simulator from typing import Optional, Dict from miv_simulator.utils import from_yaml @@ -12,6 +12,8 @@ class Connections(Component): class Config(BaseModel): + model_config = ConfigDict(extra="forbid") + filepath: str = Field("???") forest_filepath: str = Field("???") axon_extents: config.AxonExtents = Field("???") diff --git a/src/miv_simulator/interface/distances.py b/src/miv_simulator/interface/distances.py index 7fda203..9e491fe 100644 --- a/src/miv_simulator/interface/distances.py +++ b/src/miv_simulator/interface/distances.py @@ -1,7 +1,7 @@ from typing import Optional, Tuple import logging -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict from machinable import Component from machinable.config import Field @@ -11,6 +11,8 @@ class MeasureDistances(Component): class Config(BaseModel): + model_config = ConfigDict(extra="forbid") + filepath: str = Field("???") cell_distributions: config.CellDistributions = Field("???") layer_extents: config.LayerExtents = Field("???") diff --git a/src/miv_simulator/interface/h5_types.py b/src/miv_simulator/interface/h5_types.py index 345f894..711e5ab 100644 --- a/src/miv_simulator/interface/h5_types.py +++ b/src/miv_simulator/interface/h5_types.py @@ -1,5 +1,5 @@ from machinable import Component -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, ConfigDict from miv_simulator import config from mpi4py import MPI from miv_simulator.utils import io as io_utils, from_yaml @@ -8,6 +8,8 @@ class H5Types(Component): class Config(BaseModel): + model_config = ConfigDict(extra="forbid") + cell_distributions: config.CellDistributions = Field("???") synapses: config.Synapses = Field("???") diff --git a/src/miv_simulator/interface/network_architecture.py b/src/miv_simulator/interface/network_architecture.py index 64980b5..5394fc1 100644 --- a/src/miv_simulator/interface/network_architecture.py +++ b/src/miv_simulator/interface/network_architecture.py @@ -8,13 +8,15 @@ from miv_simulator import config, simulator from miv_simulator.utils import io as io_utils, from_yaml from mpi4py import MPI -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, ConfigDict class NetworkArchitecture(Component): """Creates the network architecture by generating the soma coordinates within specified layer geometry.""" class Config(BaseModel): + model_config = ConfigDict(extra="forbid") + filepath: str = Field("???") cell_distributions: config.CellDistributions = Field("???") synapses: config.Synapses = Field("???") diff --git a/src/miv_simulator/interface/synapse_forest.py b/src/miv_simulator/interface/synapse_forest.py index a540d49..623f810 100644 --- a/src/miv_simulator/interface/synapse_forest.py +++ b/src/miv_simulator/interface/synapse_forest.py @@ -1,10 +1,12 @@ from machinable import Component from miv_simulator import config, simulator -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, ConfigDict class GenerateSynapseForest(Component): class Config(BaseModel): + model_config = ConfigDict(extra="forbid") + filepath: str = Field("???") population: config.PopulationName = Field("???") morphology: config.SWCFilePath = Field("???") diff --git a/src/miv_simulator/interface/synapses.py b/src/miv_simulator/interface/synapses.py index cb11f1d..c11c7fa 100644 --- a/src/miv_simulator/interface/synapses.py +++ b/src/miv_simulator/interface/synapses.py @@ -3,7 +3,7 @@ from machinable import Component from miv_simulator import config from miv_simulator import simulator -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, ConfigDict from typing import Optional, Dict from miv_simulator.utils import from_yaml from mpi4py import MPI @@ -11,6 +11,8 @@ class Synapses(Component): class Config(BaseModel): + model_config = ConfigDict(extra="forbid") + forest_filepath: str = Field("???") cell_types: config.CellTypes = Field("???") population: str = Field("???")