Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Gepetto Utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gepetto
Gepetto Utils
Commits
f3c17c82
Commit
f3c17c82
authored
6 years ago
by
Guilhem Saurel
Browse files
Options
Downloads
Patches
Plain Diff
parse_muscod_logs.py for
@jcarpent
parent
3d25b2b3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/parse_muscod_logs.py
+48
-0
48 additions, 0 deletions
scripts/parse_muscod_logs.py
with
48 additions
and
0 deletions
scripts/parse_muscod_logs.py
0 → 100755
+
48
−
0
View file @
f3c17c82
#!/usr/bin/env python2
import
argparse
import
datetime
import
logging
import
re
args
=
argparse
.
ArgumentParser
()
args
.
add_argument
(
'
filename
'
,
type
=
argparse
.
FileType
(
'
r
'
))
args
.
add_argument
(
'
-v
'
,
'
--verbose
'
,
action
=
'
store_true
'
)
logging
.
basicConfig
()
logger
=
logging
.
getLogger
(
'
parse_muscod_logs
'
)
def
parse_muscod_logs
(
filename
,
verbose
):
"""
Parse muscod
'
s logs to get NDIS, the number of iterations & total computation time
"""
ndis
=
iterations
=
total
=
None
logger
.
setLevel
(
logging
.
INFO
if
verbose
else
logging
.
WARNING
)
for
number
,
line
in
enumerate
(
filename
):
if
'
NDIS
'
in
line
:
ndis
=
int
(
line
.
split
(
'
=
'
)[
1
].
strip
())
logger
.
info
(
'
found NDIS on line %i: %s
'
%
(
number
,
ndis
))
elif
'
**** SQP iteration
'
in
line
:
# Only the last will be remembered
iterations
=
int
(
line
.
split
(
'
'
)[
3
].
strip
())
logger
.
info
(
'
found iterations on line %i: %s
'
%
(
number
,
iterations
))
elif
'
Total
'
in
line
:
# double space to avoid 'Grand Total' line
total_dict
=
re
.
search
(
'
(?P<minutes>\d{2}):(?P<seconds>\d{2}).(?P<milliseconds>\d{3})
'
,
line
).
groupdict
()
total
=
datetime
.
timedelta
(
**
{
k
:
int
(
v
)
for
k
,
v
in
total_dict
.
items
()})
logger
.
info
(
'
found total on line %i: %s
'
%
(
number
,
total
))
if
ndis
is
None
:
logger
.
error
(
'
NDIS not found
'
)
if
iterations
is
None
:
logger
.
error
(
'
iterations not found
'
)
if
total
is
None
:
logger
.
error
(
'
total not found
'
)
return
{
'
ndis
'
:
ndis
,
'
iterations
'
:
iterations
,
'
total
'
:
total
}
if
__name__
==
'
__main__
'
:
ret
=
parse_muscod_logs
(
**
vars
(
args
.
parse_args
()))
print
(
ret
)
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