apache-airflow-providers-sftp 4.4.0__py3-none-any.whl → 4.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airflow/providers/sftp/__init__.py +4 -2
- airflow/providers/sftp/get_provider_info.py +1 -0
- airflow/providers/sftp/operators/sftp.py +82 -0
- {apache_airflow_providers_sftp-4.4.0.dist-info → apache_airflow_providers_sftp-4.5.0.dist-info}/METADATA +15 -12
- {apache_airflow_providers_sftp-4.4.0.dist-info → apache_airflow_providers_sftp-4.5.0.dist-info}/RECORD +10 -10
- {apache_airflow_providers_sftp-4.4.0.dist-info → apache_airflow_providers_sftp-4.5.0.dist-info}/WHEEL +1 -1
- {apache_airflow_providers_sftp-4.4.0.dist-info → apache_airflow_providers_sftp-4.5.0.dist-info}/LICENSE +0 -0
- {apache_airflow_providers_sftp-4.4.0.dist-info → apache_airflow_providers_sftp-4.5.0.dist-info}/NOTICE +0 -0
- {apache_airflow_providers_sftp-4.4.0.dist-info → apache_airflow_providers_sftp-4.5.0.dist-info}/entry_points.txt +0 -0
- {apache_airflow_providers_sftp-4.4.0.dist-info → apache_airflow_providers_sftp-4.5.0.dist-info}/top_level.txt +0 -0
@@ -28,14 +28,16 @@ import packaging.version
|
|
28
28
|
|
29
29
|
__all__ = ["__version__"]
|
30
30
|
|
31
|
-
__version__ = "4.
|
31
|
+
__version__ = "4.5.0"
|
32
32
|
|
33
33
|
try:
|
34
34
|
from airflow import __version__ as airflow_version
|
35
35
|
except ImportError:
|
36
36
|
from airflow.version import version as airflow_version
|
37
37
|
|
38
|
-
if packaging.version.parse(airflow_version) < packaging.version.parse(
|
38
|
+
if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
|
39
|
+
"2.4.0"
|
40
|
+
):
|
39
41
|
raise RuntimeError(
|
40
42
|
f"The package `apache-airflow-providers-sftp:{__version__}` requires Apache Airflow 2.4.0+" # NOQA: E501
|
41
43
|
)
|
@@ -19,10 +19,13 @@
|
|
19
19
|
from __future__ import annotations
|
20
20
|
|
21
21
|
import os
|
22
|
+
import socket
|
22
23
|
import warnings
|
23
24
|
from pathlib import Path
|
24
25
|
from typing import Any, Sequence
|
25
26
|
|
27
|
+
import paramiko
|
28
|
+
|
26
29
|
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
|
27
30
|
from airflow.models import BaseOperator
|
28
31
|
from airflow.providers.sftp.hooks.sftp import SFTPHook
|
@@ -188,3 +191,82 @@ class SFTPOperator(BaseOperator):
|
|
188
191
|
raise AirflowException(f"Error while transferring {file_msg}, error: {str(e)}")
|
189
192
|
|
190
193
|
return self.local_filepath
|
194
|
+
|
195
|
+
def get_openlineage_facets_on_start(self):
|
196
|
+
"""
|
197
|
+
This returns OpenLineage datasets in format:
|
198
|
+
input: file://<local_host>/path
|
199
|
+
output: file://<remote_host>:<remote_port>/path.
|
200
|
+
"""
|
201
|
+
from openlineage.client.run import Dataset
|
202
|
+
|
203
|
+
from airflow.providers.openlineage.extractors import OperatorLineage
|
204
|
+
|
205
|
+
scheme = "file"
|
206
|
+
local_host = socket.gethostname()
|
207
|
+
try:
|
208
|
+
local_host = socket.gethostbyname(local_host)
|
209
|
+
except Exception as e:
|
210
|
+
self.log.warning(
|
211
|
+
f"Failed to resolve local hostname. Using the hostname got by socket.gethostbyname() without resolution. {e}", # noqa: E501
|
212
|
+
exc_info=True,
|
213
|
+
)
|
214
|
+
|
215
|
+
hook = self.sftp_hook or self.ssh_hook or SFTPHook(ssh_conn_id=self.ssh_conn_id)
|
216
|
+
|
217
|
+
if self.remote_host is not None:
|
218
|
+
remote_host = self.remote_host
|
219
|
+
else:
|
220
|
+
remote_host = hook.get_connection(hook.ssh_conn_id).host
|
221
|
+
|
222
|
+
try:
|
223
|
+
remote_host = socket.gethostbyname(remote_host)
|
224
|
+
except OSError as e:
|
225
|
+
self.log.warning(
|
226
|
+
f"Failed to resolve remote hostname. Using the provided hostname without resolution. {e}", # noqa: E501
|
227
|
+
exc_info=True,
|
228
|
+
)
|
229
|
+
|
230
|
+
if hasattr(hook, "port"):
|
231
|
+
remote_port = hook.port
|
232
|
+
elif hasattr(hook, "ssh_hook"):
|
233
|
+
remote_port = hook.ssh_hook.port
|
234
|
+
|
235
|
+
# Since v4.1.0, SFTPOperator accepts both a string (single file) and a list of
|
236
|
+
# strings (multiple files) as local_filepath and remote_filepath, and internally
|
237
|
+
# keeps them as list in both cases. But before 4.1.0, only single string is
|
238
|
+
# allowed. So we consider both cases here for backward compatibility.
|
239
|
+
if isinstance(self.local_filepath, str):
|
240
|
+
local_filepath = [self.local_filepath]
|
241
|
+
else:
|
242
|
+
local_filepath = self.local_filepath
|
243
|
+
if isinstance(self.remote_filepath, str):
|
244
|
+
remote_filepath = [self.remote_filepath]
|
245
|
+
else:
|
246
|
+
remote_filepath = self.remote_filepath
|
247
|
+
|
248
|
+
local_datasets = [
|
249
|
+
Dataset(namespace=self._get_namespace(scheme, local_host, None, path), name=path)
|
250
|
+
for path in local_filepath
|
251
|
+
]
|
252
|
+
remote_datasets = [
|
253
|
+
Dataset(namespace=self._get_namespace(scheme, remote_host, remote_port, path), name=path)
|
254
|
+
for path in remote_filepath
|
255
|
+
]
|
256
|
+
|
257
|
+
if self.operation.lower() == SFTPOperation.GET:
|
258
|
+
inputs = remote_datasets
|
259
|
+
outputs = local_datasets
|
260
|
+
else:
|
261
|
+
inputs = local_datasets
|
262
|
+
outputs = remote_datasets
|
263
|
+
|
264
|
+
return OperatorLineage(
|
265
|
+
inputs=inputs,
|
266
|
+
outputs=outputs,
|
267
|
+
)
|
268
|
+
|
269
|
+
def _get_namespace(self, scheme, host, port, path) -> str:
|
270
|
+
port = port or paramiko.config.SSH_PORT
|
271
|
+
authority = f"{host}:{port}"
|
272
|
+
return f"{scheme}://{authority}"
|
@@ -1,14 +1,14 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: apache-airflow-providers-sftp
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.5.0
|
4
4
|
Summary: Provider for Apache Airflow. Implements apache-airflow-providers-sftp package
|
5
5
|
Home-page: https://airflow.apache.org/
|
6
6
|
Download-URL: https://archive.apache.org/dist/airflow/providers
|
7
7
|
Author: Apache Software Foundation
|
8
8
|
Author-email: dev@airflow.apache.org
|
9
9
|
License: Apache License 2.0
|
10
|
-
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-sftp/4.
|
11
|
-
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-sftp/4.
|
10
|
+
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-sftp/4.5.0/
|
11
|
+
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-sftp/4.5.0/changelog.html
|
12
12
|
Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
|
13
13
|
Project-URL: Source Code, https://github.com/apache/airflow
|
14
14
|
Project-URL: Slack Chat, https://s.apache.org/airflow-slack
|
@@ -33,6 +33,8 @@ License-File: LICENSE
|
|
33
33
|
License-File: NOTICE
|
34
34
|
Requires-Dist: apache-airflow-providers-ssh (>=2.1.0)
|
35
35
|
Requires-Dist: apache-airflow (>=2.4.0)
|
36
|
+
Provides-Extra: openlineage
|
37
|
+
Requires-Dist: apache-airflow-providers-openlineage ; extra == 'openlineage'
|
36
38
|
Provides-Extra: ssh
|
37
39
|
Requires-Dist: apache-airflow-providers-ssh ; extra == 'ssh'
|
38
40
|
|
@@ -74,7 +76,7 @@ Requires-Dist: apache-airflow-providers-ssh ; extra == 'ssh'
|
|
74
76
|
|
75
77
|
Package ``apache-airflow-providers-sftp``
|
76
78
|
|
77
|
-
Release: ``4.
|
79
|
+
Release: ``4.5.0``
|
78
80
|
|
79
81
|
|
80
82
|
`SSH File Transfer Protocol (SFTP) <https://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/>`__
|
@@ -87,7 +89,7 @@ This is a provider package for ``sftp`` provider. All classes for this provider
|
|
87
89
|
are in ``airflow.providers.sftp`` python package.
|
88
90
|
|
89
91
|
You can find package information and changelog for the provider
|
90
|
-
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-sftp/4.
|
92
|
+
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-sftp/4.5.0/>`_.
|
91
93
|
|
92
94
|
|
93
95
|
Installation
|
@@ -119,14 +121,15 @@ You can install such cross-provider dependencies when installing from PyPI. For
|
|
119
121
|
|
120
122
|
.. code-block:: bash
|
121
123
|
|
122
|
-
pip install apache-airflow-providers-sftp[
|
124
|
+
pip install apache-airflow-providers-sftp[openlineage]
|
123
125
|
|
124
126
|
|
125
|
-
|
126
|
-
Dependent package
|
127
|
-
|
128
|
-
`apache-airflow-providers-
|
129
|
-
|
127
|
+
============================================================================================================== ===============
|
128
|
+
Dependent package Extra
|
129
|
+
============================================================================================================== ===============
|
130
|
+
`apache-airflow-providers-openlineage <https://airflow.apache.org/docs/apache-airflow-providers-openlineage>`_ ``openlineage``
|
131
|
+
`apache-airflow-providers-ssh <https://airflow.apache.org/docs/apache-airflow-providers-ssh>`_ ``ssh``
|
132
|
+
============================================================================================================== ===============
|
130
133
|
|
131
134
|
The changelog for the provider package can be found in the
|
132
|
-
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-sftp/4.
|
135
|
+
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-sftp/4.5.0/changelog.html>`_.
|
@@ -1,18 +1,18 @@
|
|
1
|
-
airflow/providers/sftp/__init__.py,sha256=
|
2
|
-
airflow/providers/sftp/get_provider_info.py,sha256=
|
1
|
+
airflow/providers/sftp/__init__.py,sha256=mXow8LvnjpNw3VDueC-e8n8bgQz2PUD-x-9WmvEw3Ss,1573
|
2
|
+
airflow/providers/sftp/get_provider_info.py,sha256=kVwrdxtNsJvmNDcdx2y8PmboiiyGXFB9dO14NY2HY28,3410
|
3
3
|
airflow/providers/sftp/decorators/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
4
4
|
airflow/providers/sftp/decorators/sensors/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
5
5
|
airflow/providers/sftp/decorators/sensors/sftp.py,sha256=dRzXMgWf5SgGCQ2gOSvpzfJx8V9t98EorB0QZYccb94,2862
|
6
6
|
airflow/providers/sftp/hooks/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
7
7
|
airflow/providers/sftp/hooks/sftp.py,sha256=CHKPBzMr7oSW9nBQ8sExdD9zi50aUGpjdnebiW10rzU,14745
|
8
8
|
airflow/providers/sftp/operators/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
9
|
-
airflow/providers/sftp/operators/sftp.py,sha256=
|
9
|
+
airflow/providers/sftp/operators/sftp.py,sha256=Mp5nWEZa9SdLCO-QahaDJ0CnT9y_t3zRlGBAkrblFrA,11475
|
10
10
|
airflow/providers/sftp/sensors/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
11
11
|
airflow/providers/sftp/sensors/sftp.py,sha256=tSN0e8cRtIuTxHDce9DaBVs2qadKLSl49dwpo-qcfUw,4410
|
12
|
-
apache_airflow_providers_sftp-4.
|
13
|
-
apache_airflow_providers_sftp-4.
|
14
|
-
apache_airflow_providers_sftp-4.
|
15
|
-
apache_airflow_providers_sftp-4.
|
16
|
-
apache_airflow_providers_sftp-4.
|
17
|
-
apache_airflow_providers_sftp-4.
|
18
|
-
apache_airflow_providers_sftp-4.
|
12
|
+
apache_airflow_providers_sftp-4.5.0.dist-info/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
|
13
|
+
apache_airflow_providers_sftp-4.5.0.dist-info/METADATA,sha256=U6wt--5ZRLaKaoJAgW04GcQQk3cqJ5E3MwxX2B3KeYc,5966
|
14
|
+
apache_airflow_providers_sftp-4.5.0.dist-info/NOTICE,sha256=m-6s2XynUxVSUIxO4rVablAZCvFq-wmLrqV91DotRBw,240
|
15
|
+
apache_airflow_providers_sftp-4.5.0.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
|
16
|
+
apache_airflow_providers_sftp-4.5.0.dist-info/entry_points.txt,sha256=aiWTzXS-mN60ugZ7sL3xJpUvaMjF5dXfF65JUMVaBcs,101
|
17
|
+
apache_airflow_providers_sftp-4.5.0.dist-info/top_level.txt,sha256=OeMVH5md7fr2QQWpnZoOWWxWO-0WH1IP70lpTVwopPg,8
|
18
|
+
apache_airflow_providers_sftp-4.5.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|