airflow.providers.standard.triggers.file

Attributes

log

Classes

FileTrigger

A trigger that fires exactly once after it finds the requested file or folder.

FileDeleteTrigger

A trigger that fires exactly once after it finds the requested file and then delete the file.

DirectoryFileDeleteTrigger

Fire once when filename appears in directory, then delete it.

Module Contents

airflow.providers.standard.triggers.file.log[source]
class airflow.providers.standard.triggers.file.FileTrigger(filepath, recursive=False, poke_interval=5.0, **kwargs)[source]

Bases: airflow.triggers.base.BaseTrigger

A trigger that fires exactly once after it finds the requested file or folder.

Parameters:
  • filepath (str) – File or folder name (relative to the base path set within the connection), can be a glob.

  • recursive (bool) – when set to True, enables recursive directory matching behavior of ** in glob filepath parameter. Defaults to False.

  • poke_interval (float) – Time that the job should wait in between each try

filepath[source]
recursive = False[source]
poke_interval = 5.0[source]
serialize()[source]

Serialize FileTrigger arguments and classpath.

async run()[source]

Loop until the relevant files are found.

class airflow.providers.standard.triggers.file.FileDeleteTrigger(filepath, poke_interval=5.0, **kwargs)[source]

Bases: airflow.triggers.base.BaseEventTrigger

A trigger that fires exactly once after it finds the requested file and then delete the file.

The difference between FileTrigger and FileDeleteTrigger is FileDeleteTrigger can only find a specific file.

Parameters:
  • filepath (str) – File (relative to the base path set within the connection).

  • poke_interval (float) – Time that the job should wait in between each try

filepath[source]
poke_interval = 5.0[source]
serialize()[source]

Serialize FileDeleteTrigger arguments and classpath.

async run()[source]

Loop until the relevant file is found.

class airflow.providers.standard.triggers.file.DirectoryFileDeleteTrigger(*, directory, filename, poke_interval=5.0)[source]

Bases: airflow.triggers.base.BaseEventTrigger

Fire once when filename appears in directory, then delete it.

Functionally equivalent to FileDeleteTrigger for a single file, but sibling triggers that point at the same directory and poke_interval share a single underlying directory scan in the triggerer; each instance only fires for its own filename. This is useful when many assets are driven by per-flag-file events landing in a shared inbox directory.

Parameters:
  • directory (str) – Directory to scan.

  • filename (str) – File name (without directory) whose appearance fires this trigger. The matched file is deleted before the event is yielded.

  • poke_interval (float) – Time to wait between scans.

directory[source]
filename[source]
poke_interval = 5.0[source]
serialize()[source]

Serialize DirectoryFileDeleteTrigger arguments and classpath.

shared_stream_key()[source]

All triggers on the same directory + cadence share one scan.

classmethod open_shared_stream(kwargs)[source]
Async:

Drive one directory-listing loop and broadcast each snapshot.

Missing directories yield an empty snapshot so subscribers keep polling for the file to appear. Configuration-class failures (PermissionError, NotADirectoryError, IsADirectoryError) propagate — these are almost always permanent (wrong mount, wrong mode, path points at a file), so silently retrying just hides the misconfiguration from the operator; surfacing them as a _PollFailure makes the trigger visibly fail in the UI, where it can be diagnosed and restarted after the operator corrects the config. Other OSError subclasses (transient I/O blips, NFS hiccups, etc.) are logged at warning and the snapshot is skipped for this cadence, since those may self-heal.

async filter_shared_stream(shared_stream)[source]

Fire once for this instance’s own filename and delete the file.

async run()[source]

Standalone fallback when the shared-stream manager is unavailable.

Mirrors the shared path so the trigger remains usable in unit tests and on Airflow versions without the manager wired in. It does not deduplicate I/O — that requires the triggerer to drive the shared stream.

Was this entry helpful?