Skip to content

Commit

Permalink
[GH-370] Add --force-fast option to populate commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Nov 20, 2023
1 parent 275645d commit 600224f
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions tools/backups2datalad/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ async def release(
metavar="REGEX",
type=re.compile,
)
@click.option(
"--force-fast",
is_flag=True,
help="Always populate; do not skip population if Dandisets look backed up",
)
@click.option("-w", "--workers", type=int, help="Number of workers to run in parallel")
@click.argument("dandisets", nargs=-1)
@click.pass_obj
Expand All @@ -332,6 +337,7 @@ async def populate_cmd(
dandisets: Sequence[str],
exclude: Optional[re.Pattern[str]],
workers: Optional[int],
force_fast: bool,
) -> None:
async with datasetter:
if (r := datasetter.config.dandisets.remote) is not None:
Expand Down Expand Up @@ -360,6 +366,7 @@ async def populate_cmd(
pathtype="Dandiset",
jobs=datasetter.config.jobs,
has_github=datasetter.config.gh_org is not None,
force=force_fast,
),
afilter_installed(dirs),
workers=datasetter.config.workers,
Expand All @@ -369,12 +376,20 @@ async def populate_cmd(


@main.command()
@click.option(
"--force-fast",
is_flag=True,
help="Always populate; do not skip population if Zarrs look backed up",
)
@click.option("-w", "--workers", type=int, help="Number of workers to run in parallel")
@click.argument("zarrs", nargs=-1)
@click.pass_obj
@print_logfile
async def populate_zarrs(
datasetter: DandiDatasetter, zarrs: Sequence[str], workers: Optional[int]
datasetter: DandiDatasetter,
zarrs: Sequence[str],
workers: Optional[int],
force_fast: bool,
) -> None:
async with datasetter:
zcfg = datasetter.config.zarrs
Expand Down Expand Up @@ -405,6 +420,7 @@ async def populate_zarrs(
pathtype="Zarr",
jobs=datasetter.config.jobs,
has_github=datasetter.config.gh_org is not None,
force=force_fast,
),
afilter_installed(dirs),
workers=datasetter.config.workers,
Expand All @@ -427,11 +443,16 @@ async def zarr_checksum(dirpath: Path) -> None:


async def populate(
dirpath: Path, backup_remote: str, pathtype: str, jobs: int, has_github: bool
dirpath: Path,
backup_remote: str,
pathtype: str,
jobs: int,
has_github: bool,
force: bool = False,
) -> None:
desc = f"{pathtype} {dirpath.name}"
ds = AsyncDataset(dirpath)
if await ds.populate_up_to_date():
if not force and await ds.populate_up_to_date():
log.info("%s: no need to populate", desc)
return
log.info("Copying files for %s to backup remote", desc)
Expand Down

0 comments on commit 600224f

Please sign in to comment.