mobiusklein / ms_deisotope

A library for deisotoping and charge state deconvolution of complex mass spectra
https://mobiusklein.github.io/ms_deisotope
Apache License 2.0
33 stars 13 forks source link

Error message not being thrown or acknowledged in code #27

Closed zmunro closed 2 years ago

zmunro commented 2 years ago

If this import doesn't succeed, it is currently failing silently. The error message should be logged or raised.

https://github.com/mobiusklein/ms_deisotope/blob/dd83276bee3b85aac64075c07edce696fe5a51b0/ms_deisotope/data_source/thermo_raw.py#L120

mobiusklein commented 2 years ago

Thank you for the suggestion. It brought my attention back to some rather old code and a pattern that could use some cleaning up.

This is by design, as the message is captured and raised later only if the user explicitly asks for this type via infer_reader or related module function. In particular, this is platform-dependent code (Windows only, must install optional dependency and have a 3rd party proprietary COM C++ DLL installed and registered) but it must be imported to register the reader type and how to check if it is the right format for any given file.

I do see that if you try to instantiate an instance of thermo_raw.ThermoRawLoader when the comtypes wrapper fails to import, it will fail with a NameError because _ThermoRawFileAPI won't be defined. That should be replaced with another placeholder when it's not available that re-raises that error as well.

Did you encounter this issue by directly instantiating thermo_raw.ThermoRawLoader?

mobiusklein commented 2 years ago

The error is now at least acknowledged more carefully in the public interface code.

Thank you again for reporting this.