Warning filter
amltk.scheduling.plugins.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',) {} │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────── Ref: Task-f-ycUB67MH ────────────────────────────╯
WarningFilter
#
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
events
#
Return a list of events that this plugin emits.
Likely no need to override this method, as it will automatically return all events defined on the plugin.
Source code in src/amltk/scheduling/plugins/plugin.py
pre_submit
#
pre_submit(
fn: Callable[P, R], *args: args, **kwargs: kwargs
) -> tuple[Callable[P, R], tuple, dict]
Pre-submit hook.
Wraps the function to ignore warnings.