Skip to content
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

Call S3 sensor check_fn only with file size attribute #1278

Merged
merged 3 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion astronomer/providers/amazon/aws/triggers/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
client, self.bucket_name, self.bucket_key, self.wildcard_match
)
await asyncio.sleep(self.poke_interval)
yield TriggerEvent({"status": "running", "files": s3_objects})
files = [{"Size": s3_object["Size"]} for s3_object in s3_objects]
yield TriggerEvent({"status": "running", "files": files})
else:
yield TriggerEvent({"status": "success"})
await asyncio.sleep(self.poke_interval)
Expand Down
4 changes: 2 additions & 2 deletions tests/amazon/aws/triggers/test_s3_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def test_run_exception(self, mock_client):
async def test_run_check_fn_success(self, mock_get_files, mock_client):
"""Test if the task is run is in trigger with check_fn."""

mock_get_files.return_value = ["test"]
mock_get_files.return_value = [{"Size": 123, "Key": "test.csv"}]
mock_client.return_value.check_key.return_value = True
trigger = S3KeyTrigger(
bucket_key="s3://test_bucket/file",
Expand All @@ -100,7 +100,7 @@ async def test_run_check_fn_success(self, mock_get_files, mock_client):
)
generator = trigger.run()
actual = await generator.asend(None)
assert TriggerEvent({"status": "running", "files": ["test"]}) == actual
assert TriggerEvent({"status": "running", "files": [{"Size": 123}]}) == actual


class TestS3KeysUnchangedTrigger:
Expand Down
Loading