Ctrl + K
DocumentationLog inGet started

tessl/pypi-apache-airflow-providers-ftp

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

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

Agent Success

Agent success rate when using this tile

84%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.06x

Baseline

Agent success rate without this tile

79%

task.mdevals/scenario-2/

FTP File Inspector

Build a utility that connects to an FTP server and retrieves metadata about remote files, specifically their modification timestamps and file sizes. The utility should provide functions to check when a file was last modified and how large it is.

Requirements

File Metadata Retrieval

The utility must provide two core functions:

  1. A function that retrieves the modification timestamp of a remote file on an FTP server, given:

    • FTP connection identifier
    • Remote file path

    The function should return the modification time as a datetime object.

  2. A function that retrieves the size of a remote file on an FTP server, given:

    • FTP connection identifier
    • Remote file path

    The function should return the file size in bytes as an integer, or None if the size cannot be determined.

Error Handling

Both functions should handle cases where:

  • The file does not exist on the remote server
  • The FTP server does not support the required operations
  • Connection issues occur

Implementation Notes

  • Use the Apache Airflow FTP provider package to establish FTP connections
  • The FTP connection should be configured using Airflow's connection framework
  • Both functions should work with standard FTP servers that support file metadata commands

Test Cases

  • When querying the modification time of an existing file "data.txt" on the FTP server, the function returns a datetime object representing the last modification time @test

  • When querying the size of an existing file "report.csv" on the FTP server, the function returns an integer representing the file size in bytes @test

  • When querying the size of a file that exists but whose size cannot be determined, the function returns None @test

Implementation

@generates

API

from datetime import datetime
from typing import Optional

def get_file_modification_time(ftp_conn_id: str, remote_path: str) -> datetime:
    """
    Retrieve the last modification time of a remote file on an FTP server.

    Args:
        ftp_conn_id: The Airflow connection ID for the FTP server
        remote_path: Path to the remote file

    Returns:
        datetime: The last modification time of the file

    Raises:
        Exception: If the file does not exist or operation is not supported
    """
    pass

def get_file_size(ftp_conn_id: str, remote_path: str) -> Optional[int]:
    """
    Retrieve the size of a remote file on an FTP server.

    Args:
        ftp_conn_id: The Airflow connection ID for the FTP server
        remote_path: Path to the remote file

    Returns:
        int or None: The file size in bytes, or None if size cannot be determined

    Raises:
        Exception: If the file does not exist or operation is not supported
    """
    pass

Dependencies { .dependencies }

apache-airflow-providers-ftp { .dependency }

Provides FTP protocol operations for Apache Airflow including hooks for file metadata retrieval.

Version

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