nils-braun / b2luigi

Task scheduling and batch running for basf2 jobs made simple
GNU General Public License v3.0
17 stars 11 forks source link

`get_all_output_file_names` raises `AttributeError` for tasks with no output #169

Open meliache opened 2 years ago

meliache commented 2 years ago

I stupidly tried get_all_output_file_names (by @anselm-baur ) on a WrapperTask and got error

Traceback (most recent call last):
  File "run_naf_reconstruction.py", line 86, in <module>
    output_files_str = "\n  ".join(task.get_all_output_file_names())
  File "/afs/desy.de/user/m/meliache/.local/lib/python3.8/site-packages/b2luigi/core/task.py", line 174, in get_all_output_file_names
    for file_names in self._transform_output(self.output()).values():
AttributeError: 'NoneType' object has no attribute 'values'

I think it's clear that that output is not really defined for a wrapper task, though it seems that self._transform_output can deal with that and just returns None.

But from a user-experience point of view, if a task has no output, I personally would expect the function to just return an empty list in the case of missing outputs. Not sure if others would expect/prefer the same, but I would try to go with the principle of least surprise and if give an error message, give some more useful one.