From 825b0677d2efbb6c108f5f78d8f5f12727127e79 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 13 Jul 2023 12:06:01 +0100 Subject: [PATCH 1/2] feat(pynml-netpyne): allow netpyne runner to also return command output useful for things like netpyne-ui where we'd like to get more information about errors --- pyneuroml/pynml.py | 56 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/pyneuroml/pynml.py b/pyneuroml/pynml.py index 7a165e752..501283d91 100644 --- a/pyneuroml/pynml.py +++ b/pyneuroml/pynml.py @@ -1461,8 +1461,9 @@ def run_lems_with_jneuroml_netpyne( only_generate_json: bool = False, verbose: bool = DEFAULTS["v"], exit_on_fail: bool = True, + return_string: bool = False, cleanup: bool = False, -) -> typing.Union[bool, typing.Union[dict, tuple[dict, dict]]]: +) -> typing.Union[bool, tuple[bool, str], typing.Union[dict, tuple[dict, dict]]]: """Run LEMS file with the NEURON simulator Tip: set `skip_run=True` to only parse the LEMS file but not run the simulation. @@ -1495,8 +1496,15 @@ def run_lems_with_jneuroml_netpyne( :type verbose: bool :param exit_on_fail: toggle whether command should exit if jnml fails :type exit_on_fail: bool + :param return_string: toggle whether command output string should be returned + :type return_string: bool :param cleanup: toggle whether the directory should be cleaned of generated files after run completion :type cleanup: bool + :returns: either a bool, or a Tuple (bool, str) depending on the value of + return_string: True of jnml ran successfully, False if not; along with the + output of the command. If load_saved_data is True, it returns a dict + with the data + """ logger.info( @@ -1519,17 +1527,32 @@ def run_lems_with_jneuroml_netpyne( if skip_run: success = True else: - success = run_jneuroml( - "", - lems_file_name, - post_args, - max_memory=max_memory, - exec_in_dir=exec_in_dir, - verbose=verbose, - exit_on_fail=exit_on_fail, - ) + if return_string is True: + (success, output_string) = run_jneuroml( + "", + lems_file_name, + post_args, + max_memory=max_memory, + exec_in_dir=exec_in_dir, + verbose=verbose, + exit_on_fail=exit_on_fail, + return_string=True + ) + else: + success = run_jneuroml( + "", + lems_file_name, + post_args, + max_memory=max_memory, + exec_in_dir=exec_in_dir, + verbose=verbose, + exit_on_fail=exit_on_fail, + return_string=False + ) - if not success: + if not success and return_string is True: + return False, output_string + if not success and return_string is False: return False if load_saved_data: @@ -1543,8 +1566,11 @@ def run_lems_with_jneuroml_netpyne( reload_events=reload_events, remove_dat_files_after_load=cleanup, ) - else: - return True + + if return_string is True: + return True, output_string + + return True # TODO: need to enable run with Brian2! @@ -2272,7 +2298,9 @@ def run_jneuroml( :param return_string: toggle whether the output string should be returned :type return_string: bool - :returns: either a bool, or a Tuple (bool, str) depending on the value of return_string: True of jnml ran successfully, False if not; along with the output of the command + :returns: either a bool, or a Tuple (bool, str) depending on the value of + return_string: True of jnml ran successfully, False if not; along with the + output of the command """ logger.debug( From 4935fdbac317b0327e77c1ecac601d91ee2972eb Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 13 Jul 2023 12:50:17 +0100 Subject: [PATCH 2/2] feat: bump version for jneuroml-netpyne runner update --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 74e453051..d80c2422c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pyNeuroML -version = 1.0.8 +version = 1.0.9 author = Padraig Gleeson author_email = p.gleeson@gmail.com url = https://github.com/NeuroML/pyNeuroML