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

Add use_regex param in S3KeySensor #1172

Merged
merged 2 commits into from Jun 12, 2023
Merged

Add use_regex param in S3KeySensor #1172

merged 2 commits into from Jun 12, 2023

Conversation

pankajastro
Copy link
Contributor

@pankajastro pankajastro commented Jun 6, 2023

closes: #1154

@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a4569fc) 98.58% compared to head (41c852c) 98.59%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1172   +/-   ##
=======================================
  Coverage   98.58%   98.59%           
=======================================
  Files          90       90           
  Lines        5387     5395    +8     
=======================================
+ Hits         5311     5319    +8     
  Misses         76       76           
Impacted Files Coverage Δ
astronomer/providers/amazon/aws/hooks/s3.py 98.73% <100.00%> (+0.04%) ⬆️
astronomer/providers/amazon/aws/sensors/s3.py 100.00% <100.00%> (ø)
astronomer/providers/amazon/aws/triggers/s3.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pankajastro pankajastro marked this pull request as ready for review June 6, 2023 18:34
astronomer/providers/amazon/aws/hooks/s3.py Show resolved Hide resolved
tests/amazon/aws/hooks/test_s3_hooks.py Outdated Show resolved Hide resolved
@pankajastro pankajastro merged commit a2659f4 into main Jun 12, 2023
10 checks passed
@pankajastro pankajastro deleted the add_use_regex branch June 12, 2023 08:51
"""
bucket_name, key = S3Hook.get_s3_bucket_key(bucket_val, key, "bucket_name", "bucket_key")
if wildcard_match:
keys = await self.get_file_metadata(client, bucket_name, key)
key_matches = [k for k in keys if fnmatch.fnmatch(k["Key"], key)]
if len(key_matches) == 0:
return False
elif use_regex:
keys = await self.get_file_metadata(client, bucket_name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third parameter key (optional) is missing. Was this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, listing objects from s3 does not work well with regex search. We are using the key get_file_metadata for prefix search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow regex matching in S3KeySensorAsync
3 participants