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 audbackend.backend.Minio #231

Merged
merged 43 commits into from
Oct 30, 2024
Merged

Add audbackend.backend.Minio #231

merged 43 commits into from
Oct 30, 2024

Conversation

hagenw
Copy link
Member

@hagenw hagenw commented Sep 3, 2024

Implements a backend for MinIO.

MinIO is compatible with S3 storage, and we tested internally that this backend works with S3 storage on Hetzner and AWS. A test based on AWS is integrated in audeering/audb#450.

I decided to handle the authentication the same way as we do for audbackend.backend.Artifactory, by allowing to specify the username / password inside a config file or environment variable. In addition, we have the class method audbackend.backend.Minio.get_authentication() to retrieve them, in order to check their values.
For local MinIO servers we also need to set the secure argument to False. I added this to the config file as well, in oder to make it part of the backend configuration, and added the class method audbackend.backend.Minio.get_config(), which returns all entries as dictionary.
In certain edge cases you might want to add other arguments to the underlying minio.Minio class. For that reason I decided to add support for **kwargs, but do no checks if there is any conflict with authentication as I think this is only for power users anyway.

image

image

image

Summary by Sourcery

Add support for MinIO as a new backend in the audbackend library, enabling storage operations with MinIO. Refactor tests to accommodate the new backend and ensure robust testing of its functionality.

New Features:

  • Introduce a new backend for MinIO, allowing integration with MinIO storage systems.

Enhancements:

  • Refactor test parameterization to use a centralized list of backend-interface combinations, improving test maintainability.

Tests:

  • Add comprehensive tests for the new MinIO backend, including authentication, file operations, and configuration parsing.

@hagenw hagenw marked this pull request as draft September 3, 2024 15:00
@hagenw hagenw changed the title Add audbackend.backend.MinIO Add audbackend.backend.Minio Sep 4, 2024
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.0%. Comparing base (937da89) to head (af109fc).
Report is 1 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
audbackend/backend/__init__.py 100.0% <100.0%> (ø)
audbackend/core/api.py 100.0% <100.0%> (ø)
audbackend/core/backend/minio.py 100.0% <100.0%> (ø)

@hagenw hagenw mentioned this pull request Oct 1, 2024
* Add support for owner()

* Be more conservative regarding owner
@hagenw hagenw marked this pull request as ready for review October 22, 2024 12:41
Copy link
Contributor

sourcery-ai bot commented Oct 22, 2024

Reviewer's Guide by Sourcery

This pull request implements a new backend for MinIO in the audbackend library. It adds support for MinIO storage, which is compatible with S3, and includes necessary changes to the existing codebase to integrate the new backend. The implementation follows a similar pattern to the existing Artifactory backend, with additional configuration options specific to MinIO.

Class diagram for the new Minio backend

classDiagram
    class Minio {
        - MinioClient _client
        + Minio(host: str, repository: str, authentication: Tuple[str, str] = None, secure: bool = None, **kwargs)
        + get_authentication(host: str) Tuple[str, str]
        + get_config(host: str) Dict
        + close()
        + _checksum(path: str) str
        + _collapse(path)
        + _copy_file(src_path: str, dst_path: str, verbose: bool)
        + _create()
        + _date(path: str) str
        + _delete()
        + _exists(path: str) bool
        + _get_file(src_path: str, dst_path: str, verbose: bool)
        + _ls(path: str) List[str]
        + _move_file(src_path: str, dst_path: str, verbose: bool)
        + _open()
        + _owner(path: str) str
        + path(path: str) str
        + _put_file(src_path: str, dst_path: str, checksum: str, verbose: bool)
        + _remove_file(path: str)
        + _size(path: str) int
    }
    class Base {
        <<abstract>>
    }
    Minio --|> Base
    note for Minio "This class implements a backend for MinIO storage, compatible with S3."
Loading

File-Level Changes

Change Details Files
Implement MinIO backend class
  • Create new Minio class inheriting from Base
  • Implement authentication and configuration methods
  • Add methods for file operations (put, get, copy, move, delete)
  • Handle large file transfers (>5GB) with a fallback mechanism
audbackend/core/backend/minio.py
Integrate MinIO backend into existing codebase
  • Register MinIO backend in core API
  • Add MinIO import in backend init.py
  • Update test configurations to include MinIO
  • Modify existing tests to accommodate MinIO backend
audbackend/core/api.py
audbackend/backend/__init__.py
tests/conftest.py
tests/test_interface_unversioned.py
tests/test_interface_versioned.py
tests/test_interface_maven.py
Add new tests for MinIO backend
  • Create test_backend_minio.py with comprehensive tests
  • Test authentication, configuration, and file operations
  • Add tests for content type handling and large file copying
tests/test_backend_minio.py
Update existing tests to include MinIO
  • Modify test_api.py to include MinIO in backend tests
  • Update test_interface_unversioned.py, test_interface_versioned.py, and test_interface_maven.py to include MinIO in interface tests
tests/test_api.py
tests/test_interface_unversioned.py
tests/test_interface_versioned.py
tests/test_interface_maven.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @hagenw - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Hardcoded MinIO access key found. (link)
  • Hardcoded MinIO secret key found. (link)
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🔴 Security: 2 blocking issues
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

audbackend/core/backend/minio.py Outdated Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
audbackend/core/backend/minio.py Outdated Show resolved Hide resolved
audbackend/core/backend/minio.py Outdated Show resolved Hide resolved
audbackend/core/backend/minio.py Show resolved Hide resolved
audbackend/core/backend/minio.py Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/test_backend_minio.py Outdated Show resolved Hide resolved
tests/test_backend_minio.py Show resolved Hide resolved
hagenw and others added 8 commits October 22, 2024 14:54
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@hagenw
Copy link
Member Author

hagenw commented Oct 22, 2024

I addressed now all comments and updated the description by mentioning our Hetzner S3 test.

@hagenw
Copy link
Member Author

hagenw commented Oct 30, 2024

As it works with audb (see audeering/audb#450), I will merge this in order to continue with related updates.

@hagenw hagenw merged commit 1d65670 into main Oct 30, 2024
10 checks passed
@hagenw hagenw deleted the minio branch October 30, 2024 14:14
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.

3 participants