or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ftp-hooks.mdftp-operators.mdftp-sensors.mdindex.md
tile.json

tessl/pypi-apache-airflow-providers-ftp

Provider package for Apache Airflow that enables FTP file transfer protocol operations including hooks, operators, and sensors for workflow integration.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/apache-airflow-providers-ftp@3.13.x

To install, run

npx @tessl/cli install tessl/pypi-apache-airflow-providers-ftp@3.13.0

index.mddocs/

Apache Airflow FTP Provider

A comprehensive provider package for Apache Airflow that enables File Transfer Protocol (FTP) operations within data workflows. This provider includes hooks for managing FTP connections, operators for file transfer tasks, and sensors for monitoring file availability, making it essential for ETL pipelines and data integration workflows that require reliable file transfer capabilities.

Package Information

  • Package Name: apache-airflow-providers-ftp
  • Language: Python
  • Installation: pip install apache-airflow-providers-ftp
  • Minimum Airflow Version: 2.10.0
  • Python Versions: 3.10, 3.11, 3.12, 3.13

Core Imports

# Hook imports for FTP connections
from airflow.providers.ftp.hooks.ftp import FTPHook, FTPSHook

# Operator imports for file transfers
from airflow.providers.ftp.operators.ftp import FTPFileTransmitOperator, FTPSFileTransmitOperator, FTPOperation

# Sensor imports for file monitoring
from airflow.providers.ftp.sensors.ftp import FTPSensor, FTPSSensor

Basic Usage

from airflow import DAG
from airflow.providers.ftp.hooks.ftp import FTPHook
from airflow.providers.ftp.operators.ftp import FTPFileTransmitOperator
from airflow.providers.ftp.sensors.ftp import FTPSensor
from datetime import datetime

# Using FTP Hook directly in a task
def transfer_files_with_hook():
    hook = FTPHook(ftp_conn_id='my_ftp_connection')
    
    # Download a file
    hook.retrieve_file('/remote/path/file.txt', '/local/path/file.txt')
    
    # Upload a file  
    hook.store_file('/remote/path/upload.txt', '/local/path/upload.txt')
    
    # List directory contents
    files = hook.list_directory('/remote/directory')
    return files

# Using FTP Operator in a DAG
dag = DAG('ftp_example', start_date=datetime(2023, 1, 1))

# Wait for file to appear on FTP server
wait_for_file = FTPSensor(
    task_id='wait_for_data_file',
    path='/remote/data/input.csv',
    ftp_conn_id='my_ftp_connection',
    dag=dag
)

# Download the file when available
download_file = FTPFileTransmitOperator(
    task_id='download_data_file',
    ftp_conn_id='my_ftp_connection',
    operation=FTPOperation.GET,
    remote_filepath='/remote/data/input.csv',
    local_filepath='/local/data/input.csv',
    dag=dag
)

wait_for_file >> download_file

Architecture

The FTP provider follows Apache Airflow's standard provider architecture:

  • Hooks: Low-level connection and operation management
  • Operators: Task execution with Airflow integration and templating
  • Sensors: Conditional task triggering based on FTP resource availability
  • Connection Management: Integration with Airflow's connection system for credential management

All components support both standard FTP and secure FTPS (FTP over SSL/TLS) protocols.

Capabilities

FTP Connection Management

Low-level hook classes for establishing and managing FTP connections with authentication, SSL support, and comprehensive file operations.

class FTPHook(BaseHook):
    def __init__(self, ftp_conn_id: str = "ftp_default") -> None: ...
    def get_conn(self) -> ftplib.FTP: ...
    def close_conn(self) -> None: ...
    def test_connection(self) -> tuple[bool, str]: ...

class FTPSHook(FTPHook):
    def get_conn(self) -> ftplib.FTP: ...

FTP Hooks

File Transfer Operations

Operator classes for performing file uploads, downloads, and transfers between local and remote FTP servers with support for directory creation and batch operations.

class FTPFileTransmitOperator(BaseOperator):
    def __init__(
        self,
        *,
        ftp_conn_id: str = "ftp_default",
        local_filepath: str | list[str],
        remote_filepath: str | list[str],
        operation: str = FTPOperation.PUT,
        create_intermediate_dirs: bool = False,
        **kwargs
    ) -> None: ...

class FTPSFileTransmitOperator(FTPFileTransmitOperator): ...

class FTPOperation:
    PUT = "put"
    GET = "get"

FTP Operators

File Monitoring

Sensor classes for waiting and monitoring file or directory availability on FTP servers with configurable error handling and retry logic.

class FTPSensor(BaseSensorOperator):
    def __init__(
        self,
        *,
        path: str,
        ftp_conn_id: str = "ftp_default",
        fail_on_transient_errors: bool = True,
        **kwargs
    ) -> None: ...

class FTPSSensor(FTPSensor): ...

FTP Sensors

Connection Configuration

The FTP provider uses Airflow's connection system. Configure FTP connections in the Airflow UI or programmatically:

  • Connection Type: ftp
  • Host: FTP server hostname or IP address
  • Port: FTP server port (default: 21)
  • Login: Username for authentication
  • Password: Password for authentication
  • Extra: JSON configuration with optional parameters:
    • "passive": true/false - Enable/disable passive mode (default: true)

Types

# Connection context manager support
FTPHook.__enter__() -> FTPHook
FTPHook.__exit__(exc_type: Any, exc_val: Any, exc_tb: Any) -> None

# Error handling types
tuple[bool, str]  # test_connection return type