From 981147d0f840d0e8bedb6c8eb9475e78480ad6df Mon Sep 17 00:00:00 2001 From: Drew Oldag Date: Thu, 26 Sep 2024 16:39:44 -0700 Subject: [PATCH] Tweaked the logic in `fit_dataset` to be more forgiving. Catching raised exception at the CLI and just printing the error. --- resspect/scripts/fit_dataset.py | 14 ++++++++------ resspect/scripts/run_loop.py | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/resspect/scripts/fit_dataset.py b/resspect/scripts/fit_dataset.py index 9f814eb7..6acca900 100644 --- a/resspect/scripts/fit_dataset.py +++ b/resspect/scripts/fit_dataset.py @@ -69,20 +69,20 @@ def fit_dataset(user_choices): features_file = user_choices.output ncores = user_choices.ncores - if user_choices.sim_name in ['SNPCC', 'snpcc']: + if user_choices.sim_name.lower() == 'snpcc': # fit the entire sample fit_snpcc(path_to_data_dir=data_dir, features_file=features_file, number_of_processors=ncores, feature_extractor=user_choices.function) - elif user_choices.sim_name in ['PLAsTiCC', 'PLASTICC', 'plasticc']: + elif user_choices.sim_name.lower() == 'plasticc': fit_plasticc(path_photo_file=user_choices.photo_file, path_header_file=user_choices.header_file, output_file=features_file, sample=user_choices.sample, number_of_processors=ncores) - return None - + else: + raise ValueError("-s or --simulation not recognized. Options are 'SNPCC' or 'PLAsTiCC'.") def main(): @@ -117,8 +117,10 @@ def main(): user_input = parser.parse_args() - fit_dataset(user_input) - + try: + fit_dataset(user_input) + except Exception as e: + print(f"Error: {e}") if __name__ == '__main__': main() \ No newline at end of file diff --git a/resspect/scripts/run_loop.py b/resspect/scripts/run_loop.py index d87b7483..1ad57d14 100644 --- a/resspect/scripts/run_loop.py +++ b/resspect/scripts/run_loop.py @@ -126,8 +126,10 @@ def main(): from_user = parser.parse_args() - run_loop(from_user) - + try: + run_loop(from_user) + except Exception as e: + print(f"Error: {e}") if __name__ == '__main__': main() \ No newline at end of file