Skip to content

Commit

Permalink
Fix circuit validation (#72)
Browse files Browse the repository at this point in the history
* Fix circuit validation

* Move 'components' errors to BbpError
* Consider '@library' enum when checking files
  • Loading branch information
asanin-epfl committed Jul 8, 2020
1 parent 8903edf commit 92e836d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
11 changes: 7 additions & 4 deletions bluepysnap/circuit_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _check_components_dir(name, components):
"""
dirpath = components.get(name)
if not dirpath or not Path(dirpath).is_dir():
return [fatal('Invalid components "{}": {}'.format(name, dirpath))]
return [BbpError(Error.FATAL, 'Invalid components "{}": {}'.format(name, dirpath))]
return []


Expand Down Expand Up @@ -233,18 +233,21 @@ def _check_rotations():
_check_rotations()
components = config['components']
errors += _check_components_dir('morphologies_dir', components)
errors += _check_components_dir('mechanisms_dir', components)
errors += _check_components_dir('biophysical_neuron_models_dir', components)
if errors:
return errors
morph_files = group['morphology'] if _get_h5_data(group, '@library/morphology') is None \
else group['@library/morphology']
errors += _check_files(
'morphology: {}[{}]'.format(group_name, group.file.filename),
(Path(components['morphologies_dir'], m + '.swc') for m in group['morphology']),
(Path(components['morphologies_dir'], m + '.swc') for m in morph_files),
Error.WARNING)
bio_files = group['model_template'] if _get_h5_data(group, '@library/model_template') is None \
else group['@library/model_template']
bio_path = Path(components['biophysical_neuron_models_dir'])
errors += _check_files(
'model_template: {}[{}]'.format(group_name, group.file.filename),
(bio_path / _get_model_template_file(m) for m in group['model_template']),
(bio_path / _get_model_template_file(m) for m in bio_files),
Error.WARNING)
return errors

Expand Down
1 change: 0 additions & 1 deletion tests/data/circuit_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
},
"components": {
"morphologies_dir": "$COMPONENT_DIR/morphologies",
"mechanisms_dir": "$COMPONENT_DIR/mechanisms_dir",
"biophysical_neuron_models_dir": "$COMPONENT_DIR/biophysical_neuron_models"
},
"node_sets_file": "$BASE_DIR/node_sets.json",
Expand Down
8 changes: 4 additions & 4 deletions tests/test_circuit_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ def test_no_rotation_bbp_node_group_datasets():


def test_no_bio_component_dirs():
dirs = ['morphologies_dir', 'mechanisms_dir', 'biophysical_neuron_models_dir']
dirs = ['morphologies_dir', 'biophysical_neuron_models_dir']
for dir_ in dirs:
with copy_circuit() as (_, config_copy_path):
with edit_config(config_copy_path) as config:
del config['components'][dir_]
errors = test_module.validate(str(config_copy_path))
errors = test_module.validate(str(config_copy_path), True)
# multiplication by 2 because we have 2 populations, each produces the same error.
assert errors == 2 * [Error(Error.FATAL,
'Invalid components "{}": {}'.format(dir_, None))]
assert errors == 2 * [BbpError(Error.FATAL,
'Invalid components "{}": {}'.format(dir_, None))]


@patch('bluepysnap.circuit_validation.MAX_MISSING_FILES_DISPLAY', 1)
Expand Down

0 comments on commit 92e836d

Please sign in to comment.