-
-
Notifications
You must be signed in to change notification settings - Fork 8
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: get metadata dict from s3 bucket with last modified date and siz… #69
Conversation
Nice of you to open a PR 🙏 |
/quack review |
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.
Thanks for the PR 🙏
Other sections
pyro_risks/utils/s3.py:L137
pyro_risks/utils/s3.py:L150
pyro_risks/utils/s3.py:L151
pyro_risks/utils/s3.py:L152
For a better experience, it's recommended to check the review comments in the tab Files Changed.
Feedback is a gift! Quack will adjust your review style when you add reactions to a review comment
pyro_risks/utils/s3.py
Outdated
@@ -133,3 +133,28 @@ def get_file_metadata(self, object_key): | |||
obj = self.bucket.Object(object_key) | |||
metadata = obj.metadata | |||
return metadata | |||
|
|||
def get_files_metadata(self, pattern=None): |
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.
Would you mind adding type annotations? 🙏
Pattern explanation 👈
In Python, type annotations are not enforced. But that can be valuable for debugging using mypy, for your collaborators' understanding, and the autocomplete of your IDE. For more details, feel free to check this resource.Code example
Here is an example of how this is typically handled:
# def is_upper(variable_name):
def is_upper(variable_name: str) -> bool:
Quack feedback loop 👍👎
This comment is about [missing-type-annotations]. Add the following reactions on this comment to let us know if:- 👍 that comment was on point
- 👀 that doesn't seem right
- 👎 this isn't important for you right now
- 😕 that explanation wasn't clear
pyro_risks/utils/s3.py
Outdated
files = [] | ||
for obj in self.bucket.objects.all(): | ||
if not pattern or pattern in obj.key: | ||
file_name = obj.key |
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.
It doesn't look like we need this intermediate variable
Pattern explanation 👈
You shouldn't concede readability, but when it's possible, avoid unnecessary memory allocation. For more details, feel free to check this resource.Code example
Here is an example of how this is typically handled:
# def make_upper(input_str: str) -> str:
# upper_str = input_str.upper()
# return upper_str
def make_upper(input_str: str) -> str:
return input_str.upper()
Quack feedback loop 👍👎
This comment is about [intermediate-variable]. Add the following reactions on this comment to let us know if:- 👍 that comment was on point
- 👀 that doesn't seem right
- 👎 this isn't important for you right now
- 😕 that explanation wasn't clear
pyro_risks/utils/s3.py
Outdated
for obj in self.bucket.objects.all(): | ||
if not pattern or pattern in obj.key: | ||
file_name = obj.key | ||
file_size = round(obj.size * 1.0 / (1024*1000000), 2) |
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.
It doesn't look like we need this intermediate variable
Pattern explanation 👈
You shouldn't concede readability, but when it's possible, avoid unnecessary memory allocation. For more details, feel free to check this resource.Code example
Here is an example of how this is typically handled:
# def make_upper(input_str: str) -> str:
# upper_str = input_str.upper()
# return upper_str
def make_upper(input_str: str) -> str:
return input_str.upper()
Quack feedback loop 👍👎
This comment is about [intermediate-variable]. Add the following reactions on this comment to let us know if:- 👍 that comment was on point
- 👀 that doesn't seem right
- 👎 this isn't important for you right now
- 😕 that explanation wasn't clear
pyro_risks/utils/s3.py
Outdated
if not pattern or pattern in obj.key: | ||
file_name = obj.key | ||
file_size = round(obj.size * 1.0 / (1024*1000000), 2) | ||
file_last_modified = obj.last_modified |
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.
It doesn't look like we need this intermediate variable
Pattern explanation 👈
You shouldn't concede readability, but when it's possible, avoid unnecessary memory allocation. For more details, feel free to check this resource.Code example
Here is an example of how this is typically handled:
# def make_upper(input_str: str) -> str:
# upper_str = input_str.upper()
# return upper_str
def make_upper(input_str: str) -> str:
return input_str.upper()
Quack feedback loop 👍👎
This comment is about [intermediate-variable]. Add the following reactions on this comment to let us know if:- 👍 that comment was on point
- 👀 that doesn't seem right
- 👎 this isn't important for you right now
- 😕 that explanation wasn't clear
/quack review |
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.
Thanks for the PR 🙏
Other sections
pyro_risks/utils/s3.py:L137
For a better experience, it's recommended to check the review comments in the tab Files Changed.
Feedback is a gift! Quack will adjust your review style when you add reactions to a review comment
pyro_risks/utils/s3.py
Outdated
@@ -133,3 +133,25 @@ def get_file_metadata(self, object_key): | |||
obj = self.bucket.Object(object_key) | |||
metadata = obj.metadata | |||
return metadata | |||
|
|||
def get_files_metadata(self, pattern=None): |
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.
Would you mind adding type annotations? 🙏
Pattern explanation 👈
In Python, type annotations are not enforced. But that can be valuable for debugging using mypy, for your collaborators' understanding, and the autocomplete of your IDE. For more details, feel free to check this resource.Code example
Here is an example of how this is typically handled:
# def is_upper(variable_name):
def is_upper(variable_name: str) -> bool:
Quack feedback loop 👍👎
This comment is about [missing-type-annotations]. Add the following reactions on this comment to let us know if:- 👍 that comment was on point
- 👀 that doesn't seem right
- 👎 this isn't important for you right now
- 😕 that explanation wasn't clear
/quack review |
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.
Thanks for the PR 🙏
Nothing to report from Quack 🥳
/quack review |
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.
Thanks for the PR 🙏
Other sections
pyro_risks/utils/s3.py:L78
For a better experience, it's recommended to check the review comments in the tab Files Changed.
Feedback is a gift! Quack will adjust your review style when you add reactions to a review comment
pyro_risks/utils/s3.py
Outdated
@@ -75,7 +75,7 @@ def __init__( | |||
self.s3 = self.session.resource("s3", endpoint_url=endpoint_url) | |||
self.bucket = self.s3.Bucket(bucket_name) | |||
|
|||
def upload_file(self, file_path, object_key): | |||
def upload_file(self, file_path, object_key: str) -> None: |
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.
Would you mind adding type annotations? 🙏
Pattern explanation 👈
In Python, type annotations are not enforced. But that can be valuable for debugging using mypy, for your collaborators' understanding, and the autocomplete of your IDE. For more details, feel free to check this resource.Code example
Here is an example of how this is typically handled:
# def is_upper(variable_name):
def is_upper(variable_name: str) -> bool:
Quack feedback loop 👍👎
This comment is about [missing-type-annotations]. Add the following reactions on this comment to let us know if:- 👍 that comment was on point
- 👀 that doesn't seem right
- 👎 this isn't important for you right now
- 😕 that explanation wasn't clear
/quack review |
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.
Thanks for the PR 🙏
Nothing to report from Quack 🥳
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.
Thanks for the additions !
add: get metadata dict from s3 bucket with last modified date and size in GB