Skip to content

Commit

Permalink
Merge pull request #6739 from adswa/enh-progress-addarchivecontent
Browse files Browse the repository at this point in the history
ENH: Improve add-archive-contents progressbar following #6735 & #6734
  • Loading branch information
adswa committed Jun 7, 2022
2 parents dc9a61d + f8ab6c5 commit 96a8584
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions datalad/local/add_archive_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,23 @@ def __call__(
file_counter = 0
# iterative over all files in the archive
extracted_files = list(earchive.get_extracted_files())
# start a progress bar for extraction
pbar_id = f'add-archive-{archive_path}'
log_progress(
lgr.info, pbar_id, 'Extracting archive',
label="Extracting archive",
unit=' Files',
total = len(extracted_files),
noninteractive_level = logging.INFO)
for extracted_file in extracted_files:
file_counter += 1
files_left = len(extracted_files) - file_counter
log_progress(
lgr.info, 'archive-content', 'Extracting archive',
label="Extracting archive",
update=file_counter, total=len(extracted_files))
lgr.info, pbar_id,
"Files to extract %i ", files_left,
update=1,
increment=True,
noninteractive_level=logging.DEBUG)
stats.files += 1
extracted_path = Path(earchive.path) / Path(extracted_file)

Expand Down Expand Up @@ -668,7 +679,9 @@ def __call__(
finally:
# take down the progress bar
log_progress(
lgr.info, 'archive-content', 'Finished extraction')
lgr.info, pbar_id,
'Finished extraction',
noninteractive_level=logging.INFO)
# since we batched addurl, we should close those batched processes
# if haven't done yet. explicitly checked to avoid any possible
# "double-action"
Expand Down

0 comments on commit 96a8584

Please sign in to comment.