From 72643908b6cf19a9592ba27b534c5914780f00b2 Mon Sep 17 00:00:00 2001 From: Veniamin Malefioudakis Date: Thu, 25 Jul 2024 11:50:44 +0300 Subject: [PATCH 1/5] add --log-file par to cli commands --- GANDLF/entrypoints/anonymizer.py | 13 +++++++++++-- GANDLF/entrypoints/config_generator.py | 11 ++++++++++- GANDLF/entrypoints/construct_csv.py | 10 ++++++++++ GANDLF/entrypoints/debug_info.py | 11 ++++++++++- GANDLF/entrypoints/deploy.py | 10 ++++++++++ GANDLF/entrypoints/generate_metrics.py | 10 ++++++++++ GANDLF/entrypoints/optimize_model.py | 14 +++++++++++++- GANDLF/entrypoints/patch_miner.py | 11 ++++++++++- GANDLF/entrypoints/preprocess.py | 10 ++++++++++ GANDLF/entrypoints/recover_config.py | 11 ++++++++++- GANDLF/entrypoints/run.py | 10 ++++++++++ GANDLF/entrypoints/split_csv.py | 12 +++++++++++- GANDLF/entrypoints/verify_install.py | 11 ++++++++++- 13 files changed, 135 insertions(+), 9 deletions(-) diff --git a/GANDLF/entrypoints/anonymizer.py b/GANDLF/entrypoints/anonymizer.py index 8adc7fcc8..04623c40d 100644 --- a/GANDLF/entrypoints/anonymizer.py +++ b/GANDLF/entrypoints/anonymizer.py @@ -12,7 +12,7 @@ from GANDLF.anonymize import run_anonymizer from GANDLF.cli import copyrightMessage from GANDLF.entrypoints import append_copyright_to_help -from GANDLF.utils.gandlf_logging import logger_setup +from GANDLF.utils import logger_setup def _anonymize_images( @@ -63,9 +63,18 @@ def _anonymize_images( type=click.Path(), help="Output directory or file which will contain the image(s) after anonymization.", ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs after anonymization.", +) @append_copyright_to_help -def new_way(input_dir, config, modality, output_file): +def new_way(input_dir, config, modality, output_file, log_file): """Anonymize images/scans in the data directory.""" + if log_file is not None: + logger_setup(log_file) _anonymize_images(input_dir, output_file, config, modality) diff --git a/GANDLF/entrypoints/config_generator.py b/GANDLF/entrypoints/config_generator.py index 861d80077..53c8f68a3 100644 --- a/GANDLF/entrypoints/config_generator.py +++ b/GANDLF/entrypoints/config_generator.py @@ -34,9 +34,18 @@ def _generate_config(config: str, strategy: str, output: str): type=click.Path(file_okay=False, dir_okay=True), help="Path to output directory.", ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help -def new_way(config, strategy, output): +def new_way(config, strategy, output, log_file): """Generate multiple GaNDLF configurations based on a single baseline GaNDLF for experimentation.""" + if log_file is not None: + logger_setup(log_file) _generate_config(config, strategy, output) diff --git a/GANDLF/entrypoints/construct_csv.py b/GANDLF/entrypoints/construct_csv.py index b8e7c2994..74ec40089 100644 --- a/GANDLF/entrypoints/construct_csv.py +++ b/GANDLF/entrypoints/construct_csv.py @@ -91,6 +91,13 @@ def _construct_csv( help="If True, paths in the output data CSV will always be relative to the location" " of the output data CSV itself.", ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help def new_way( input_dir: str, @@ -98,8 +105,11 @@ def new_way( label_id: Optional[str], output_file: str, relativize_paths: bool, + log_file: str, ): """Generate training/inference CSV from data directory.""" + if log_file is not None: + logger_setup(log_file) _construct_csv( input_dir=input_dir, channels_id=channels_id, diff --git a/GANDLF/entrypoints/debug_info.py b/GANDLF/entrypoints/debug_info.py index a179513a1..49143a52e 100644 --- a/GANDLF/entrypoints/debug_info.py +++ b/GANDLF/entrypoints/debug_info.py @@ -25,9 +25,18 @@ def _debug_info(): @click.command() +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help -def new_way(): +def new_way(log_file): """Displays detailed info about system environment: library versions, settings, etc.""" + if log_file is not None: + logger_setup(log_file) _debug_info() diff --git a/GANDLF/entrypoints/deploy.py b/GANDLF/entrypoints/deploy.py index f24a25cf1..a02ca6c4c 100644 --- a/GANDLF/entrypoints/deploy.py +++ b/GANDLF/entrypoints/deploy.py @@ -126,6 +126,13 @@ def _deploy( help="An optional custom python entrypoint script to use instead of the default specified in mlcube.yaml." " (Only for inference and metrics)", ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help def new_way( model: Optional[str], @@ -136,8 +143,11 @@ def new_way( output_dir: str, requires_gpu: bool, entrypoint: Optional[str], + log_file:str ): """Generate frozen/deployable versions of trained GaNDLF models.""" + if log_file is not None: + logger_setup(log_file) _deploy( model=model, config=config, diff --git a/GANDLF/entrypoints/generate_metrics.py b/GANDLF/entrypoints/generate_metrics.py index 5d589a9f0..785b0c8c5 100644 --- a/GANDLF/entrypoints/generate_metrics.py +++ b/GANDLF/entrypoints/generate_metrics.py @@ -54,6 +54,13 @@ def _generate_metrics( help="The value to use for missing predictions as penalty; if `-1`, this does not get added. This is only used in the case where the targets and predictions are passed independently.", ) @click.option("--raw-input", hidden=True) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help def new_way( config: str, @@ -61,8 +68,11 @@ def new_way( output_file: Optional[str], missing_prediction: int, raw_input: str, + log_file: str, ): """Metrics calculator.""" + if log_file is not None: + logger_setup(log_file) _generate_metrics( input_data=input_data, config=config, diff --git a/GANDLF/entrypoints/optimize_model.py b/GANDLF/entrypoints/optimize_model.py index 021f4d65f..de72172fe 100644 --- a/GANDLF/entrypoints/optimize_model.py +++ b/GANDLF/entrypoints/optimize_model.py @@ -46,11 +46,23 @@ def _optimize_model( required=False, type=click.Path(exists=True, file_okay=True, dir_okay=False), ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help def new_way( - model: str, config: Optional[str] = None, output_path: Optional[str] = None + model: str, + log_file: str, + config: Optional[str] = None, + output_path: Optional[str] = None, ): """Generate optimized versions of trained GaNDLF models.""" + if log_file is not None: + logger_setup(log_file) _optimize_model(model=model, config=config, output_path=output_path) diff --git a/GANDLF/entrypoints/patch_miner.py b/GANDLF/entrypoints/patch_miner.py index 58b041129..3e39a5cb6 100644 --- a/GANDLF/entrypoints/patch_miner.py +++ b/GANDLF/entrypoints/patch_miner.py @@ -42,9 +42,18 @@ def _mine_patches(input_path: str, output_dir: str, config: Optional[str]): help="config (in YAML) for running the patch miner. Needs 'scale' and 'patch_size' to be defined, " "otherwise defaults to 16 and (256, 256), respectively.", ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help -def new_way(input_csv: str, output_dir: str, config: Optional[str]): +def new_way(input_csv: str, output_dir: str, config: Optional[str], log_file): """Construct patches from whole slide image(s).""" + if log_file is not None: + logger_setup(log_file) _mine_patches(input_path=input_csv, output_dir=output_dir, config=config) diff --git a/GANDLF/entrypoints/preprocess.py b/GANDLF/entrypoints/preprocess.py index 0644b1d53..3c680c7ae 100644 --- a/GANDLF/entrypoints/preprocess.py +++ b/GANDLF/entrypoints/preprocess.py @@ -81,6 +81,13 @@ def _preprocess( is_flag=True, help="If passed, applies zero cropping during output creation.", ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help def new_way( config: str, @@ -89,8 +96,11 @@ def new_way( label_pad: str, apply_augs: bool, crop_zero: bool, + log_file: bool ): """Generate training/inference data which are preprocessed to reduce resource footprint during computation.""" + if log_file is not None: + logger_setup(log_file) _preprocess( config=config, input_data=input_data, diff --git a/GANDLF/entrypoints/recover_config.py b/GANDLF/entrypoints/recover_config.py index 6168b2ad1..445a92f2f 100644 --- a/GANDLF/entrypoints/recover_config.py +++ b/GANDLF/entrypoints/recover_config.py @@ -47,10 +47,19 @@ def _recover_config(model_dir: Optional[str], mlcube: bool, output_file: str): type=click.Path(file_okay=True, dir_okay=False), help="Path to an output file where the config will be written.", ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help -def new_way(model_dir, mlcube, output_file): +def new_way(model_dir, mlcube, output_file,log_file): """Recovers a config file from a GaNDLF model. If used from within a deployed GaNDLF MLCube, attempts to extract the config from the embedded model.""" + if log_file is not None: + logger_setup(log_file) _recover_config(model_dir=model_dir, mlcube=mlcube, output_file=output_file) diff --git a/GANDLF/entrypoints/run.py b/GANDLF/entrypoints/run.py index f974acdc1..054ae50f0 100644 --- a/GANDLF/entrypoints/run.py +++ b/GANDLF/entrypoints/run.py @@ -146,6 +146,13 @@ def _run( help="Location to save the output of the inference session. Not used for training.", ) @click.option("--raw-input", hidden=True) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help def new_way( config: str, @@ -157,8 +164,11 @@ def new_way( resume: bool, output_path: str, raw_input: str, + log_file:str ): """Semantic segmentation, regression, and classification for medical images using Deep Learning.""" + if log_file is not None: + logger_setup(log_file) _run( config=config, input_data=input_data, diff --git a/GANDLF/entrypoints/split_csv.py b/GANDLF/entrypoints/split_csv.py index 7261e5fe8..0652645a8 100644 --- a/GANDLF/entrypoints/split_csv.py +++ b/GANDLF/entrypoints/split_csv.py @@ -50,9 +50,19 @@ def _split_csv(input_csv: str, output_dir: str, config_path: Optional[str]): help="The GaNDLF config (in YAML) with the `nested_training` key specified to the folds needed.", type=click.Path(exists=True, file_okay=True, dir_okay=False), ) +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) + @append_copyright_to_help -def new_way(input_csv: str, output_dir: str, config: Optional[str]): +def new_way(input_csv: str, output_dir: str, config: Optional[str],log_file): """Split the data into training, validation, and testing sets and save them as csvs in the output directory.""" + if log_file is not None: + logger_setup(log_file) _split_csv(input_csv, output_dir, config) diff --git a/GANDLF/entrypoints/verify_install.py b/GANDLF/entrypoints/verify_install.py index 970b78a6f..2ec8134aa 100644 --- a/GANDLF/entrypoints/verify_install.py +++ b/GANDLF/entrypoints/verify_install.py @@ -30,9 +30,18 @@ def _verify_install(): @click.command() +@click.option( + "--log-file", + "-l", + type=click.Path(), + default=None, + help="Output file which will contain the logs.", +) @append_copyright_to_help -def new_way(): +def new_way(log_file): """Verify GaNDLF installation.""" + if log_file is not None: + logger_setup(log_file) _verify_install() From 379c68a5326161e33e881f809647eb626dc9d7cc Mon Sep 17 00:00:00 2001 From: Veniamin Malefioudakis Date: Thu, 25 Jul 2024 11:52:13 +0300 Subject: [PATCH 2/5] blacked --- GANDLF/entrypoints/deploy.py | 2 +- GANDLF/entrypoints/preprocess.py | 2 +- GANDLF/entrypoints/recover_config.py | 2 +- GANDLF/entrypoints/run.py | 2 +- GANDLF/entrypoints/split_csv.py | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/GANDLF/entrypoints/deploy.py b/GANDLF/entrypoints/deploy.py index a02ca6c4c..59e5118e3 100644 --- a/GANDLF/entrypoints/deploy.py +++ b/GANDLF/entrypoints/deploy.py @@ -143,7 +143,7 @@ def new_way( output_dir: str, requires_gpu: bool, entrypoint: Optional[str], - log_file:str + log_file: str, ): """Generate frozen/deployable versions of trained GaNDLF models.""" if log_file is not None: diff --git a/GANDLF/entrypoints/preprocess.py b/GANDLF/entrypoints/preprocess.py index 3c680c7ae..82b5823cc 100644 --- a/GANDLF/entrypoints/preprocess.py +++ b/GANDLF/entrypoints/preprocess.py @@ -96,7 +96,7 @@ def new_way( label_pad: str, apply_augs: bool, crop_zero: bool, - log_file: bool + log_file: bool, ): """Generate training/inference data which are preprocessed to reduce resource footprint during computation.""" if log_file is not None: diff --git a/GANDLF/entrypoints/recover_config.py b/GANDLF/entrypoints/recover_config.py index 445a92f2f..81667429d 100644 --- a/GANDLF/entrypoints/recover_config.py +++ b/GANDLF/entrypoints/recover_config.py @@ -55,7 +55,7 @@ def _recover_config(model_dir: Optional[str], mlcube: bool, output_file: str): help="Output file which will contain the logs.", ) @append_copyright_to_help -def new_way(model_dir, mlcube, output_file,log_file): +def new_way(model_dir, mlcube, output_file, log_file): """Recovers a config file from a GaNDLF model. If used from within a deployed GaNDLF MLCube, attempts to extract the config from the embedded model.""" if log_file is not None: diff --git a/GANDLF/entrypoints/run.py b/GANDLF/entrypoints/run.py index 054ae50f0..dbf983c2b 100644 --- a/GANDLF/entrypoints/run.py +++ b/GANDLF/entrypoints/run.py @@ -164,7 +164,7 @@ def new_way( resume: bool, output_path: str, raw_input: str, - log_file:str + log_file: str, ): """Semantic segmentation, regression, and classification for medical images using Deep Learning.""" if log_file is not None: diff --git a/GANDLF/entrypoints/split_csv.py b/GANDLF/entrypoints/split_csv.py index 0652645a8..c73bd26a6 100644 --- a/GANDLF/entrypoints/split_csv.py +++ b/GANDLF/entrypoints/split_csv.py @@ -57,9 +57,8 @@ def _split_csv(input_csv: str, output_dir: str, config_path: Optional[str]): default=None, help="Output file which will contain the logs.", ) - @append_copyright_to_help -def new_way(input_csv: str, output_dir: str, config: Optional[str],log_file): +def new_way(input_csv: str, output_dir: str, config: Optional[str], log_file): """Split the data into training, validation, and testing sets and save them as csvs in the output directory.""" if log_file is not None: logger_setup(log_file) From 5ded8ed66c55362fa362379352fe5f4fdc986884 Mon Sep 17 00:00:00 2001 From: Veniamin Malefioudakis Date: Thu, 25 Jul 2024 12:56:02 +0300 Subject: [PATCH 3/5] update cli commands --- GANDLF/entrypoints/anonymizer.py | 3 +-- GANDLF/entrypoints/construct_csv.py | 1 - GANDLF/entrypoints/debug_info.py | 1 - GANDLF/entrypoints/deploy.py | 1 - GANDLF/entrypoints/generate_metrics.py | 1 - GANDLF/entrypoints/optimize_model.py | 1 - GANDLF/entrypoints/patch_miner.py | 1 - GANDLF/entrypoints/preprocess.py | 1 - GANDLF/entrypoints/recover_config.py | 1 - GANDLF/entrypoints/run.py | 1 - GANDLF/entrypoints/split_csv.py | 1 - GANDLF/entrypoints/verify_install.py | 1 - testing/entrypoints/test_anonymizer.py | 23 +++++++++++++++++++++++ 13 files changed, 24 insertions(+), 13 deletions(-) diff --git a/GANDLF/entrypoints/anonymizer.py b/GANDLF/entrypoints/anonymizer.py index 04623c40d..d618208d9 100644 --- a/GANDLF/entrypoints/anonymizer.py +++ b/GANDLF/entrypoints/anonymizer.py @@ -65,10 +65,9 @@ def _anonymize_images( ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, - help="Output file which will contain the logs after anonymization.", + help="Output file which will contain the logs.", ) @append_copyright_to_help def new_way(input_dir, config, modality, output_file, log_file): diff --git a/GANDLF/entrypoints/construct_csv.py b/GANDLF/entrypoints/construct_csv.py index 74ec40089..a4a63d78e 100644 --- a/GANDLF/entrypoints/construct_csv.py +++ b/GANDLF/entrypoints/construct_csv.py @@ -93,7 +93,6 @@ def _construct_csv( ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/debug_info.py b/GANDLF/entrypoints/debug_info.py index 49143a52e..38d4e518b 100644 --- a/GANDLF/entrypoints/debug_info.py +++ b/GANDLF/entrypoints/debug_info.py @@ -27,7 +27,6 @@ def _debug_info(): @click.command() @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/deploy.py b/GANDLF/entrypoints/deploy.py index 59e5118e3..cdb7460e0 100644 --- a/GANDLF/entrypoints/deploy.py +++ b/GANDLF/entrypoints/deploy.py @@ -128,7 +128,6 @@ def _deploy( ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/generate_metrics.py b/GANDLF/entrypoints/generate_metrics.py index 785b0c8c5..69b571e0d 100644 --- a/GANDLF/entrypoints/generate_metrics.py +++ b/GANDLF/entrypoints/generate_metrics.py @@ -56,7 +56,6 @@ def _generate_metrics( @click.option("--raw-input", hidden=True) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/optimize_model.py b/GANDLF/entrypoints/optimize_model.py index de72172fe..7e684307d 100644 --- a/GANDLF/entrypoints/optimize_model.py +++ b/GANDLF/entrypoints/optimize_model.py @@ -48,7 +48,6 @@ def _optimize_model( ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/patch_miner.py b/GANDLF/entrypoints/patch_miner.py index 3e39a5cb6..cdb330e17 100644 --- a/GANDLF/entrypoints/patch_miner.py +++ b/GANDLF/entrypoints/patch_miner.py @@ -44,7 +44,6 @@ def _mine_patches(input_path: str, output_dir: str, config: Optional[str]): ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/preprocess.py b/GANDLF/entrypoints/preprocess.py index 82b5823cc..6f37ec0e2 100644 --- a/GANDLF/entrypoints/preprocess.py +++ b/GANDLF/entrypoints/preprocess.py @@ -83,7 +83,6 @@ def _preprocess( ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/recover_config.py b/GANDLF/entrypoints/recover_config.py index 81667429d..b2162450c 100644 --- a/GANDLF/entrypoints/recover_config.py +++ b/GANDLF/entrypoints/recover_config.py @@ -49,7 +49,6 @@ def _recover_config(model_dir: Optional[str], mlcube: bool, output_file: str): ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/run.py b/GANDLF/entrypoints/run.py index dbf983c2b..200d829b4 100644 --- a/GANDLF/entrypoints/run.py +++ b/GANDLF/entrypoints/run.py @@ -148,7 +148,6 @@ def _run( @click.option("--raw-input", hidden=True) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/split_csv.py b/GANDLF/entrypoints/split_csv.py index c73bd26a6..d1b65d656 100644 --- a/GANDLF/entrypoints/split_csv.py +++ b/GANDLF/entrypoints/split_csv.py @@ -52,7 +52,6 @@ def _split_csv(input_csv: str, output_dir: str, config_path: Optional[str]): ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/verify_install.py b/GANDLF/entrypoints/verify_install.py index 2ec8134aa..bd860bc07 100644 --- a/GANDLF/entrypoints/verify_install.py +++ b/GANDLF/entrypoints/verify_install.py @@ -32,7 +32,6 @@ def _verify_install(): @click.command() @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/testing/entrypoints/test_anonymizer.py b/testing/entrypoints/test_anonymizer.py index 99d060b1d..b2a35f165 100644 --- a/testing/entrypoints/test_anonymizer.py +++ b/testing/entrypoints/test_anonymizer.py @@ -20,6 +20,7 @@ TmpDire("output/"), TmpNoEx("path_na/"), TmpFile("output.csv", content="col1,col2\n123,456\n"), + TmpDire("logs/") ] test_cases = [ CliCase( @@ -31,6 +32,7 @@ "-i . -c config.yaml -m rad -o output/", # tests modality has default value "-i . -c config.yaml -o output/", + ], old_way_lines=[ "--inputDir . --config config.yaml --modality rad --outputFile output/", @@ -108,6 +110,27 @@ # "-i . -m fake_modality -o output.csv", # <- in old way there is no such a validation in cli part ], ), + CliCase( + should_succeed=True, + + new_way_lines=[ + # full command + "--input-dir . --config config.yaml --modality rad --output-file output/ --log-file logs/logs.log", + # tests short arg aliases + "-i . -c config.yaml -m rad -o output/", + # tests modality has default value + "-i . -c config.yaml -o output/", + + ], + old_way_lines=None, + expected_args={ + "input_path": os.path.normpath("."), + "output_path": os.path.normpath("output/"), + "parameters": {"foo": "bar"}, + "modality": "rad", + "log_file":os.path.normpath("logs/"), + }, + ), ] From 6ed8cec2cf20091c1415fbb8126cca65a8e1a049 Mon Sep 17 00:00:00 2001 From: Veniamin Malefioudakis Date: Thu, 25 Jul 2024 14:47:33 +0300 Subject: [PATCH 4/5] update test entry files --- GANDLF/entrypoints/config_generator.py | 1 - GANDLF/entrypoints/preprocess.py | 2 +- GANDLF/entrypoints/split_csv.py | 2 +- testing/entrypoints/test_anonymizer.py | 25 +------------------------ 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/GANDLF/entrypoints/config_generator.py b/GANDLF/entrypoints/config_generator.py index 53c8f68a3..644f3da7b 100644 --- a/GANDLF/entrypoints/config_generator.py +++ b/GANDLF/entrypoints/config_generator.py @@ -36,7 +36,6 @@ def _generate_config(config: str, strategy: str, output: str): ) @click.option( "--log-file", - "-l", type=click.Path(), default=None, help="Output file which will contain the logs.", diff --git a/GANDLF/entrypoints/preprocess.py b/GANDLF/entrypoints/preprocess.py index 6f37ec0e2..68f3df3e0 100644 --- a/GANDLF/entrypoints/preprocess.py +++ b/GANDLF/entrypoints/preprocess.py @@ -95,7 +95,7 @@ def new_way( label_pad: str, apply_augs: bool, crop_zero: bool, - log_file: bool, + log_file: str, ): """Generate training/inference data which are preprocessed to reduce resource footprint during computation.""" if log_file is not None: diff --git a/GANDLF/entrypoints/split_csv.py b/GANDLF/entrypoints/split_csv.py index d1b65d656..1606aeffb 100644 --- a/GANDLF/entrypoints/split_csv.py +++ b/GANDLF/entrypoints/split_csv.py @@ -57,7 +57,7 @@ def _split_csv(input_csv: str, output_dir: str, config_path: Optional[str]): help="Output file which will contain the logs.", ) @append_copyright_to_help -def new_way(input_csv: str, output_dir: str, config: Optional[str], log_file): +def new_way(input_csv: str, output_dir: str, config: Optional[str], log_file: str): """Split the data into training, validation, and testing sets and save them as csvs in the output directory.""" if log_file is not None: logger_setup(log_file) diff --git a/testing/entrypoints/test_anonymizer.py b/testing/entrypoints/test_anonymizer.py index b2a35f165..ee4ab2035 100644 --- a/testing/entrypoints/test_anonymizer.py +++ b/testing/entrypoints/test_anonymizer.py @@ -20,7 +20,6 @@ TmpDire("output/"), TmpNoEx("path_na/"), TmpFile("output.csv", content="col1,col2\n123,456\n"), - TmpDire("logs/") ] test_cases = [ CliCase( @@ -32,7 +31,6 @@ "-i . -c config.yaml -m rad -o output/", # tests modality has default value "-i . -c config.yaml -o output/", - ], old_way_lines=[ "--inputDir . --config config.yaml --modality rad --outputFile output/", @@ -110,27 +108,6 @@ # "-i . -m fake_modality -o output.csv", # <- in old way there is no such a validation in cli part ], ), - CliCase( - should_succeed=True, - - new_way_lines=[ - # full command - "--input-dir . --config config.yaml --modality rad --output-file output/ --log-file logs/logs.log", - # tests short arg aliases - "-i . -c config.yaml -m rad -o output/", - # tests modality has default value - "-i . -c config.yaml -o output/", - - ], - old_way_lines=None, - expected_args={ - "input_path": os.path.normpath("."), - "output_path": os.path.normpath("output/"), - "parameters": {"foo": "bar"}, - "modality": "rad", - "log_file":os.path.normpath("logs/"), - }, - ), ] @@ -144,4 +121,4 @@ def test_case(cli_runner: CliRunner, case: CliCase): new_way=new_way, old_way=old_way, old_script_name=OLD_SCRIPT_NAME, - ) + ) \ No newline at end of file From 431d2bd35176224715252186c8ab104d9efee32d Mon Sep 17 00:00:00 2001 From: Veniamin Malefioudakis Date: Thu, 25 Jul 2024 14:50:13 +0300 Subject: [PATCH 5/5] update test_anonymizer --- testing/entrypoints/test_anonymizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/entrypoints/test_anonymizer.py b/testing/entrypoints/test_anonymizer.py index ee4ab2035..99d060b1d 100644 --- a/testing/entrypoints/test_anonymizer.py +++ b/testing/entrypoints/test_anonymizer.py @@ -121,4 +121,4 @@ def test_case(cli_runner: CliRunner, case: CliCase): new_way=new_way, old_way=old_way, old_script_name=OLD_SCRIPT_NAME, - ) \ No newline at end of file + )