Skip to content

Add owner argument to put_file()#297

Draft
hagenw wants to merge 2 commits into
mainfrom
add-owner-argument
Draft

Add owner argument to put_file()#297
hagenw wants to merge 2 commits into
mainfrom
add-owner-argument

Conversation

@hagenw

@hagenw hagenw commented Jun 26, 2026

Copy link
Copy Markdown
Member

On S3/Minio backends we store the owner of a file in metadata, so we set it during the upload. This is handy when copying/moving files from one repository to another with the goal of preserving the original ownership.

This pull requests implements this functionality with a focus on S3/Minio.

If this is a valid argument for backends as well and we should integrate it in the official API we should decide later. Until then this pull request is marked as draft.

@sourcery-ai

sourcery-ai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Introduces an optional owner argument to put_file across backends and interfaces, wiring it through to Minio where it is persisted as object metadata while other backends accept and ignore it, and updates the Minio metadata helper to default the owner to the current user when not provided.

Sequence diagram for put_file owner propagation to Minio backend

sequenceDiagram
    actor Client
    participant UnversionedInterface as UnversionedInterface
    participant BackendBase as BackendBase
    participant MinioBackend as MinioBackend
    participant MinioClient as MinioClient

    Client->>UnversionedInterface: put_file(src_path, dst_path, owner, validate, verbose)
    UnversionedInterface->>BackendBase: put_file(src_path, dst_path, owner, validate, verbose)
    BackendBase->>MinioBackend: _put_file(src_path, dst_path, checksum, owner, verbose)
    MinioBackend->>MinioBackend: _metadata(checksum, owner)
    alt [owner is None or empty]
        MinioBackend->>getpass: getpass.getuser()
        MinioBackend-->>MinioBackend: owner = current_user
    end
    MinioBackend->>MinioClient: fput_object(..., metadata=_metadata(checksum, owner))
Loading

Flow diagram for Minio _metadata owner resolution

flowchart TD
    A["_metadata(checksum, owner)"] --> B{owner provided?}
    B -- Yes --> C["Use given owner"]
    B -- No or empty --> D["getpass.getuser()"]
    D --> E["Set owner to current user"]
    C --> F["Return {checksum, owner}"]
    E --> F["Return {checksum, owner}"]
Loading

File-Level Changes

Change Details Files
Thread an optional owner parameter through the backend base API and public put_file interfaces (versioned and unversioned), including tests helpers.
  • Extend Backend._put_file signature to accept an owner parameter and propagate it from Backend.put_file, including docstring updates describing owner semantics and validation behavior.
  • Update unversioned and versioned interface put_file methods to accept an owner keyword argument with default None, pass it through to the backend, and document how different backends may use or ignore it.
  • Adapt test helper implementations (bad_file_system and singlefolder) to the new put_file/_put_file signatures by accepting and passing the owner argument.
audbackend/core/backend/base.py
audbackend/core/interface/unversioned.py
audbackend/core/interface/versioned.py
tests/bad_file_system.py
tests/singlefolder.py
Implement ownership metadata handling for the Minio backend, ensuring owner is stored in object metadata while preserving behavior for existing code paths like _copy_file.
  • Change MinioBackend._put_file signature to accept an owner argument and forward it to the metadata construction when uploading objects.
  • Update _metadata helper in the Minio backend to take an optional owner argument, defaulting to the current user when None or empty, and clarify its docstring to describe checksum and owner behavior.
  • Adjust MinioBackend._copy_file to call _put_file with an explicit owner placeholder (currently None) to satisfy the new signature while keeping copy behavior unchanged.
audbackend/core/backend/minio.py
Align non-owning backends’ implementations with the extended API while explicitly documenting that owner is ignored for them.
  • Update Artifactory backend _put_file signature to accept owner while leaving deployment logic unchanged, and document that Artifactory derives owner from the uploading user so the parameter is ignored.
  • Update filesystem backend _put_file signature to accept owner while keeping copy semantics unchanged, and document that filesystem-derived ownership means the owner argument is ignored.
audbackend/core/backend/artifactory.py
audbackend/core/backend/filesystem.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (34715af) to head (20bac45).

Additional details and impacted files
Files with missing lines Coverage Δ
audbackend/core/backend/artifactory.py 100.0% <ø> (ø)
audbackend/core/backend/base.py 100.0% <ø> (ø)
audbackend/core/backend/filesystem.py 100.0% <ø> (ø)
audbackend/core/backend/minio.py 100.0% <100.0%> (ø)
audbackend/core/interface/unversioned.py 100.0% <ø> (ø)
audbackend/core/interface/versioned.py 100.0% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant