Skip to content

Add tmp_root argument to publish()#45

Merged
hagenw merged 3 commits into
mainfrom
tmp-root-argument
May 13, 2026
Merged

Add tmp_root argument to publish()#45
hagenw merged 3 commits into
mainfrom
tmp-root-argument

Conversation

@hagenw
Copy link
Copy Markdown
Member

@hagenw hagenw commented May 13, 2026

Closes #44

Adds tmp_root as argument to audb.publish(). When not None the archive with the model files will be generated inside the provided folder.

image

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 13, 2026

Reviewer's Guide

Adds an optional tmp_root parameter to model publishing so temporary archives can be created under a caller-provided directory, and wires this through backend.put_archive with tests to ensure directory creation and cleanup semantics.

Sequence diagram for tmp_root handling in publish

sequenceDiagram
    actor Client
    participant publish
    participant backend_put_archive as backend.put_archive
    participant audeer_mkdir as audeer.mkdir
    participant tempfile_TemporaryDirectory as tempfile.TemporaryDirectory

    Client->>publish: publish(root, repository, subgroup, tmp_root)
    publish->>backend_put_archive: put_archive(root, backend_interface, verbose, tmp_root)

    alt tmp_root is not None
        backend_put_archive->>audeer_mkdir: mkdir(tmp_root)
        audeer_mkdir-->>backend_put_archive: tmp_root
        backend_put_archive->>tempfile_TemporaryDirectory: TemporaryDirectory(dir=tmp_root)
    else tmp_root is None
        backend_put_archive->>tempfile_TemporaryDirectory: TemporaryDirectory(dir=None)
    end

    tempfile_TemporaryDirectory-->>backend_put_archive: tmp_root
    backend_put_archive-->>publish: archive_path
    publish-->>Client: archive_path
Loading

File-Level Changes

Change Details Files
Allow publish/put_archive to stage temporary archives under a caller-provided tmp_root directory instead of the system temp folder.
  • Extend backend.put_archive signature with optional tmp_root argument and document its behavior.
  • Ensure a provided tmp_root path is created with audeer.mkdir before use.
  • Use tempfile.TemporaryDirectory(dir=tmp_root) to stage the model.zip archive inside the given directory or system default when None.
  • Thread tmp_root parameter through api.publish to backend.put_archive and document the new argument in the public API docstring.
audmodel/core/backend.py
audmodel/core/api.py
Add a regression test to verify tmp_root directory creation and cleanup semantics when publishing.
  • Introduce test_publish_tmp_root to publish with a custom tmp_root path that does not yet exist.
  • Assert that publishing succeeds, that tmp_root directory is created, and that it remains empty after TemporaryDirectory cleanup.
tests/test_publish.py

Assessment against linked issues

Issue Objective Addressed Explanation
#44 Add an argument to audmodel.publish() that allows callers to specify a custom temporary directory used for creating the model archive, instead of always using the system default temp folder.
#44 Implement the plumbing and behavior so that the specified temporary directory is created if needed, used for staging the archive, and otherwise falls back to the system default temp directory when not provided, with corresponding documentation/tests.

Possibly linked issues


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

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (632b112) to head (f2dbbe0).

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

sourcery-ai[bot]

This comment was marked as resolved.

@hagenw hagenw self-assigned this May 13, 2026
@hagenw hagenw requested a review from frankenjoe May 13, 2026 06:23
Comment thread audmodel/core/backend.py
@hagenw hagenw merged commit 6373645 into main May 13, 2026
12 checks passed
@hagenw hagenw deleted the tmp-root-argument branch May 13, 2026 12:55
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.

Add tmpdir argument to audb.publish()

2 participants