tessl install tessl/pypi-apache-airflow-providers-ftp@3.13.0Provider 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%
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.
The utility must provide two core functions:
A function that retrieves the modification timestamp of a remote file on an FTP server, given:
The function should return the modification time as a datetime object.
A function that retrieves the size of a remote file on an FTP server, given:
The function should return the file size in bytes as an integer, or None if the size cannot be determined.
Both functions should handle cases where:
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
@generates
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
"""
passProvides FTP protocol operations for Apache Airflow including hooks for file metadata retrieval.