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

Liuxianyi/aws backend #984

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

liuxianyi
Copy link

@liuxianyi liuxianyi commented Mar 7, 2023

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Currently, mmengine can't support the cloud storage of amazon S3, so I pull a request to add this function.

Modification

  1. modify several files under tests/test_fileio, specifically, mmengine/fileio/backends/AWSbackend.py for function-related read and write. mmengine/fileio/file_client.py add into '_prefix_to_backends'.
  2. for new demand, add a test unit in tests/test_fileio/test_backends/test_aws_backend.py for ensuring the function formally operate.

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

raise ImportError('Please install boto3 to enable '
'AWS_Backend.')

self._client = boto3.client('s3')
Copy link
Collaborator

@zhouzaida zhouzaida Mar 8, 2023

Choose a reason for hiding this comment

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

The client accepts many parameters. Should we also support them?

class AWSBackend(BaseStorageBackend):
    def __init__(
        self,
        aws_access_key_id: Optional[[str] = None,
        aws_secret_access_key: Optional[[str] = None,
        path_mapping: Optional[dict] = None,
        client_kwargs: Optional[dict] = None,
    )  
        if client_kwargs is not None:
            client_kwargs = dict()
        self._client = boto3.client(
            's3',
            aws_access_key_id=aws_access_key_id,
            aws_secret_access_key=aws_secret_access_key,
            **client_kwargs
        )

@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@aeb5c45). Click here to learn what that means.
Patch has no changes to coverable lines.

❗ Current head 3ba5a9d differs from pull request most recent head 0c29b29. Consider uploading reports for the commit 0c29b29 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #984   +/-   ##
=======================================
  Coverage        ?   76.38%           
=======================================
  Files           ?      140           
  Lines           ?    11060           
  Branches        ?     2206           
=======================================
  Hits            ?     8448           
  Misses          ?     2251           
  Partials        ?      361           
Flag Coverage Δ
unittests 76.38% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

bucket) and not obj_name.endswith('/') and obj_name != '':
return True
return False

Copy link

Choose a reason for hiding this comment

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

join_path function is required to make the backend compatible with CheckpointHook to save models to AWS bucket. See this. You may simply take the one from PetrelBackend and it will work.

@GeorgePearse
Copy link

GeorgePearse commented Apr 27, 2023

Has this not been merged in due to the fact that the AWS / s3 backend does not implement the removal of prior checkpoints when best_checkpoint is used?

And is there a reasonable way to use it without forking mmengine?

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.

5 participants