specifysystems/lmpy

Accepted name wranglers don't fail gracefully if the name map file does not exist

Closed this issue · 1 comments

If an accepted name wrangler is instantiated with a name map file that does not exist, the wrangler fails and errors out with an error message like:

FileNotFoundError: [Errno 2] No such file or directory: 'name_map/Caryophyllaceae_map.json'
Exception ignored in: <function _AcceptedNameWrangler.__del__ at 0x7f95c950df30>
Traceback (most recent call last):
  File "/home/cjgrady/anaconda3/envs/caryophyllaceae/lib/python3.10/site-packages/lmpy/data_wrangling/common/accepted_name_wrangler.py", line 81, in __del__
    self.out_name_map_filename is not None,
AttributeError: 'AcceptedNameOccurrenceWrangler' object has no attribute 'out_name_map_filename'

This is confusing because it looks like it is a problem with the code and not because the file is missing.

A couple of things should probably happen. The del method should contain a try / except so that it can fail correctly and we should possibly allow the name map file to not exist if there is a name resolver provided (because we may update the file). We could throw a warning maybe. That or it should fail but it should be clear as to what the problem actually is.

All tools now check for existence of input files