Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BBPBGLIB-1030] Reject *.sonata nodes and edges file #19

Merged
merged 8 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions neurodamus/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ def _projection_params(config: _SimConfig, run_conf):
non_negatives = ("PopulationID",)
for name, proj in config.projections.items():
_check_params("Projection " + name, compat.Map(proj), required_fields, (), non_negatives)
_validate_file_extension(compat.Map(proj).get("Path"))


@SimConfig.validator
Expand Down Expand Up @@ -553,6 +554,8 @@ def _make_circuit_config(config_dict, req_morphology=True):
elif config_dict.get("nrnPath") == "<NONE>":
config_dict["nrnPath"] = False
_validate_circuit_morphology(config_dict, req_morphology)
_validate_file_extension(config_dict.get("CellLibraryFile"))
_validate_file_extension(config_dict.get("nrnPath"))
return CircuitConfig(config_dict)


Expand All @@ -575,6 +578,15 @@ def _validate_circuit_morphology(config_dict, required=True):
log_verbose(" > MorphologyType = %s, src: %s", morph_type, morph_path)


def _validate_file_extension(path):
if not path:
return
filepath = path.split(":")[0] # for sonata, remove the edge_pop name appended to the file path
if filepath.endswith(".sonata"):
raise ConfigurationError("*.sonata files are no longer supported, "
"please rename them to *.h5")


@SimConfig.validator
def _base_circuit(config: _SimConfig, run_conf):
log_verbose("CIRCUIT (default): %s", run_conf.get("CircuitPath", "<DISABLED>"))
Expand Down
8 changes: 1 addition & 7 deletions neurodamus/io/synapse_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,7 @@ def has_property(self, field_name):
def _get_sonata_circuit(path):
"""Returns a SONATA edge file in path if present
"""
if os.path.isdir(path):
filename = os.path.join(path, "edges.sonata")
if os.path.exists(filename):
return filename
elif path.endswith(".sonata"):
return path
elif path.endswith(".h5"):
if path.endswith(".h5"):
import h5py
f = h5py.File(path, 'r')
if "edges" in f:
Expand Down
2 changes: 1 addition & 1 deletion neurodamus/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_edge_managers(self, source, destination):

def get_edge_manager(self, source, destination, conn_type=SynapseRuleManager):
managers = [manager for manager in self.get_edge_managers(source, destination)
if type(manager) == conn_type]
if isinstance(manager, conn_type)]
return managers[0] if managers else None

def get_create_edge_manager(self, conn_type, source, destination, src_target,
Expand Down
2 changes: 1 addition & 1 deletion neurodamus/target_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def load_targets(self, circuit):
instantiated, and potentially split.
"""
def _is_sonata_file(file_name):
if file_name.endswith(".h5") or file_name.endswith(".sonata"):
if file_name.endswith(".h5"):
return True
return False
if circuit.CircuitPath:
Expand Down
6 changes: 3 additions & 3 deletions tests/simulations/neuromodulation/BlueConfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Run Default
{
CircuitPath ./minimal_circuit
nrnPath ./minimal_circuit/edges.sonata
nrnPath ./minimal_circuit/edges.h5
CellLibraryFile circuit.mvd3
MorphologyPath ./minimal_circuit/morph-release-2020-08-10
MorphologyType asc
Expand All @@ -23,7 +23,7 @@ Run Default

Projection proj
{
Path ./minimal_circuit/projections.sonata
Path ./minimal_circuit/projections.h5
PopulationID 1
Source virtual_neurons
Type NeuroModulation
Expand All @@ -35,7 +35,7 @@ Report soma
Type compartment
ReportOn v
Unit mV
Format Bin
Format SONATA
Dt 0.1
StartTime 0
EndTime 5000
Expand Down
2 changes: 1 addition & 1 deletion tests/test_patched_delays.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_eager_caching():

# set nrnPath (w/plasticity)
SimConfig.base_circuit['nrnPath'] = \
"/gpfs/bbp.cscs.ch/project/proj83/circuits/sscx-v7-plasticity/edges.sonata"
"/gpfs/bbp.cscs.ch/project/proj83/circuits/sscx-v7-plasticity/edges.h5"

# append Connection blocks programmatically
# plasticity
Expand Down
6 changes: 3 additions & 3 deletions tests/test_synapses.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Run Default
{{
CellLibraryFile /gpfs/bbp.cscs.ch/project/proj83/circuits/Bio_M/20200805/circuit.mvd3
nrnPath /gpfs/bbp.cscs.ch/project/proj83/circuits/sscx-v7-plasticity/edges.sonata
nrnPath /gpfs/bbp.cscs.ch/project/proj83/circuits/sscx-v7-plasticity/edges.h5

# Use a fake circuit path to avoid loading the HUGE start.target of the real circuit
CircuitPath /gpfs/bbp.cscs.ch/project/proj12/jenkins/cellular/circuit-1k
Expand Down Expand Up @@ -49,7 +49,7 @@
Projection Thalamocortical_input_VPM
{{
Path /gpfs/bbp.cscs.ch/project/proj83/circuits/Bio_M/20200805/projections/\
2023_01_16/vpm/edges.sonata
2023_01_16/vpm/edges.h5
Source pre_VPM
PopulationID 1
}}
Expand Down Expand Up @@ -149,7 +149,7 @@ def test_synapses_params(blueconfig1):
SimConfig.connections.hoc_map.put("init_I_E", CONN_i2e.hoc_map)
# init_VPM
CONN_vpm = compat.Map(Nd.Map())
CONN_vpm["Source"] = "pre_VPM"
CONN_vpm["Source"] = "projections:pre_VPM"
CONN_vpm["Destination"] = "post_L5_PC"
CONN_vpm["Weight"] = conn_weight
SimConfig.connections.hoc_map.put("init_VPM", CONN_vpm.hoc_map)
Expand Down