Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion audmodel/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def load(
*,
cache_root: str | None = None,
timeout: float = 14400, # 4 h
num_workers: int = 1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider validating num_workers for positive integer values.

A check for num_workers > 0 will help prevent errors from invalid input.

verbose: bool = False,
) -> str:
r"""Download a model by its unique ID.
Expand All @@ -294,6 +295,7 @@ def load(
If not set :meth:`audmodel.default_cache_root` is used
timeout: maximum time in seconds
before giving up acquiring a lock
num_workers: number of parallel jobs
verbose: show debug messages

Returns:
Expand All @@ -313,7 +315,7 @@ def load(
"""
cache_root = audeer.safe_path(cache_root or default_cache_root())
short_id, version = split_uid(uid, cache_root)
return get_archive(short_id, version, cache_root, timeout, verbose)
return get_archive(short_id, version, cache_root, timeout, num_workers, verbose)


def meta(
Expand Down
4 changes: 4 additions & 0 deletions audmodel/core/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def get_archive(
version: str,
cache_root: str,
timeout: float,
num_workers: int,
verbose: bool,
) -> str:
r"""Return backend and local archive path.
Expand All @@ -70,6 +71,7 @@ def get_archive(
cache_root: path of cache root
timeout: maximum time in seconds
before giving up acquiring a lock
num_workers: number of parallel jobs
verbose: if ``True`` show message
or progress bar
when downloading file
Expand Down Expand Up @@ -106,6 +108,7 @@ def get_archive(
src_path,
dst_path,
version,
num_workers=num_workers,
verbose=verbose,
)

Expand All @@ -114,6 +117,7 @@ def get_archive(
dst_path,
tmp_root,
keep_archive=False,
num_workers=num_workers,
verbose=verbose,
)

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ classifiers = [
]
requires-python = '>=3.10'
dependencies = [
'audbackend[all] >=2.2.2',
'audbackend[all] >=2.3.0',
'audeer @ git+https://github.com/audeering/audeer.git@archive-num-workers-2',
'filelock',
'oyaml',
]
Expand Down