-
Notifications
You must be signed in to change notification settings - Fork 2
Suppress known git progress logs #259
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
candleindark
wants to merge
19
commits into
datalad:master
Choose a base branch
from
candleindark:suppress-git-progress-logs
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.
Open
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d3ef817
Suppress known git progress logs
candleindark 412923d
Define Git progress report matching patterns
candleindark 638b044
Reimplement `filter()` in `SuppressKnownGitProgressLogs`
candleindark f5e47b8
Redefine `known_git_progress_log_types` as a set
candleindark 5e07ecc
Eliminate unneeded group capturing in re expressions
candleindark 5c5016e
Test `celery_app` in `make_celery.py` is instantiated correctly
candleindark e7b4e5a
Rename `SuppressKnownGitProgressLogs` to `SuppressKnownGitProgressRep…
candleindark 1731edb
Rename `known_git_progress_log_types` to `known_git_progress_report_t…
candleindark fbea870
Modify comments
candleindark 4461a37
RF:
candleindark 45808f9
Merge with suggested change on return base on if op name is known
candleindark 63736c6
Add additional comment
candleindark 653f2b2
Provide tests for the log filter
candleindark ce5ca72
Merge branch 'master' into suppress-git-progress-logs
candleindark e60c28d
Enable datalad library mode in datalad-registry
candleindark d0d6270
Enable datalad library mode in datalad-registry-client
candleindark 337bf31
Enable datalad library mode for datalad-registry in module level
candleindark 74bf6ec
Revert "Enable datalad library mode in datalad-registry-client"
candleindark 195ffd2
Remove custom log handler from the datalad package
candleindark 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,63 @@ | ||
| # This file provides Celery commands access to the Celery app created through | ||
| # the factory functions in datalad_registry/__init__.py | ||
| import logging | ||
| import re | ||
|
|
||
| from celery import Celery | ||
|
|
||
| from . import create_app | ||
|
|
||
|
|
||
| # === Code for suppressing known git progress logs === | ||
| class SuppressKnownGitProgressLogs(logging.Filter): | ||
| # Known git progress log types | ||
| # These types can be found in the definition of | ||
| # `datalad.support.gitrepo.GitProgress` | ||
| known_git_progress_log_types = { | ||
| "Counting objects", | ||
| "Compressing objects", | ||
| "Writing objects", | ||
| "Receiving objects", | ||
| "Resolving deltas", | ||
| "Finding sources", | ||
| "Checking out files", | ||
| "Enumerating objects", | ||
| } | ||
|
|
||
| re_op_absolute = re.compile(r"(?:remote: )?([\w\s]+):\s+\d+.*") | ||
| re_op_relative = re.compile(r"(?:remote: )?([\w\s]+):\s+\d+% \(\d+/\d+\).*") | ||
|
|
||
| def filter(self, record): | ||
| # The following logic is based on the logic in | ||
| # `datalad.support.gitrepo.GitProgress._parse_progress_line` | ||
|
|
||
| msg = record.getMessage() | ||
|
|
||
| match = self.re_op_relative.match(msg) | ||
| if match is None: | ||
| match = self.re_op_absolute.match(msg) | ||
|
|
||
| if match is None: | ||
| # === msg does not match the pattern of a git progress report === | ||
| return True | ||
|
|
||
| op_name = match.group(1) | ||
| if op_name not in self.known_git_progress_log_types: | ||
| # === msg matches the pattern of a git progress report | ||
| # but of an unknown type === | ||
| return True | ||
| else: | ||
| # === msg must be a git progress report as indicated by having | ||
| # the matching pattern and is of a known type === | ||
| return False | ||
|
|
||
|
|
||
| # Retrieve a reference to the "datalad.gitrepo" logger | ||
| dl_gitrepo_lgr = logging.getLogger("datalad.gitrepo") | ||
|
|
||
| # Add a filter to the "datalad.gitrepo" logger to suppress known git progress logs | ||
| dl_gitrepo_lgr.addFilter(SuppressKnownGitProgressLogs()) | ||
| # === End of code for suppressing known git progress logs === | ||
|
|
||
| flask_app = create_app() | ||
| celery_app: Celery = flask_app.extensions["celery"] | ||
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.