-
Notifications
You must be signed in to change notification settings - Fork 1.2k
UI progress cleanup #2846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
UI progress cleanup #2846
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5d10606
remove ETA on completion, minor tidy
casperdcl c6c8b80
no unit scaling for small totals
casperdcl eb05f8b
clean output cleaning (meta)
casperdcl dee5199
black
casperdcl 426972e
disable super progress bar for single-files
casperdcl dd34100
replace super bar with intermediate "Adding..." for single files
casperdcl 0293f71
minor comment and force refresh
casperdcl 80e8270
add recursive file find progress
casperdcl 3b65181
remove unneeded <??:?? for unknown ETA
casperdcl 21c1b26
add progress for stages; also may need reverting
casperdcl 866b3cd
add progress for save/commit/dump stages
casperdcl 2a4c308
tidy close logic
casperdcl aa3ff02
minor comment
casperdcl 25557c5
remove potential single-iteration bar
casperdcl a66cc0e
add saving progress for files in dirs
casperdcl 660fcfd
fix disable logic
casperdcl 528dedd
minor import tidy
casperdcl 6de48d3
replace funcy.merge with py3 syntax
casperdcl 7fa5e69
silly omission
casperdcl 61a1e7f
backtrack pbars after failing when adding nonexistent files
casperdcl 4ae9b75
minor import tidy
casperdcl b49a61d
minor message rename
casperdcl ab115df
Recursing => Searching
casperdcl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ | |
import colorama | ||
|
||
from . import locked | ||
from dvc.exceptions import RecursiveAddingWhileUsingFilename | ||
from dvc.progress import Tqdm | ||
from dvc.repo.scm_context import scm_context | ||
from dvc.stage import Stage | ||
from dvc.utils import LARGE_DIR_SIZE | ||
from ..exceptions import RecursiveAddingWhileUsingFilename | ||
from ..output.base import OutputDoesNotExistError | ||
from ..progress import Tqdm | ||
from ..repo.scm_context import scm_context | ||
from ..stage import Stage | ||
from ..utils import LARGE_DIR_SIZE | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
@@ -23,7 +24,12 @@ def add(repo, targets, recursive=False, no_commit=False, fname=None): | |
targets = [targets] | ||
|
||
stages_list = [] | ||
with Tqdm(total=len(targets), desc="Add", unit="file", leave=True) as pbar: | ||
num_targets = len(targets) | ||
with Tqdm(total=num_targets, desc="Add", unit="file", leave=True) as pbar: | ||
if num_targets == 1: | ||
# clear unneeded top-level progress bar for single target | ||
pbar.bar_format = "Adding..." | ||
pbar.refresh() | ||
for target in targets: | ||
sub_targets = _find_all_targets(repo, target, recursive) | ||
pbar.total += len(sub_targets) - 1 | ||
|
@@ -45,17 +51,29 @@ def add(repo, targets, recursive=False, no_commit=False, fname=None): | |
|
||
repo.check_modified_graph(stages) | ||
|
||
for stage in stages: | ||
stage.save() | ||
|
||
if not no_commit: | ||
stage.commit() | ||
|
||
stage.dump() | ||
with Tqdm( | ||
total=len(stages), | ||
desc="Processing", | ||
unit="file", | ||
disable=True if len(stages) == 1 else None, | ||
) as pbar_stages: | ||
for stage in stages: | ||
try: | ||
stage.save() | ||
except OutputDoesNotExistError: | ||
pbar.n -= 1 | ||
raise | ||
|
||
if not no_commit: | ||
stage.commit() | ||
|
||
stage.dump() | ||
pbar_stages.update() | ||
|
||
stages_list += stages | ||
# remove filled bar bit of progress, leaving stats | ||
pbar.bar_format = pbar.BAR_FMT_DEFAULT.replace("|{bar:10}|", " ") | ||
|
||
if num_targets == 1: # restore bar format for stats | ||
pbar.bar_format = pbar.BAR_FMT_DEFAULT | ||
|
||
return stages_list | ||
|
||
|
@@ -64,7 +82,12 @@ def _find_all_targets(repo, target, recursive): | |
if os.path.isdir(target) and recursive: | ||
return [ | ||
fname | ||
for fname in repo.tree.walk_files(target) | ||
for fname in Tqdm( | ||
repo.tree.walk_files(target), | ||
desc="Searching " + target, | ||
bar_format=Tqdm.BAR_FMT_NOTOTAL, | ||
unit="file", | ||
) | ||
if not repo.is_dvc_internal(fname) | ||
if not Stage.is_stage_file(fname) | ||
if not repo.scm.belongs_to_scm(fname) | ||
|
@@ -76,7 +99,12 @@ def _find_all_targets(repo, target, recursive): | |
def _create_stages(repo, targets, fname, pbar=None): | ||
stages = [] | ||
|
||
for out in targets: | ||
for out in Tqdm( | ||
targets, | ||
desc="Creating DVC-files", | ||
disable=True if len(targets) < LARGE_DIR_SIZE else None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is LARGE_DIR_SIZE really needed here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might prevent unneeded flickering (creating and disappearing) of a really quick progressbar... |
||
unit="file", | ||
): | ||
stage = Stage.create(repo, outs=[out], add=True, fname=fname) | ||
|
||
if not stage: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.