-
-
Notifications
You must be signed in to change notification settings - Fork 836
feat: add progress indicator to repository check loop #9476
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
Open
sagar-h007
wants to merge
6
commits into
borgbackup:master
Choose a base branch
from
sagar-h007:feat/check-progress-indicator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+60
−9
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6b640dd
feat: add progress indicator to repository check loop
sagar-h007 52453a7
check: refine repository progress indicator implementation.
sagar-h007 b9c31f5
fix ci
sagar-h007 81e11b0
fix:resolve PR CI failures by fixing import loop and remote API versi…
sagar-h007 1b98058
move ProgressIndicatorCounter import to module level and fix progress…
sagar-h007 9df300c
fix: use progress indicator only when --progress is set
sagar-h007 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
|
|
||
| from .constants import * # NOQA | ||
| from .hashindex import ChunkIndex, ChunkIndexEntry | ||
| from .helpers import Error, ErrorWithTraceback, IntegrityError | ||
| from .helpers import Error, ErrorWithTraceback, IntegrityError, ProgressIndicatorCounter | ||
| from .helpers import Location | ||
| from .helpers import bin_to_hex, hex_to_bin | ||
| from .storelocking import Lock | ||
|
|
@@ -290,7 +290,7 @@ def info(self): | |
| info = dict(id=self.id, version=self.version) | ||
| return info | ||
|
|
||
| def check(self, repair=False, max_duration=0): | ||
| def check(self, repair=False, max_duration=0, progress=False): | ||
| """Check repository consistency""" | ||
|
|
||
| def log_error(msg): | ||
|
|
@@ -317,7 +317,8 @@ def check_object(obj): | |
| else: | ||
| log_error("too small.") | ||
|
|
||
| # TODO: progress indicator, ... | ||
| if progress: | ||
| pi = ProgressIndicatorCounter(step=1, msg="Checked objects: %d", msgid="repository.check") | ||
| partial = bool(max_duration) | ||
| assert not (repair and partial) | ||
| mode = "partial" if partial else "full" | ||
|
|
@@ -364,6 +365,8 @@ def check_object(obj): | |
| obj_corrupted = False | ||
| check_object(obj) | ||
| objs_checked += 1 | ||
| if progress: | ||
| pi.show(objs_checked) | ||
|
Comment on lines
+368
to
+369
Member
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. somehow there is no consistency in master branch about this pattern. |
||
| if obj_corrupted: | ||
| objs_errors += 1 | ||
| if repair: | ||
|
|
@@ -393,10 +396,14 @@ def check_object(obj): | |
| logger.info(f"Checkpointing at key {key}.") | ||
| self.store.store(LAST_KEY_CHECKED, key.encode()) | ||
| if partial and now > t_start + max_duration: | ||
| if progress: | ||
| pi.finish() | ||
| logger.info(f"Finished partial repository check, last key checked is {key}.") | ||
| self.store.store(LAST_KEY_CHECKED, key.encode()) | ||
| break | ||
| else: | ||
| if progress: | ||
| pi.finish() | ||
| logger.info("Finished repository check.") | ||
| try: | ||
| self.store.delete(LAST_KEY_CHECKED) | ||
|
|
@@ -411,7 +418,8 @@ def check_object(obj): | |
| ) | ||
| except StoreObjectNotFound: | ||
| # it can be that there is no "data/" at all, then it crashes when iterating infos. | ||
| pass | ||
| if progress: | ||
| pi.finish() | ||
| logger.info(f"Checked {objs_checked} repository objects, {objs_errors} errors.") | ||
| if objs_errors == 0: | ||
| logger.info(f"Finished {mode} repository check, no problems found.") | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize self.counter = 0 in init method, so you don't need that hasattr.
also, move the code that is not related to producing output to a
progressmethod as you see in the percent pi.