Skip to content

Commit

Permalink
Merge pull request #6704 from adswa/enh-unlock-pbs
Browse files Browse the repository at this point in the history
ENH: Enable progress bars for unlock, fixes #6691
  • Loading branch information
yarikoptic committed May 31, 2022
2 parents d75b8c0 + 01d2619 commit aa34666
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions datalad/local/unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
)
from datalad.interface.results import get_status_dict
from datalad.interface.utils import eval_results
from datalad.log import log_progress
from datalad.support.constraints import (
EnsureNone,
EnsureStr,
Expand Down Expand Up @@ -167,12 +168,34 @@ def __call__(

# Do the actual unlocking.
for ds_path, files in to_unlock.items():
# register for final orderly take down
pbar_id = f'unlock-{ds_path}'
nfiles = len(files)
log_progress(
lgr.info, pbar_id,
'Unlocking files',
unit=' Files',
label='Unlocking',
total=nfiles,
)
ds = Dataset(ds_path)
for r in ds.repo._call_annex_records(
for r in ds.repo._call_annex_records_items_(
["unlock"],
files=files):
files=files,
):
log_progress(
lgr.info, pbar_id, "Files to unlock %i", nfiles, update=1, increment=True)
nfiles -= 1
yield get_status_dict(
path=op.join(ds.path, r['file']),
status='ok' if r['success'] else 'error',
type='file',
**res_kwargs)
if nfiles < 1:
# git-annex will spend considerable time after the last
# file record to finish things up, let this be known
log_progress(
lgr.info, pbar_id, "Recording unlocked state in git", update=0, increment=True)

log_progress(
lgr.info, pbar_id, "Completed unlocking files")

0 comments on commit aa34666

Please sign in to comment.