airflow.providers.ssh.utils.remote_job¶
Utilities for SSH remote job execution.
Attributes¶
Classes¶
Paths for remote job artifacts on the target system. |
Functions¶
|
Generate a unique job ID for remote execution. |
|
Build a POSIX shell wrapper that runs the command detached via nohup. |
|
Build a PowerShell wrapper that runs the command detached via Start-Process. |
|
Build a POSIX command to read log bytes from offset. |
|
Build a PowerShell command to read log bytes from offset. |
|
Build a POSIX command to get file size in bytes. |
|
Build a PowerShell command to get file size in bytes. |
|
Build a POSIX command to check if job completed and get exit code. |
|
Build a PowerShell command to check if job completed and get exit code. |
|
Build a POSIX command to kill the remote process. |
|
Build a PowerShell command to kill the remote process. |
|
Build a POSIX command to clean up the job directory. |
|
Build a PowerShell command to clean up the job directory. |
Build a command to detect if the remote system is POSIX-compliant. |
|
Build a command to detect if the remote system is Windows. |
Module Contents¶
- airflow.providers.ssh.utils.remote_job.WINDOWS_DEFAULT_BASE_DIR = '$env:TEMP\\airflow-ssh-jobs'[source]¶
- airflow.providers.ssh.utils.remote_job.generate_job_id(dag_id, task_id, run_id, try_number, suffix_length=8)[source]¶
Generate a unique job ID for remote execution.
Creates a deterministic identifier from the task context with a random suffix to ensure uniqueness across retries and potential race conditions.
- class airflow.providers.ssh.utils.remote_job.RemoteJobPaths[source]¶
Paths for remote job artifacts on the target system.
- airflow.providers.ssh.utils.remote_job.build_posix_wrapper_command(command, paths, environment=None)[source]¶
Build a POSIX shell wrapper that runs the command detached via nohup.
The wrapper: - Creates the job directory - Starts the command in the background with nohup - Redirects stdout/stderr to the log file - Writes the exit code atomically on completion - Writes the PID for potential cancellation
- airflow.providers.ssh.utils.remote_job.build_windows_wrapper_command(command, paths, environment=None)[source]¶
Build a PowerShell wrapper that runs the command detached via Start-Process.
The wrapper: - Creates the job directory - Starts the command in a new detached PowerShell process - Redirects stdout/stderr to the log file - Writes the exit code atomically on completion - Writes the PID for potential cancellation
- airflow.providers.ssh.utils.remote_job.build_posix_log_tail_command(log_file, offset, max_bytes)[source]¶
Build a POSIX command to read log bytes from offset.
- airflow.providers.ssh.utils.remote_job.build_windows_log_tail_command(log_file, offset, max_bytes)[source]¶
Build a PowerShell command to read log bytes from offset.
- airflow.providers.ssh.utils.remote_job.build_posix_file_size_command(file_path)[source]¶
Build a POSIX command to get file size in bytes.
- airflow.providers.ssh.utils.remote_job.build_windows_file_size_command(file_path)[source]¶
Build a PowerShell command to get file size in bytes.
- airflow.providers.ssh.utils.remote_job.build_posix_completion_check_command(exit_code_file)[source]¶
Build a POSIX command to check if job completed and get exit code.
- airflow.providers.ssh.utils.remote_job.build_windows_completion_check_command(exit_code_file)[source]¶
Build a PowerShell command to check if job completed and get exit code.
- airflow.providers.ssh.utils.remote_job.build_posix_kill_command(pid_file)[source]¶
Build a POSIX command to kill the remote process.
- airflow.providers.ssh.utils.remote_job.build_windows_kill_command(pid_file)[source]¶
Build a PowerShell command to kill the remote process.
- airflow.providers.ssh.utils.remote_job.build_posix_cleanup_command(job_dir)[source]¶
Build a POSIX command to clean up the job directory.
- Parameters:
job_dir (str) – Path to the job directory
- Returns:
Shell command to remove the directory
- Raises:
ValueError – If job_dir is not under the expected base directory
- Return type:
- airflow.providers.ssh.utils.remote_job.build_windows_cleanup_command(job_dir)[source]¶
Build a PowerShell command to clean up the job directory.
- Parameters:
job_dir (str) – Path to the job directory
- Returns:
PowerShell command to remove the directory
- Raises:
ValueError – If job_dir is not under the expected base directory
- Return type: