Skip to content

Commit

Permalink
add 'prefix' option to Beaker.dataset.fetch() (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh authored Jul 28, 2023
1 parent dd7a2ca commit dd29556
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ use patch releases for compatibility fixes instead.

## Unreleased

### Added

- Added `prefix` parameter to `Beaker.dataset.fetch()`.

## [v1.19.0](https://github.com/allenai/beaker-py/releases/tag/v1.19.0) - 2023-07-17

### Added
Expand Down
6 changes: 5 additions & 1 deletion beaker/services/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def fetch(
self,
dataset: Union[str, Dataset],
target: Optional[PathOrStr] = None,
prefix: Optional[str] = None,
force: bool = False,
max_workers: Optional[int] = None,
quiet: bool = False,
Expand All @@ -217,7 +218,8 @@ def fetch(
Download a dataset.
:param dataset: The dataset ID, name, or object.
:param target: The target path to fetched data. Defaults to ``Path(.)``.
:param target: The target path to download fetched data to. Defaults to ``Path(.)``.
:param prefix: Only download files that start with the given prefix.
:param max_workers: The maximum number of thread pool workers to use to download files concurrently.
:param force: If ``True``, existing local files will be overwritten.
:param quiet: If ``True``, progress won't be displayed.
Expand Down Expand Up @@ -271,6 +273,8 @@ def fetch(
download_futures = []
try:
for file_info in dataset_info.page.data:
if prefix is not None and not file_info.path.startswith(prefix):
continue
target_path = target / Path(file_info.path)
if not force and target_path.exists():
raise FileExistsError(file_info.path)
Expand Down

0 comments on commit dd29556

Please sign in to comment.