Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
python-common
Commits
4a6a9070
Commit
4a6a9070
authored
9 years ago
by
Henning Glawe
Browse files
Options
Downloads
Patches
Plain Diff
build global match statistics via SimpleParser.updateTelemetryCounters
parent
013ba957
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/python/nomadcore/annotator.py
+0
-14
0 additions, 14 deletions
common/python/nomadcore/annotator.py
common/python/nomadcore/simple_parser.py
+17
-0
17 additions, 0 deletions
common/python/nomadcore/simple_parser.py
with
17 additions
and
14 deletions
common/python/nomadcore/annotator.py
+
0
−
14
View file @
4a6a9070
...
...
@@ -20,9 +20,6 @@ class Annotator(object):
self
.
_formatNameWidth
=
formatNameWidth
self
.
_formatSourceWidth
=
formatSourceWidth
self
.
_update_annotate_format
()
self
.
counter
=
{}
for
counter
in
[
'
total
'
,
'
ignore
'
,
'
match
'
,
'
partial
'
,
'
unmatched
'
]:
self
.
counter
[
counter
]
=
0
def
_update_annotate_format
(
self
):
self
.
_annotate_format
=
'
%%%ds:%%04d %%%ds %%9s|%%s
'
%
(
...
...
@@ -37,17 +34,6 @@ class Annotator(object):
self
.
_update_annotate_format
()
def
annotate
(
self
,
minfo
):
# update counters
self
.
counter
[
'
total
'
]
+=
1
if
minfo
[
'
coverageIgnore
'
]:
self
.
counter
[
'
ignore
'
]
+=
1
elif
minfo
[
'
match
'
]
>
1
:
self
.
counter
[
'
match
'
]
+=
1
elif
minfo
[
'
match
'
]:
self
.
counter
[
'
partial
'
]
+=
1
else
:
self
.
counter
[
'
unmatched
'
]
+=
1
# don't write to file unless it is there
if
not
self
.
annotateFile
:
return
1
...
...
This diff is collapsed.
Click to expand it.
common/python/nomadcore/simple_parser.py
+
17
−
0
View file @
4a6a9070
...
...
@@ -738,6 +738,7 @@ class CompiledMatcher(object):
def
handleMatchTelemetry
(
self
,
parser
,
match
,
line
,
targetStartEnd
):
match_telemetry
=
self
.
getMatchTelemetry
(
parser
,
match
,
line
,
targetStartEnd
)
parser
.
updateTelemetryCounters
(
match_telemetry
)
parser
.
annotator
.
annotate
(
match_telemetry
)
class
ParsingContext
(
object
):
# use slots?
...
...
@@ -1047,6 +1048,9 @@ class SimpleParser(object):
# by default, ignore empty lines in coverage analysis
self
.
coverageIgnore
=
getattr
(
superContext
,
'
coverageIgnore
'
,
re
.
compile
(
r
"
^\s*$
"
))
self
.
telemetry_counter
=
{}
for
counter
in
[
'
total
'
,
'
ignore
'
,
'
match
'
,
'
partial
'
,
'
unmatched
'
]:
self
.
telemetry_counter
[
counter
]
=
0
if
annotate
:
annofilename
=
fIn
.
fIn
.
name
+
"
.annotate
"
else
:
...
...
@@ -1144,6 +1148,19 @@ class SimpleParser(object):
while
self
.
parseStep
():
pass
def
updateTelemetryCounters
(
self
,
matchTelemetry
):
# update counters
self
.
telemetry_counter
[
'
total
'
]
+=
1
if
matchTelemetry
[
'
coverageIgnore
'
]:
self
.
telemetry_counter
[
'
ignore
'
]
+=
1
elif
matchTelemetry
[
'
match
'
]
>
1
:
self
.
telemetry_counter
[
'
match
'
]
+=
1
elif
matchTelemetry
[
'
match
'
]:
self
.
telemetry_counter
[
'
partial
'
]
+=
1
else
:
self
.
telemetry_counter
[
'
unmatched
'
]
+=
1
def
compileParser
(
simpleParser
,
metaInfo
,
metaInfoToKeep
,
default_units
=
None
,
metainfo_units
=
None
,
strValueTransform
=
None
):
"""
compiles the given simple parser
"""
parserBuilder
=
SimpleParserBuilder
(
simpleParser
,
metaInfo
,
metaInfoToKeep
,
default_units
,
metainfo_units
,
strValueTransform
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment