Warning filter
The
WarningFilter
if used to automatically filter out warnings from a Task
as it runs.
This wraps your function in context manager
warnings.catch_warnings()
and applies your arguments to warnings.filterwarnings()
,
as you would normally filter warnings in Python.
Usage
import warnings
from amltk.scheduling import Scheduler
from amltk.scheduling.plugins import WarningFilter
def f() -> None:
warnings.warn("This is a warning")
scheduler = Scheduler.with_processes(1)
task = scheduler.task(f, plugins=WarningFilter("ignore"))
╭─ Task f() -> 'None' ─────────────────────────────────────────────────────────╮
│ ╭───────────────────────── Plugin warning-filter ──────────────────────────╮ │
│ │ Args Kwargs │ │
│ │ ('ignore',) {} │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│ @on_submitted │
│ @on_done │
│ @on_result │
│ @on_exception │
│ @on_cancelled │
╰─────────────────────────────── Ref: Rkp26xTA ────────────────────────────────╯
class WarningFilter(*args, **kwargs)
#
Bases: Plugin
A plugin that disables warnings emitted from tasks.
PARAMETER | DESCRIPTION |
---|---|
*args |
arguments to pass to
TYPE:
|
**kwargs |
keyword arguments to pass to
TYPE:
|
Source code in src/amltk/scheduling/plugins/warning_filter.py
name: ClassVar
classvar
attr
#
The name of the plugin.
def attach_task(task)
#
def pre_submit(fn, *args, **kwargs)
#
Pre-submit hook.
Wraps the function to ignore warnings.