Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Chaofan Chen
ogs
Commits
d8e4d895
Commit
d8e4d895
authored
6 months ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[Py] Added option to output csv files
parent
43f8b3bd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Applications/Python/ogs/dev/ogs_log_summary.py
+48
-13
48 additions, 13 deletions
Applications/Python/ogs/dev/ogs_log_summary.py
with
48 additions
and
13 deletions
Applications/Python/ogs/dev/ogs_log_summary.py
+
48
−
13
View file @
d8e4d895
...
@@ -285,7 +285,7 @@ def aggregate_log_files(log_files_dirs):
...
@@ -285,7 +285,7 @@ def aggregate_log_files(log_files_dirs):
return
map_prj_file_to_agg_vtkdiff_stats
return
map_prj_file_to_agg_vtkdiff_stats
def
run
(
log_files_dirs
,
xml_
out_dir
,
verbose
):
def
run
(
log_files_dirs
,
out_dir
,
*
,
snippet_out
,
csv_out
,
verbose
):
map_prj_file_to_agg_vtkdiff_stats
=
aggregate_log_files
(
log_files_dirs
)
map_prj_file_to_agg_vtkdiff_stats
=
aggregate_log_files
(
log_files_dirs
)
for
i
,
(
prj_file
,
df_vtkdiff_max
)
in
enumerate
(
for
i
,
(
prj_file
,
df_vtkdiff_max
)
in
enumerate
(
...
@@ -296,18 +296,25 @@ def run(log_files_dirs, xml_out_dir, verbose):
...
@@ -296,18 +296,25 @@ def run(log_files_dirs, xml_out_dir, verbose):
print
()
# blank line as a separator
print
()
# blank line as a separator
print
(
f
"
######
{
prj_file
}
\n
"
)
print
(
f
"
######
{
prj_file
}
\n
"
)
df_vtkdiff_max
=
round_up_2_digits
(
df_vtkdiff_max
)
# noqa: PLW2901
df_vtkdiff_max
_rounded
=
round_up_2_digits
(
df_vtkdiff_max
)
if
verbose
:
if
verbose
:
print_table_summary
(
df_vtkdiff_max
,
sys
.
stdout
)
print_table_summary
(
df_vtkdiff_max
_rounded
,
sys
.
stdout
)
if
xml_
out_dir
is
not
None
:
if
out_dir
is
not
None
and
(
snippet_out
or
csv_out
)
:
prj_dir
=
Path
(
prj_file
).
parent
prj_dir
=
Path
(
prj_file
).
parent
assert
not
prj_dir
.
is_absolute
()
assert
not
prj_dir
.
is_absolute
()
this_xml_out_dir
=
xml_out_dir
/
prj_dir
this_out_dir
=
out_dir
/
prj_dir
this_xml_out_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
this_out_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
this_xml_out_file
=
this_xml_out_dir
/
Path
(
prj_file
).
name
write_xml_snippet
(
df_vtkdiff_max
,
this_xml_out_file
)
if
snippet_out
:
this_xml_out_file
=
this_out_dir
/
Path
(
prj_file
).
name
write_xml_snippet
(
df_vtkdiff_max_rounded
,
this_xml_out_file
)
if
csv_out
:
this_csv_out_file
=
this_out_dir
/
f
"
{
Path
(
prj_file
).
name
}
.csv
"
# for 17 digits precision cf. also https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10
df_vtkdiff_max
.
to_csv
(
this_csv_out_file
,
sep
=
"
\t
"
,
float_format
=
"
%.17g
"
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
@@ -319,7 +326,20 @@ if __name__ == "__main__":
...
@@ -319,7 +326,20 @@ if __name__ == "__main__":
"
--verbose
"
,
"
-v
"
,
action
=
"
store_true
"
,
help
=
"
Produce verbose cmdline output
"
"
--verbose
"
,
"
-v
"
,
action
=
"
store_true
"
,
help
=
"
Produce verbose cmdline output
"
)
)
parser
.
add_argument
(
parser
.
add_argument
(
"
--snippet-out
"
,
type
=
Path
,
help
=
"
OGS prj snippet output directory
"
"
-o
"
,
"
--out
"
,
type
=
Path
,
help
=
"
output directory root for prj file snippets and CSV files.
"
,
)
parser
.
add_argument
(
"
--snippet-out
"
,
action
=
"
store_true
"
,
help
=
"
Output <test_definition> snippets for prj files.
"
,
)
parser
.
add_argument
(
"
--csv-out
"
,
action
=
"
store_true
"
,
help
=
"
Output aggregated statistics as CSV files.
"
,
)
)
parser
.
add_argument
(
parser
.
add_argument
(
"
log_files_dirs
"
,
"
log_files_dirs
"
,
...
@@ -331,9 +351,8 @@ if __name__ == "__main__":
...
@@ -331,9 +351,8 @@ if __name__ == "__main__":
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
snippet_out
=
args
.
snippet_out
snippet_out
=
args
.
snippet_out
csv_out
=
args
.
csv_out
if
snippet_out
is
not
None
:
outdir
=
args
.
out
assert
snippet_out
.
is_dir
()
logger
.
setLevel
(
logging
.
INFO
)
logger
.
setLevel
(
logging
.
INFO
)
ch
=
logging
.
StreamHandler
()
ch
=
logging
.
StreamHandler
()
...
@@ -342,11 +361,27 @@ if __name__ == "__main__":
...
@@ -342,11 +361,27 @@ if __name__ == "__main__":
ch
.
setFormatter
(
formatter
)
ch
.
setFormatter
(
formatter
)
logger
.
addHandler
(
ch
)
logger
.
addHandler
(
ch
)
if
outdir
and
not
(
snippet_out
or
csv_out
):
logger
.
INFO
(
"
Output directory will not be used.
"
)
if
(
snippet_out
or
csv_out
)
and
not
outdir
:
logger
.
ERROR
(
"
No output directory specified for XML and/or CSV output.
"
)
sys
.
exit
()
if
outdir
is
not
None
:
assert
outdir
.
is_dir
()
# suppress error message from Python interpreter, e.g., if a command
# suppress error message from Python interpreter, e.g., if a command
# pipeline exits early, see
# pipeline exits early, see
# https://docs.python.org/3/library/signal.html#note-on-sigpipe
# https://docs.python.org/3/library/signal.html#note-on-sigpipe
try
:
try
:
run
(
args
.
log_files_dirs
,
snippet_out
,
args
.
verbose
)
run
(
args
.
log_files_dirs
,
outdir
,
snippet_out
=
snippet_out
,
csv_out
=
csv_out
,
verbose
=
args
.
verbose
,
)
except
BrokenPipeError
:
except
BrokenPipeError
:
devnull
=
os
.
open
(
os
.
devnull
,
os
.
O_WRONLY
)
devnull
=
os
.
open
(
os
.
devnull
,
os
.
O_WRONLY
)
os
.
dup2
(
devnull
,
sys
.
stdout
.
fileno
())
os
.
dup2
(
devnull
,
sys
.
stdout
.
fileno
())
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