Skip to content

Commit

Permalink
Tweaked the logic in fit_dataset to be more forgiving. Catching rai…
Browse files Browse the repository at this point in the history
…sed exception at the CLI and just printing the error.
  • Loading branch information
drewoldag committed Sep 26, 2024
1 parent e4d5e26 commit 981147d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions resspect/scripts/fit_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():

Expand Down Expand Up @@ -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()
6 changes: 4 additions & 2 deletions resspect/scripts/run_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 981147d

Please sign in to comment.