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.
Installation
pip install luigi_soft_failures
Usage
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 failed_softly:
def run(self):
if self.requires().failed_softly():
...
For a complete example see as_decorator.py.
API
softly_failing accepts the following parameters:
-
catch_all(bool, defaultFalse):When
True, any exception thrown in the task'srunmethod will lead to a soft failure. Otherwise, soft failures can be generated manually by callingself.fail_softly('Some error message')from the task'srunmethod and exiting the method without exception. -
propagate(bool, defaultFalse):When
True, the task fails softly if any of it's dependencies failed softly, andrunis never executed. Otherwise,runis executed as if the dependencies ran successfully. -
output_dir(str, defaultNone): 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 tosoftly_failing -
Specified in
luigi.cfg:[luigi_soft_failures.Config] output_dir=/some/path -
Environment variable
LUIGI_SOFT_FAILURES_OUTPUT_DIR -
Default
./soft_failures/
Limitations
- 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!
Metadata
Release files for luigi-soft-failures 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| luigi_soft_failures-0.1.1.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| luigi_soft_failures-0.1.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / luigi_soft_failures-0.1.1.tar.gz
| Download URL | luigi_soft_failures-0.1.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ca408cc52de8123390ef573ce1641dcd6b6e7b83b70d35233f2af41955cd8ce
|
|
BLAKE2b-256 checksum How to use checksums |
c92e1eff9987869e29d87304cc6e5662db9481a6b761a4f2151fd2d799acf148
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
|
Release files / luigi_soft_failures-0.1.1-py2.py3-none-any.whl
| Download URL | luigi_soft_failures-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
3da2aedc41696c5f791879fe19ab1a7beec1571c9998eeea19cec7909d2e0639
|
|
BLAKE2b-256 checksum How to use checksums |
746d0856f9ad304afd24a650545fdee20aa3355784dbe868162fd6b1b5f8346d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
|