utkarsharma2 commented on code in PR #31360:
URL: https://github.com/apache/airflow/pull/31360#discussion_r1228176588
##########
airflow/providers/sftp/operators/sftp.py:
##########
@@ -188,3 +191,85 @@ def execute(self, context: Any) -> str | list[str] | None:
raise AirflowException(f"Error while transferring {file_msg},
error: {str(e)}")
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,
+ )
+
+ if self.sftp_hook is not None:
+ hook = self.sftp_hook
+ elif self.ssh_hook is not None:
+ hook = self.ssh_hook
+ else:
+ hook = SFTPHook(ssh_conn_id=self.ssh_conn_id)
+
+ if self.remote_host is not None:
+ remote_host = self.remote_host
+ else:
+ remote_host = hook.get_connection(hook.ssh_conn_id).host
Review Comment:
If the hook is initialized from `self.sftp_hook` will it still have
`hook.ssh_conn_id`??
--
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]