-
Notifications
You must be signed in to change notification settings - Fork 16.6k
In S3ToGcsOperator return the list of copied files even in deferrable mode #49768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,10 +17,10 @@ | |
| # under the License. | ||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Sequence | ||
| from collections.abc import Iterable, Sequence | ||
| from datetime import datetime, timezone | ||
| from tempfile import NamedTemporaryFile | ||
| from typing import TYPE_CHECKING, Any | ||
| from typing import TYPE_CHECKING, Any, overload | ||
|
|
||
| from airflow.configuration import conf | ||
| from airflow.exceptions import AirflowException | ||
|
|
@@ -281,6 +281,7 @@ def transfer_files_async(self, files: list[str], gcs_hook: GCSHook, s3_hook: S3H | |
| poll_interval=self.poll_interval, | ||
| ), | ||
| method_name="execute_complete", | ||
| kwargs=dict(files=files), | ||
| ) | ||
|
|
||
| def submit_transfer_jobs(self, files: list[str], gcs_hook: GCSHook, s3_hook: S3Hook) -> list[str]: | ||
|
|
@@ -335,7 +336,15 @@ def submit_transfer_jobs(self, files: list[str], gcs_hook: GCSHook, s3_hook: S3H | |
|
|
||
| return job_names | ||
|
|
||
| def execute_complete(self, context: Context, event: dict[str, Any]) -> None: | ||
| @overload | ||
| def execute_complete(self, context: Context, event: dict[str, Any], files: None) -> None: ... | ||
| @overload | ||
| def execute_complete( | ||
| self, context: Context, event: dict[str, Any], files: Iterable[str] | ||
| ) -> list[str]: ... | ||
| def execute_complete( | ||
| self, context: Context, event: dict[str, Any], files: Iterable[str] | None = None | ||
| ) -> list[str] | None: | ||
|
Comment on lines
+339
to
+347
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlexisBRENON as I understand you want to overload the I think it is better to put
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You get it right. I tried to make the Passing it through the Trigger and then the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlexisBRENON yes, sure
Because it is not a common practice and attributes in P.S. We can look for one more solution for this issue. We can make the |
||
| """ | ||
| Return immediately and relies on trigger to throw a success event. Callback for the trigger. | ||
|
|
||
|
|
@@ -345,6 +354,7 @@ def execute_complete(self, context: Context, event: dict[str, Any]) -> None: | |
| if event["status"] == "error": | ||
| raise AirflowException(event["message"]) | ||
| self.log.info("%s completed with response %s ", self.task_id, event["message"]) | ||
| return None if files is None else list(files) | ||
|
|
||
| def get_transfer_hook(self): | ||
| return CloudDataTransferServiceHook( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexisBRENON could you please clarify what behavior you want to achieve by this line?
If you want to put
filestotriggeror return it fromexecute_completethen it is better to add it as an attribute toCloudStorageTransferServiceCreateJobsTrigger.