elsasserlab / minute

MINUTE-ChIP data analysis workflow
https://minute.readthedocs.io
MIT License
2 stars 0 forks source link

Better handling of minute init --input parameter #171

Closed cnluzon closed 1 year ago

cnluzon commented 1 year ago

I mistakenly left out validation of --input on minute init. So the command would run, and generate invalid groups.tsv file. So now:

I think the make_groups_from_barcodes_and_reads should be the function raising an exception if input is not valid, but I also think it is not so nice if the user gets an output with an entire Traceback and all, so I put it on a try/catch block, but still printed the message coming from it in a CommandLineError, which I am unsure if it is the best way to do.

marcelm commented 1 year ago

I think the make_groups_from_barcodes_and_reads should be the function raising an exception if input is not valid, but I also think it is not so nice if the user gets an output with an entire Traceback and all, so I put it on a try/catch block, but still printed the message coming from it in a CommandLineError, which I am unsure if it is the best way to do.

This is IMO the right way to do it: The function itself should juts raise an appropriate exception, and then the actual command-line code (main or run_init in this case) catches it and converts it to a CommandLineError. This separates responsibilities nicely: The function doesn’t need to even know that it is being run from the command line. And main() can take the exception and its message and make it nicer to read.