dabla commented on code in PR #76971:
URL: https://github.com/apache/airflow/pull/76971#discussion_r4639958014
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/s3_to_wasb.py:
##########
@@ -246,27 +246,31 @@ def get_files_to_move(self) -> list[str]:
if not self.replace:
# Only grab the files from S3 that are not in Azure Blob already.
This will prevent any files that
- # exist in both S3 and Azure Blob from being overwritten. If a
blob_name is provided, check to
- # see if that blob exists
- azure_blob_files: list[str] = []
+ # exist in both S3 and Azure Blob from being overwritten. Compare
the blob name that move_file()
+ # writes, because the listing returns full blob names while
files_to_move holds names relative to
+ # s3_prefix.
+ azure_blob_files: set[str] = set()
if self.blob_name:
- # If the singular blob (stored at self.blob_name) exists, add
it to azure_blob_files so it
- # can be removed from the list of files to move
+ # If the singular blob (stored at self.blob_name) exists, add
it so it can be removed from
+ # the list of files to move
if self.wasb_hook.check_for_blob(self.container_name,
self.blob_name):
- azure_blob_files.append(self.blob_name.split("/")[-1])
+ azure_blob_files.add(self.blob_name)
Review Comment:
**[warning]** The `blob_name` change has no test that fails on main.
Moving from `self.blob_name.split("/")[-1]` to the full `self.blob_name`
fixes the case where the destination name differs from the `s3_key` basename.
But `test_get_file_to_move__both_key` uses `s3_key="TEST/TEST1.csv"` with
`blob_name="TEST/TEST1.csv"`, so both basenames are `TEST1.csv` and the test
passes before and after the change. A row with a different destination name,
for example `blob_name="dest/renamed.csv"` with `check_for_blob` returning
`True` and `[]` expected, returns `["TEST1.csv"]` on main and `[]` here. That
row would pin the behaviour change the PR body describes.
##########
providers/microsoft/azure/tests/unit/microsoft/azure/transfers/test_s3_to_wasb.py:
##########
@@ -210,6 +225,54 @@ def test_get_files_to_move__s3_key_wasb_prefix(self,
wasb_mock_hook, wasb_existi
uploaded_files = operator.get_files_to_move()
assert sorted(uploaded_files) == sorted(returned_files)
+
@mock.patch("airflow.providers.microsoft.azure.transfers.s3_to_wasb.S3Hook")
Review Comment:
**[nit]** The two new tests patch `S3Hook`, `WasbHook` and
`NamedTemporaryFile` without `autospec=True`.
[AGENTS.md](https://github.com/apache/airflow/blob/main/AGENTS.md) asks for
`spec`/`autospec` when mocking. With autospec, a renamed hook method
(`get_blobs_list_recursive`, `load_file`) fails the test instead of passing
against a free-form mock. The older tests in this file have the same pattern,
so this only applies to the two new ones.
--
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]