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: get metadata dict from s3 bucket with last modified date and siz… #69

Merged
merged 6 commits into from
Oct 6, 2023

Conversation

GHCamille
Copy link
Collaborator

add: get metadata dict from s3 bucket with last modified date and size in GB

@ghost
Copy link

ghost commented Sep 13, 2023

Nice of you to open a PR 🙏
When you're ready and want to get it reviewed, post a comment in this Pull Request with this message: /quack review

@GHCamille
Copy link
Collaborator Author

/quack review

Copy link

@ghost ghost left a 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
  • [missing-type-annotations] detected at pyro_risks/utils/s3.py:L137
  • [intermediate-variable] detected at pyro_risks/utils/s3.py:L150
  • [intermediate-variable] detected at pyro_risks/utils/s3.py:L151
  • [intermediate-variable] detected at 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

    @@ -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):
    Copy link

    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

    files = []
    for obj in self.bucket.objects.all():
    if not pattern or pattern in obj.key:
    file_name = obj.key
    Copy link

    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

    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)
    Copy link

    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

    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
    Copy link

    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

    @GHCamille
    Copy link
    Collaborator Author

    /quack review

    Copy link

    @ghost ghost left a 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
  • [missing-type-annotations] detected at 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

    @@ -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):
    Copy link

    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

    @GHCamille
    Copy link
    Collaborator Author

    /quack review

    Copy link

    @ghost ghost left a 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 🥳

    @GHCamille
    Copy link
    Collaborator Author

    /quack review

    Copy link

    @ghost ghost left a 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
  • [missing-type-annotations] detected at 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

    @@ -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:
    Copy link

    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

    @GHCamille
    Copy link
    Collaborator Author

    /quack review

    Copy link

    @ghost ghost left a 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 🥳

    Copy link
    Collaborator

    @juldpnt juldpnt left a 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 !

    @GHCamille GHCamille modified the milestone: 0.1.1 Oct 5, 2023
    @juldpnt juldpnt merged commit 4079545 into master Oct 6, 2023
    3 of 10 checks passed
    @juldpnt juldpnt deleted the get-metadata-s3 branch October 6, 2023 09:28
    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.

    2 participants