mobuchowski commented on code in PR #31354:
URL: https://github.com/apache/airflow/pull/31354#discussion_r1228381756


##########
airflow/providers/ftp/operators/ftp.py:
##########
@@ -135,6 +137,63 @@ def execute(self, context: Any) -> str | list[str] | None:
 
         return self.local_filepath
 
+    def get_openlineage_facets_on_start(self):
+        try:
+            from openlineage.client.run import Dataset
+
+            from airflow.providers.openlineage.extractors import 
OperatorLineage
+        except ImportError:
+            return None
+        scheme = "file"
+
+        local_host = socket.gethostname()
+        try:
+            local_host = socket.gethostbyname(local_host)
+        except Exception as e:
+            self.log.warning(
+                f"Failed to resolve local hostname. Using the hostname got by 
socket.gethostbyname() without resolution. {e}",  # noqa: E501
+                exc_info=True,
+            )
+
+        conn = self.hook.get_conn()
+        remote_host = conn.host
+        remote_port = conn.port
+
+        if isinstance(self.local_filepath, str):
+            local_filepath = [self.local_filepath]
+        else:
+            local_filepath = self.local_filepath
+        if isinstance(self.remote_filepath, str):
+            remote_filepath = [self.remote_filepath]
+        else:
+            remote_filepath = self.remote_filepath
+
+        local_datasets = [
+            Dataset(namespace=self._get_namespace(scheme, local_host, None, 
path), name=path)
+            for path in local_filepath
+        ]
+        remote_datasets = [
+            Dataset(namespace=self._get_namespace(scheme, remote_host, 
remote_port, path), name=path)
+            for path in remote_filepath
+        ]
+
+        if self.operation.lower() == FTPOperation.GET:
+            inputs = remote_datasets
+            outputs = local_datasets
+        else:
+            inputs = local_datasets
+            outputs = remote_datasets
+
+        return OperatorLineage(
+            inputs=inputs,

Review Comment:
   I don't see any relevant ones we could attach. That does not mean we can't 
add them later.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to