From 5f9f285f7136d4df2d72a0e6dabfaf138fd6fe68 Mon Sep 17 00:00:00 2001 From: Gianluca Ficarelli Date: Fri, 8 Mar 2024 12:01:40 +0100 Subject: [PATCH] Use click --- custom_analyses/src/a00/requirements.in | 1 + custom_analyses/src/a00/requirements.txt | 1 + custom_analyses/src/a01/requirements.in | 3 +- custom_analyses/src/a01/requirements.txt | 54 +++++++++---------- custom_analyses/src/a02/requirements.in | 1 + custom_analyses/src/a02/requirements.txt | 54 +++++++++---------- custom_analyses/src/common/utils.py | 28 ++++++++-- custom_analyses/src/emodel_00/requirements.in | 1 + custom_analyses/src/emodel_01/requirements.in | 1 + 9 files changed, 84 insertions(+), 60 deletions(-) diff --git a/custom_analyses/src/a00/requirements.in b/custom_analyses/src/a00/requirements.in index e69de29..dca9a90 100644 --- a/custom_analyses/src/a00/requirements.in +++ b/custom_analyses/src/a00/requirements.in @@ -0,0 +1 @@ +click diff --git a/custom_analyses/src/a00/requirements.txt b/custom_analyses/src/a00/requirements.txt index e69de29..2f72dd5 100644 --- a/custom_analyses/src/a00/requirements.txt +++ b/custom_analyses/src/a00/requirements.txt @@ -0,0 +1 @@ +click==8.1.7 diff --git a/custom_analyses/src/a01/requirements.in b/custom_analyses/src/a01/requirements.in index 8807413..512adc7 100644 --- a/custom_analyses/src/a01/requirements.in +++ b/custom_analyses/src/a01/requirements.in @@ -1,2 +1,3 @@ -bluepysnap>=2.0.0 blueetl>=0.4.0 +bluepysnap>=2.0.0 +click diff --git a/custom_analyses/src/a01/requirements.txt b/custom_analyses/src/a01/requirements.txt index acd1f8e..71d4346 100644 --- a/custom_analyses/src/a01/requirements.txt +++ b/custom_analyses/src/a01/requirements.txt @@ -1,43 +1,43 @@ annotated-types==0.6.0 -attrs==23.1.0 -blueetl==0.4.3 +attrs==23.2.0 +blueetl==0.7.1 blueetl-core==0.1.7 -bluepysnap==2.0.2 +bluepysnap==3.0.1 cached-property==1.5.2 click==8.1.7 contourpy==1.2.0 cycler==0.12.1 deprecation==2.1.0 -fonttools==4.46.0 +fonttools==4.49.0 h5py==3.10.0 -importlib-resources==6.1.1 +importlib_resources==6.1.3 joblib==1.3.2 -jsonschema==4.20.0 -jsonschema-specifications==2023.11.2 +jsonschema==4.21.1 +jsonschema-specifications==2023.12.1 kiwisolver==1.4.5 libsonata==0.1.24 -matplotlib==3.8.2 -more-itertools==10.1.0 -morph-tool==2.9.1 +matplotlib==3.8.3 +more-itertools==10.2.0 +morph-tool==2.10.2 MorphIO==3.3.7 -neurom==3.2.5 -numpy==1.26.2 +neurom==3.2.8 +numpy==1.26.4 packaging==23.2 -pandas==2.1.4 -Pillow==10.1.0 -pyarrow==14.0.1 -pydantic==2.5.2 -pydantic_core==2.14.5 -pyparsing==3.1.1 -python-dateutil==2.8.2 -pytz==2023.3.post1 +pandas==2.2.1 +pillow==10.2.0 +pyarrow==15.0.1 +pydantic==2.6.3 +pydantic_core==2.16.3 +pyparsing==3.1.2 +python-dateutil==2.9.0.post0 +pytz==2024.1 PyYAML==6.0.1 -referencing==0.32.0 -rpds-py==0.13.2 -scipy==1.11.4 +referencing==0.33.0 +rpds-py==0.18.0 +scipy==1.12.0 six==1.16.0 -tqdm==4.66.1 -typing_extensions==4.9.0 -tzdata==2023.3 -xarray==2023.12.0 +tqdm==4.66.2 +typing_extensions==4.10.0 +tzdata==2024.1 +xarray==2024.2.0 xmltodict==0.13.0 diff --git a/custom_analyses/src/a02/requirements.in b/custom_analyses/src/a02/requirements.in index 94341a5..1de88ab 100644 --- a/custom_analyses/src/a02/requirements.in +++ b/custom_analyses/src/a02/requirements.in @@ -1,3 +1,4 @@ +blueetl>=0.4.0 bluepysnap>=2.0.0 blueetl>=0.4.0 submitit>=1.5.1 diff --git a/custom_analyses/src/a02/requirements.txt b/custom_analyses/src/a02/requirements.txt index 50669a5..da01440 100644 --- a/custom_analyses/src/a02/requirements.txt +++ b/custom_analyses/src/a02/requirements.txt @@ -1,45 +1,45 @@ annotated-types==0.6.0 -attrs==23.1.0 -blueetl==0.4.3 +attrs==23.2.0 +blueetl==0.7.1 blueetl-core==0.1.7 -bluepysnap==2.0.2 +bluepysnap==3.0.1 cached-property==1.5.2 click==8.1.7 cloudpickle==3.0.0 contourpy==1.2.0 cycler==0.12.1 deprecation==2.1.0 -fonttools==4.46.0 +fonttools==4.49.0 h5py==3.10.0 -importlib-resources==6.1.1 +importlib_resources==6.1.3 joblib==1.3.2 -jsonschema==4.20.0 -jsonschema-specifications==2023.11.2 +jsonschema==4.21.1 +jsonschema-specifications==2023.12.1 kiwisolver==1.4.5 libsonata==0.1.24 -matplotlib==3.8.2 -more-itertools==10.1.0 -morph-tool==2.9.1 +matplotlib==3.8.3 +more-itertools==10.2.0 +morph-tool==2.10.2 MorphIO==3.3.7 -neurom==3.2.5 -numpy==1.26.2 +neurom==3.2.8 +numpy==1.26.4 packaging==23.2 -pandas==2.1.4 -Pillow==10.1.0 -pyarrow==14.0.1 -pydantic==2.5.2 -pydantic_core==2.14.5 -pyparsing==3.1.1 -python-dateutil==2.8.2 -pytz==2023.3.post1 +pandas==2.2.1 +pillow==10.2.0 +pyarrow==15.0.1 +pydantic==2.6.3 +pydantic_core==2.16.3 +pyparsing==3.1.2 +python-dateutil==2.9.0.post0 +pytz==2024.1 PyYAML==6.0.1 -referencing==0.32.0 -rpds-py==0.13.2 -scipy==1.11.4 +referencing==0.33.0 +rpds-py==0.18.0 +scipy==1.12.0 six==1.16.0 submitit==1.5.1 -tqdm==4.66.1 -typing_extensions==4.9.0 -tzdata==2023.3 -xarray==2023.12.0 +tqdm==4.66.2 +typing_extensions==4.10.0 +tzdata==2024.1 +xarray==2024.2.0 xmltodict==0.13.0 diff --git a/custom_analyses/src/common/utils.py b/custom_analyses/src/common/utils.py index 4977f29..c8f14bc 100644 --- a/custom_analyses/src/common/utils.py +++ b/custom_analyses/src/common/utils.py @@ -3,11 +3,12 @@ import logging import multiprocessing import os -import sys import time from collections.abc import Callable from pathlib import Path +import click + L = logging.getLogger("analysis") @@ -58,11 +59,28 @@ def wrapper( return result if func.__module__ == "__main__": - # if the script is called directly, automatically execute the function - wrapper( - analysis_config=load_json(Path(sys.argv[1])), - analysis_output=Path(sys.argv[2]), + # if the script is called directly, automatically wrap and execute the function + @click.command() + @click.option( + "--log-level", + default="INFO", + help="Log level", + type=click.Choice( + choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], + case_sensitive=False, + ), + show_default=True, ) + @click.argument("analysis_config_file", type=click.Path(exists=True)) + @click.argument("analysis_output_file", type=click.Path(exists=False)) + def cli_wrapper(analysis_config_file, analysis_output_file, log_level): + wrapper( + analysis_config=load_json(Path(analysis_config_file)), + analysis_output=Path(analysis_output_file), + log_level=log_level, + ) + + cli_wrapper() return wrapper diff --git a/custom_analyses/src/emodel_00/requirements.in b/custom_analyses/src/emodel_00/requirements.in index 1826ec7..62a45b2 100644 --- a/custom_analyses/src/emodel_00/requirements.in +++ b/custom_analyses/src/emodel_00/requirements.in @@ -1,4 +1,5 @@ bluecellulab<2.3.2 +click joblib matplotlib neuron diff --git a/custom_analyses/src/emodel_01/requirements.in b/custom_analyses/src/emodel_01/requirements.in index 879fac7..f10ff27 100644 --- a/custom_analyses/src/emodel_01/requirements.in +++ b/custom_analyses/src/emodel_01/requirements.in @@ -1,2 +1,3 @@ bluepyemodel +click neuron