Allow Luigi tasks to fail softly, without cancelling downstream tasks.
Provides a decorator for Luigi tasks that allows them to fail softly. Tasks that fail softly are seen by Luigi as complete, and thus don't prevent dependent tasks from running. The dependent task can check if it's dependencies actually ran successfully or failed softly.
pip install luigi_soft_failures
from luigi_soft_failures import softly_failing
Use as class decorator:
@softly_failing(catch_all=True, propagate=True) class SomeTask(luigi.Task): ...
Or on demand in the requiring task:
def requires(self): return softly_failing(catch_all=True)(SomeTask)(some_param=42)
The dependent task can check the status of it's dependencies using
def run(self): if self.requires().failed_softly(): ...
For a complete example see as_decorator.py.
softly_failing accepts the following parameters:
True, any exception thrown in the task's
runmethod will lead to a soft failure. Otherwise, soft failures can be generated manually by calling
self.fail_softly('Some error message')from the task's
runmethod and exiting the method without exception.
True, the task fails softly if any of it's dependencies failed softly, and
runis never executed. Otherwise,
runis executed as if the dependencies ran successfully.
None): Described below.
Storage of soft failure reports
Whan the wrapped task fails softly, it creates a report with the failure message or exception traceback to indicate this. These reports are stored in a directory specified in one of the following ways (in this order of precedence):
output_dirparameter passed to
- Soft failure status is stored using a
LocalTarget, so a local storage that all workers have access to is required.
- In the Luigi visualizer, softly failed tasks are shown as complete.
Pull requests to address these are very welcome!
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for luigi_soft_failures-0.1.1.tar.gz
Hashes for luigi_soft_failures-0.1.1-py2.py3-none-any.whl