From e729283ac9dd26b45440f84f858ad0245bbdb60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Thu, 5 Oct 2023 10:24:24 +0200 Subject: [PATCH 01/10] remove compute_responses from export_emodels_hoc Change-Id: I963423ad4eaabac29e14d95eace5cb7c0be87b71 --- bluepyemodel/export_emodel/export_emodel.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/bluepyemodel/export_emodel/export_emodel.py b/bluepyemodel/export_emodel/export_emodel.py index 26c14f7b..a54e6a5e 100644 --- a/bluepyemodel/export_emodel/export_emodel.py +++ b/bluepyemodel/export_emodel/export_emodel.py @@ -238,7 +238,6 @@ def export_emodels_hoc( only_validated=False, only_best=True, seeds=None, - map_function=map, new_emodel_name=None, ): """Export a set of emodels to a set of folder named after them. Each folder will contain a hoc @@ -250,14 +249,13 @@ def export_emodels_hoc( access_point, include_validation_protocols=True ) - emodels = compute_responses( - access_point, - cell_evaluator, - map_function, - seeds=seeds, - preselect_for_validation=False, - store_responses=False, - ) + emodels = access_point.get_emodels() + if access_point.emodel_metadata.iteration: + emodels = [ + model + for model in emodels + if model.emodel_metadata.iteration == access_point.emodel_metadata.iteration + ] emodels = select_emodels( access_point.emodel_metadata.emodel, From baa855697ba0f287a1d827f47e514430db25679b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Thu, 5 Oct 2023 10:47:27 +0200 Subject: [PATCH 02/10] Put hoc path of export in a function Change-Id: I2546447aa68148e1a5800e03bd1a7c14ee0f9d7d --- bluepyemodel/export_emodel/export_emodel.py | 41 ++++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/bluepyemodel/export_emodel/export_emodel.py b/bluepyemodel/export_emodel/export_emodel.py index a54e6a5e..a655f266 100644 --- a/bluepyemodel/export_emodel/export_emodel.py +++ b/bluepyemodel/export_emodel/export_emodel.py @@ -29,6 +29,29 @@ logger = logging.getLogger(__name__) +def get_hoc_file_path(output_path): + """Get the hoc file path.""" + output_path = pathlib.Path(output_path) + return str(output_path / "model.hoc") + + +def get_output_path(emodel, output_dir=None, output_base_dir="export_emodels_hoc"): + """Get the output path. + + Args: + emodel (EModel): emodel + output_dir (str): output directory + output_base_dir (str): if output_dir is None, export to this directory instead, + using also emodel metadata in the path + """ + if output_dir is None: + output_dir = f"./{output_base_dir}/{emodel.emodel_metadata.as_string(seed=emodel.seed)}/" + output_path = pathlib.Path(output_dir) + output_path.mkdir(parents=True, exist_ok=True) + + return output_path + + def _write_node_file(emodel, model_template_path, node_file_path, morphology_path=None): """Creates a nodes.h5 file in the SONATA format. It contains the information needed to run the model. See https://bbpteam.epfl.ch/documentation/projects/ @@ -102,14 +125,8 @@ def _export_model_sonata(cell_model, emodel, output_dir=None, new_emodel_name=No if new_emodel_name is not None: emodel.emodel_metadata.emodel = new_emodel_name - if output_dir is None: - output_dir = ( - f"./export_emodels_sonata/{emodel.emodel_metadata.as_string(seed=emodel.seed)}/" - ) - output_path = pathlib.Path(output_dir) - output_path.mkdir(parents=True, exist_ok=True) - - hoc_file_path = str(output_path / "model.hoc") + output_path = get_output_path(emodel, output_dir, output_base_dir="export_emodels_sonata") + hoc_file_path = get_hoc_file_path(output_path) node_file_path = str(output_path / "nodes.h5") morphology_path = str(output_path / pathlib.Path(cell_model.morphology.morphology_path).name) @@ -212,12 +229,8 @@ def _export_emodel_hoc(cell_model, mo, output_dir=None, new_emodel_name=None): if new_emodel_name is not None: mo.emodel_metadata.emodel = new_emodel_name - if output_dir is None: - output_dir = f"./export_emodels_hoc/{mo.emodel_metadata.as_string(seed=mo.seed)}/" - output_path = pathlib.Path(output_dir) - output_path.mkdir(parents=True, exist_ok=True) - - hoc_file_path = str(output_path / "model.hoc") + output_path = get_output_path(mo, output_dir, output_base_dir="export_emodels_hoc") + hoc_file_path = get_hoc_file_path(output_path) morphology_path = str(output_path / pathlib.Path(cell_model.morphology.morphology_path).name) # Copy the morphology From 7bdc310080b6a3696f80ff535e63e38508e949b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Thu, 5 Oct 2023 11:08:04 +0200 Subject: [PATCH 03/10] add store function for hocs Change-Id: I2600bf4bf2726a1f902d0c451d41ee66bc0be157 --- bluepyemodel/access_point/local.py | 19 +++++++++++++++++++ bluepyemodel/export_emodel/export_emodel.py | 4 +--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bluepyemodel/access_point/local.py b/bluepyemodel/access_point/local.py index 378c762c..58947c75 100644 --- a/bluepyemodel/access_point/local.py +++ b/bluepyemodel/access_point/local.py @@ -31,6 +31,8 @@ from bluepyemodel.emodel_pipeline.emodel_metadata import EModelMetadata from bluepyemodel.emodel_pipeline.emodel_settings import EModelPipelineSettings from bluepyemodel.emodel_pipeline.emodel_workflow import EModelWorkflow +from bluepyemodel.export_emodel.export_emodel import export_emodels_hoc +from bluepyemodel.export_emodel.export_emodel import export_emodels_sonata from bluepyemodel.evaluation.evaluator import LEGACY_PRE_PROTOCOLS from bluepyemodel.evaluation.evaluator import PRE_PROTOCOLS from bluepyemodel.evaluation.fitness_calculator_configuration import FitnessCalculatorConfiguration @@ -789,3 +791,20 @@ def add_entry_recipes( with recipes_path.open("w") as f: json.dump(recipes, f, indent=2) + + def store_emodels_hoc( + self, only_validated=False, only_best=True, seeds=None, new_emodel_name=None + ): + export_emodels_hoc(self, only_validated, only_best, seeds, new_emodel_name) + + def store_emodels_sonata( + self, + only_validated=False, + only_best=True, + seeds=None, + map_function=map, + new_emodel_name=None, + ): + export_emodels_sonata( + self, only_validated, only_best, seeds, map_function, new_emodel_name + ) diff --git a/bluepyemodel/export_emodel/export_emodel.py b/bluepyemodel/export_emodel/export_emodel.py index a655f266..33f3175a 100644 --- a/bluepyemodel/export_emodel/export_emodel.py +++ b/bluepyemodel/export_emodel/export_emodel.py @@ -254,9 +254,7 @@ def export_emodels_hoc( new_emodel_name=None, ): """Export a set of emodels to a set of folder named after them. Each folder will contain a hoc - version of the model. - - WARNING: this function is not compatible with multiprocessing.""" + version of the model.""" cell_evaluator = get_evaluator_from_access_point( access_point, include_validation_protocols=True From ace00c7b8f7a706914e1302a8d0669de5b0522a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Thu, 5 Oct 2023 17:44:43 +0200 Subject: [PATCH 04/10] add emodelscript Change-Id: I59ed7c5a43557ee9175e32ba6c276f45f6bd1c75 --- bluepyemodel/access_point/local.py | 20 +++-- bluepyemodel/emodel_pipeline/emodel_script.py | 56 +++++++++++++ bluepyemodel/export_emodel/export_emodel.py | 64 ++------------- bluepyemodel/export_emodel/utils.py | 79 +++++++++++++++++++ 4 files changed, 157 insertions(+), 62 deletions(-) create mode 100644 bluepyemodel/emodel_pipeline/emodel_script.py create mode 100644 bluepyemodel/export_emodel/utils.py diff --git a/bluepyemodel/access_point/local.py b/bluepyemodel/access_point/local.py index 58947c75..ca95d322 100644 --- a/bluepyemodel/access_point/local.py +++ b/bluepyemodel/access_point/local.py @@ -31,8 +31,6 @@ from bluepyemodel.emodel_pipeline.emodel_metadata import EModelMetadata from bluepyemodel.emodel_pipeline.emodel_settings import EModelPipelineSettings from bluepyemodel.emodel_pipeline.emodel_workflow import EModelWorkflow -from bluepyemodel.export_emodel.export_emodel import export_emodels_hoc -from bluepyemodel.export_emodel.export_emodel import export_emodels_sonata from bluepyemodel.evaluation.evaluator import LEGACY_PRE_PROTOCOLS from bluepyemodel.evaluation.evaluator import PRE_PROTOCOLS from bluepyemodel.evaluation.fitness_calculator_configuration import FitnessCalculatorConfiguration @@ -792,10 +790,22 @@ def add_entry_recipes( with recipes_path.open("w") as f: json.dump(recipes, f, indent=2) + def store_hocs( + self, + only_validated=False, + only_best=True, + seeds=None, + map_function=map, + new_emodel_name=None, + description=None, + output_base_dir="export_emodels_hoc" + ): + pass + def store_emodels_hoc( self, only_validated=False, only_best=True, seeds=None, new_emodel_name=None ): - export_emodels_hoc(self, only_validated, only_best, seeds, new_emodel_name) + pass def store_emodels_sonata( self, @@ -805,6 +815,4 @@ def store_emodels_sonata( map_function=map, new_emodel_name=None, ): - export_emodels_sonata( - self, only_validated, only_best, seeds, map_function, new_emodel_name - ) + pass diff --git a/bluepyemodel/emodel_pipeline/emodel_script.py b/bluepyemodel/emodel_pipeline/emodel_script.py new file mode 100644 index 00000000..9db9b088 --- /dev/null +++ b/bluepyemodel/emodel_pipeline/emodel_script.py @@ -0,0 +1,56 @@ +"""EModelScript class""" + +""" +Copyright 2023, EPFL/Blue Brain Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + + +class EModelScript: + + """Contains an emodel hoc file path.""" + + def __init__( + self, + hoc_file_path=None, + seed=None, + workflow_id=None + ): + """Init + + Args: + hoc_file_path (str): path to the hoc file of the emodel + seed (str): seed used during optimisation for this emodel. + workflow_id (str): id of the emodel workflow resource + """ + self.hoc_file_path = hoc_file_path + self.seed = seed + self.workflow_id = workflow_id + + def get_related_nexus_ids(self): + return { + "generation": { + "type": "Generation", + "activity": { + "type": "Activity", + "followedWorkflow": {"type": "EModelWorkflow", "id": self.workflow_id}, + }, + } + } + + def as_dict(self): + return { + "nexus_distributions": [self.hoc_file_path], + "seed": self.seed, + } diff --git a/bluepyemodel/export_emodel/export_emodel.py b/bluepyemodel/export_emodel/export_emodel.py index 33f3175a..6be2a107 100644 --- a/bluepyemodel/export_emodel/export_emodel.py +++ b/bluepyemodel/export_emodel/export_emodel.py @@ -25,33 +25,13 @@ from bluepyemodel.evaluation.evaluation import compute_responses from bluepyemodel.evaluation.evaluation import get_evaluator_from_access_point +from bluepyemodel.export_emodel.utils import get_hoc_file_path +from bluepyemodel.export_emodel.utils import get_output_path +from bluepyemodel.export_emodel.utils import select_emodels logger = logging.getLogger(__name__) -def get_hoc_file_path(output_path): - """Get the hoc file path.""" - output_path = pathlib.Path(output_path) - return str(output_path / "model.hoc") - - -def get_output_path(emodel, output_dir=None, output_base_dir="export_emodels_hoc"): - """Get the output path. - - Args: - emodel (EModel): emodel - output_dir (str): output directory - output_base_dir (str): if output_dir is None, export to this directory instead, - using also emodel metadata in the path - """ - if output_dir is None: - output_dir = f"./{output_base_dir}/{emodel.emodel_metadata.as_string(seed=emodel.seed)}/" - output_path = pathlib.Path(output_dir) - output_path.mkdir(parents=True, exist_ok=True) - - return output_path - - def _write_node_file(emodel, model_template_path, node_file_path, morphology_path=None): """Creates a nodes.h5 file in the SONATA format. It contains the information needed to run the model. See https://bbpteam.epfl.ch/documentation/projects/ @@ -151,33 +131,6 @@ def _export_model_sonata(cell_model, emodel, output_dir=None, new_emodel_name=No ) -def select_emodels(emodel_name, emodels, only_validated=False, only_best=True, seeds=None): - if not emodels: - logger.warning("In export_emodels_nexus, no emodel for %s", emodel_name) - return [] - - if only_best: - emodels = [sorted(emodels, key=lambda x: x.fitness)[0]] - - if seeds: - emodels = [e for e in emodels if e.seed in seeds] - if not emodels: - logger.warning( - "In export_emodels_nexus, no emodel for %s and seeds %s", emodel_name, seeds - ) - return [] - - if only_validated: - emodels = [e for e in emodels if e.passed_validation] - if not emodels: - logger.warning( - "In export_emodels_nexus, no emodel for %s that passed validation", emodel_name - ) - return [] - - return emodels - - def export_emodels_sonata( access_point, only_validated=False, @@ -212,6 +165,8 @@ def export_emodels_sonata( seeds=seeds, ) if not emodels: + logger.warning("No emodels were selected in export_emodels_sonata. " + "Stopping sonata export here.") return cell_model = cell_evaluator.cell_model @@ -251,6 +206,7 @@ def export_emodels_hoc( only_validated=False, only_best=True, seeds=None, + map_function=map, new_emodel_name=None, ): """Export a set of emodels to a set of folder named after them. Each folder will contain a hoc @@ -261,12 +217,6 @@ def export_emodels_hoc( ) emodels = access_point.get_emodels() - if access_point.emodel_metadata.iteration: - emodels = [ - model - for model in emodels - if model.emodel_metadata.iteration == access_point.emodel_metadata.iteration - ] emodels = select_emodels( access_point.emodel_metadata.emodel, @@ -274,8 +224,10 @@ def export_emodels_hoc( only_validated=only_validated, only_best=only_best, seeds=seeds, + iteration=access_point.emodel_metadata.iteration, ) if not emodels: + logger.warning("No emodels were selected in export_emodels_hoc. Stopping hoc export here.") return cell_model = cell_evaluator.cell_model diff --git a/bluepyemodel/export_emodel/utils.py b/bluepyemodel/export_emodel/utils.py new file mode 100644 index 00000000..b659003e --- /dev/null +++ b/bluepyemodel/export_emodel/utils.py @@ -0,0 +1,79 @@ +"""Export the emodels in the SONATA format""" + +""" +Copyright 2023, EPFL/Blue Brain Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +import logging +import pathlib + +logger = logging.getLogger(__name__) + + +def get_output_path(emodel, output_dir=None, output_base_dir="export_emodels_hoc"): + """Get the output path. + + Args: + emodel (EModel): emodel + output_dir (str): output directory + output_base_dir (str): if output_dir is None, export to this directory instead, + using also emodel metadata in the path + """ + if output_dir is None: + output_dir = f"./{output_base_dir}/{emodel.emodel_metadata.as_string(seed=emodel.seed)}/" + output_path = pathlib.Path(output_dir) + output_path.mkdir(parents=True, exist_ok=True) + + return output_path + + +def get_hoc_file_path(output_path): + """Get the hoc file path.""" + output_path = pathlib.Path(output_path) + return str(output_path / "model.hoc") + + +def select_emodels(emodel_name, emodels, only_validated=False, only_best=True, seeds=None, iteration=None): + if not emodels: + logger.warning("In export_emodels_nexus, no emodel for %s", emodel_name) + return [] + + if iteration: + emodels = [ + model + for model in emodels + if model.emodel_metadata.iteration == iteration + ] + + if only_best: + emodels = [sorted(emodels, key=lambda x: x.fitness)[0]] + + if seeds: + emodels = [e for e in emodels if e.seed in seeds] + if not emodels: + logger.warning( + "In export_emodels_nexus, no emodel for %s and seeds %s", emodel_name, seeds + ) + return [] + + if only_validated: + emodels = [e for e in emodels if e.passed_validation] + if not emodels: + logger.warning( + "In export_emodels_nexus, no emodel for %s that passed validation", emodel_name + ) + return [] + + return emodels From 6c8bdc0db38eb5dc3d677542b1b8612b769172ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Fri, 6 Oct 2023 11:21:59 +0200 Subject: [PATCH 05/10] add store hoc function to DataAccessPoint Change-Id: Ie3418546ab6c193b3c76756aa9ab4be359124918 --- bluepyemodel/access_point/access_point.py | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bluepyemodel/access_point/access_point.py b/bluepyemodel/access_point/access_point.py index 875144cb..776ded2f 100644 --- a/bluepyemodel/access_point/access_point.py +++ b/bluepyemodel/access_point/access_point.py @@ -167,6 +167,33 @@ def get_emodel_names(self): Returns: dict: keys are emodel names with seed, values are names without seed. """ + + def store_hocs( + self, + only_validated=False, + only_best=True, + seeds=None, + map_function=map, + new_emodel_name=None, + description=None, + output_base_dir="export_emodels_hoc" + ): + """Store the hoc files""" + + def store_emodels_hoc( + self, only_validated=False, only_best=True, seeds=None, new_emodel_name=None + ): + """Store hoc file produced by export_hoc""" + + def store_emodels_sonata( + self, + only_validated=False, + only_best=True, + seeds=None, + map_function=map, + new_emodel_name=None, + ): + """Store hoc file produced by export_sonata""" def optimisation_state(self, seed=None, continue_opt=False): """Return the state of the optimisation. From a082c05c70bb6d982b419d0682b08c05cbc38367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Fri, 6 Oct 2023 13:47:26 +0200 Subject: [PATCH 06/10] lint fix Change-Id: Ic0f73aa7a8b830ebad4dd7876c6be30f0316137e --- bluepyemodel/access_point/access_point.py | 2 +- bluepyemodel/export_emodel/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bluepyemodel/access_point/access_point.py b/bluepyemodel/access_point/access_point.py index 776ded2f..afb29a95 100644 --- a/bluepyemodel/access_point/access_point.py +++ b/bluepyemodel/access_point/access_point.py @@ -167,7 +167,7 @@ def get_emodel_names(self): Returns: dict: keys are emodel names with seed, values are names without seed. """ - + def store_hocs( self, only_validated=False, diff --git a/bluepyemodel/export_emodel/utils.py b/bluepyemodel/export_emodel/utils.py index b659003e..e0ff4fd9 100644 --- a/bluepyemodel/export_emodel/utils.py +++ b/bluepyemodel/export_emodel/utils.py @@ -24,7 +24,7 @@ def get_output_path(emodel, output_dir=None, output_base_dir="export_emodels_hoc"): """Get the output path. - + Args: emodel (EModel): emodel output_dir (str): output directory @@ -49,7 +49,7 @@ def select_emodels(emodel_name, emodels, only_validated=False, only_best=True, s if not emodels: logger.warning("In export_emodels_nexus, no emodel for %s", emodel_name) return [] - + if iteration: emodels = [ model From 064390cfe5a848488cb7a3535b196d38145f9e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Fri, 6 Oct 2023 13:55:46 +0200 Subject: [PATCH 07/10] lint fix Change-Id: I218c9613eb157bd8cab92af55a133d8b36ede9a1 --- bluepyemodel/export_emodel/export_emodel.py | 1 - bluepyemodel/export_emodel/utils.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bluepyemodel/export_emodel/export_emodel.py b/bluepyemodel/export_emodel/export_emodel.py index 6be2a107..32c9a8a6 100644 --- a/bluepyemodel/export_emodel/export_emodel.py +++ b/bluepyemodel/export_emodel/export_emodel.py @@ -206,7 +206,6 @@ def export_emodels_hoc( only_validated=False, only_best=True, seeds=None, - map_function=map, new_emodel_name=None, ): """Export a set of emodels to a set of folder named after them. Each folder will contain a hoc diff --git a/bluepyemodel/export_emodel/utils.py b/bluepyemodel/export_emodel/utils.py index e0ff4fd9..4d79afcc 100644 --- a/bluepyemodel/export_emodel/utils.py +++ b/bluepyemodel/export_emodel/utils.py @@ -45,7 +45,9 @@ def get_hoc_file_path(output_path): return str(output_path / "model.hoc") -def select_emodels(emodel_name, emodels, only_validated=False, only_best=True, seeds=None, iteration=None): +def select_emodels( + emodel_name, emodels, only_validated=False, only_best=True, seeds=None, iteration=None +): if not emodels: logger.warning("In export_emodels_nexus, no emodel for %s", emodel_name) return [] From 533e6e056f0c51e9ad781d5739a01bf684f3e6e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Fri, 6 Oct 2023 14:03:38 +0200 Subject: [PATCH 08/10] black fix Change-Id: I9fea93747a79928882b4ddcb5473803faf225061 --- bluepyemodel/access_point/access_point.py | 2 +- bluepyemodel/access_point/local.py | 2 +- bluepyemodel/emodel_pipeline/emodel_script.py | 7 +------ bluepyemodel/export_emodel/export_emodel.py | 5 +++-- bluepyemodel/export_emodel/utils.py | 6 +----- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/bluepyemodel/access_point/access_point.py b/bluepyemodel/access_point/access_point.py index afb29a95..69e31f07 100644 --- a/bluepyemodel/access_point/access_point.py +++ b/bluepyemodel/access_point/access_point.py @@ -176,7 +176,7 @@ def store_hocs( map_function=map, new_emodel_name=None, description=None, - output_base_dir="export_emodels_hoc" + output_base_dir="export_emodels_hoc", ): """Store the hoc files""" diff --git a/bluepyemodel/access_point/local.py b/bluepyemodel/access_point/local.py index ca95d322..d10b9ed9 100644 --- a/bluepyemodel/access_point/local.py +++ b/bluepyemodel/access_point/local.py @@ -798,7 +798,7 @@ def store_hocs( map_function=map, new_emodel_name=None, description=None, - output_base_dir="export_emodels_hoc" + output_base_dir="export_emodels_hoc", ): pass diff --git a/bluepyemodel/emodel_pipeline/emodel_script.py b/bluepyemodel/emodel_pipeline/emodel_script.py index 9db9b088..baedd317 100644 --- a/bluepyemodel/emodel_pipeline/emodel_script.py +++ b/bluepyemodel/emodel_pipeline/emodel_script.py @@ -21,12 +21,7 @@ class EModelScript: """Contains an emodel hoc file path.""" - def __init__( - self, - hoc_file_path=None, - seed=None, - workflow_id=None - ): + def __init__(self, hoc_file_path=None, seed=None, workflow_id=None): """Init Args: diff --git a/bluepyemodel/export_emodel/export_emodel.py b/bluepyemodel/export_emodel/export_emodel.py index 32c9a8a6..940111bb 100644 --- a/bluepyemodel/export_emodel/export_emodel.py +++ b/bluepyemodel/export_emodel/export_emodel.py @@ -165,8 +165,9 @@ def export_emodels_sonata( seeds=seeds, ) if not emodels: - logger.warning("No emodels were selected in export_emodels_sonata. " - "Stopping sonata export here.") + logger.warning( + "No emodels were selected in export_emodels_sonata. " "Stopping sonata export here." + ) return cell_model = cell_evaluator.cell_model diff --git a/bluepyemodel/export_emodel/utils.py b/bluepyemodel/export_emodel/utils.py index 4d79afcc..d9d5550a 100644 --- a/bluepyemodel/export_emodel/utils.py +++ b/bluepyemodel/export_emodel/utils.py @@ -53,11 +53,7 @@ def select_emodels( return [] if iteration: - emodels = [ - model - for model in emodels - if model.emodel_metadata.iteration == iteration - ] + emodels = [model for model in emodels if model.emodel_metadata.iteration == iteration] if only_best: emodels = [sorted(emodels, key=lambda x: x.fitness)[0]] From a6c5d6444c0af9bcdc613497f1d59c4661fc6748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Fri, 6 Oct 2023 14:07:50 +0200 Subject: [PATCH 09/10] lint fix Change-Id: I58c42b4223b453acf8105c6cd9fcc21be6196afc --- bluepyemodel/export_emodel/export_emodel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bluepyemodel/export_emodel/export_emodel.py b/bluepyemodel/export_emodel/export_emodel.py index 940111bb..2f058ae4 100644 --- a/bluepyemodel/export_emodel/export_emodel.py +++ b/bluepyemodel/export_emodel/export_emodel.py @@ -166,7 +166,7 @@ def export_emodels_sonata( ) if not emodels: logger.warning( - "No emodels were selected in export_emodels_sonata. " "Stopping sonata export here." + "No emodels were selected in export_emodels_sonata. Stopping sonata export here." ) return From f16d510602fd1443b287649c9079545ee5a993ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Fri, 6 Oct 2023 15:13:15 +0200 Subject: [PATCH 10/10] raise NotImplementedError instead of passing in hoc storing function of LocalAccesssPoint Change-Id: I77a89de35e361a116b97befd3db1b9cb2b1e75c2 --- bluepyemodel/access_point/local.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bluepyemodel/access_point/local.py b/bluepyemodel/access_point/local.py index d10b9ed9..5e89698b 100644 --- a/bluepyemodel/access_point/local.py +++ b/bluepyemodel/access_point/local.py @@ -800,12 +800,12 @@ def store_hocs( description=None, output_base_dir="export_emodels_hoc", ): - pass + raise NotImplementedError def store_emodels_hoc( self, only_validated=False, only_best=True, seeds=None, new_emodel_name=None ): - pass + raise NotImplementedError def store_emodels_sonata( self, @@ -815,4 +815,4 @@ def store_emodels_sonata( map_function=map, new_emodel_name=None, ): - pass + raise NotImplementedError