Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Batmen Tools
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
sepia-pub
mael
Batmen Tools
Commits
d3df2efe
Commit
d3df2efe
authored
2 years ago
by
Maël Madon
Browse files
Options
Downloads
Patches
Plain Diff
improve verbose mode in swf_filter
parent
0e4f203a
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
swf_filter.py
+19
-26
19 additions, 26 deletions
swf_filter.py
with
19 additions
and
26 deletions
swf_
moulinet
te.py
→
swf_
fil
te
r
.py
+
19
−
26
View file @
d3df2efe
#!/usr/bin/env python3
#!/usr/bin/env python3
"""
"""
SWF parser
to make selections and obtain some stats
.
SWF parser
allowing to filter jobs from an input file according to some criteria
.
Inspired from https://gitlab.inria.fr/batsim/batsim/-/blob/master/tools/swf_to_batsim_workload_compute_only.py
Inspired from https://gitlab.inria.fr/batsim/batsim/-/blob/master/tools/swf_to_batsim_workload_compute_only.py
"""
"""
...
@@ -21,15 +21,12 @@ def generate_workload(input_swf, output_swf=None,
...
@@ -21,15 +21,12 @@ def generate_workload(input_swf, output_swf=None,
indent
=
None
,
indent
=
None
,
translate_submit_times
=
False
,
translate_submit_times
=
False
,
keep_only
=
None
,
keep_only
=
None
,
verbose
=
False
,
quiet
=
False
,
quiet
=
False
,
job_size_function_string
=
'
1*nb_res
'
):
job_size_function_string
=
'
1*nb_res
'
):
"""
Makes a selection from a SWF trace, optionally outputing it as SWF.
"""
"""
Makes a selection from a SWF trace, optionally outputing it as SWF.
"""
element
=
'
([-+]?\d+(?:\.\d+)?)
'
element
=
'
([-+]?\d+(?:\.\d+)?)
'
r
=
re
.
compile
(
'
\s*
'
+
(
element
+
'
\s+
'
)
*
17
+
element
+
'
\s*
'
)
r
=
re
.
compile
(
'
\s*
'
+
(
element
+
'
\s+
'
)
*
17
+
element
+
'
\s*
'
)
current_id
=
0
# Some counters...
# Some counters...
not_selected
=
{
"
nb
"
:
0
,
"
coreh
"
:
0
}
not_selected
=
{
"
nb
"
:
0
,
"
coreh
"
:
0
}
selected
=
{
"
nb
"
:
0
,
"
coreh
"
:
0
}
selected
=
{
"
nb
"
:
0
,
"
coreh
"
:
0
}
...
@@ -37,14 +34,12 @@ def generate_workload(input_swf, output_swf=None,
...
@@ -37,14 +34,12 @@ def generate_workload(input_swf, output_swf=None,
not_line_match_format
=
0
not_line_match_format
=
0
users
=
[]
users
=
[]
minimum_observed_submit_time
=
float
(
'
inf
'
)
# Let's loop over the lines of the input file
# Let's loop over the lines of the input file
i
=
1
i
=
0
for
line
in
input_swf
:
for
line
in
input_swf
:
i
+=
1
i
+=
1
if
i
%
10000
0
==
0
:
if
not
quiet
and
i
%
10000
==
0
:
print
(
"
Processing swf line
"
,
i
)
print
(
f
"
\r\033
[K
Processing swf line
{
i
}
"
,
end
=
""
)
res
=
r
.
match
(
line
)
res
=
r
.
match
(
line
)
...
@@ -96,19 +91,20 @@ def generate_workload(input_swf, output_swf=None,
...
@@ -96,19 +91,20 @@ def generate_workload(input_swf, output_swf=None,
else
:
else
:
not_line_match_format
+=
1
not_line_match_format
+=
1
print
(
'
-------------------
\n
End parsing
'
)
if
not
quiet
:
print
(
'
Total {} jobs and {} users have been created.
'
.
format
(
print
(
'
\n
-------------------
\n
End parsing.
'
)
selected
[
"
nb
"
],
len
(
users
)))
print
(
'
Total {} jobs and {} users have been created.
'
.
format
(
print
(
selected
[
"
nb
"
],
len
(
users
)))
'
Total number of core-hours: {:.0f}
'
.
format
(
selected
[
"
coreh
"
]
/
3600
))
print
(
print
(
'
{} valid jobs were not selected (keep_only) for {:.0f} core-hour
'
.
format
(
'
Total number of core-hours: {:.0f}
'
.
format
(
selected
[
"
coreh
"
]
/
3600
))
not_selected
[
"
nb
"
],
not_selected
[
"
coreh
"
]
/
3600
))
print
(
'
{} valid jobs were not selected (keep_only) for {:.0f} core-hour
'
.
format
(
print
(
"
Jobs not selected: {:.1f}% in number, {:.1f}% in core-hour
"
not_selected
[
"
nb
"
],
not_selected
[
"
coreh
"
]
/
3600
))
.
format
(
not_selected
[
"
nb
"
]
/
(
not_selected
[
"
nb
"
]
+
selected
[
"
nb
"
])
*
100
,
print
(
"
Jobs not selected: {:.1f}% in number, {:.1f}% in core-hour
"
not_selected
[
"
coreh
"
]
/
(
selected
[
"
coreh
"
]
+
not_selected
[
"
coreh
"
])
*
100
))
.
format
(
not_selected
[
"
nb
"
]
/
(
not_selected
[
"
nb
"
]
+
selected
[
"
nb
"
])
*
100
,
print
(
'
{} out of {} lines in the file did not match the swf format
'
.
format
(
not_selected
[
"
coreh
"
]
/
(
selected
[
"
coreh
"
]
+
not_selected
[
"
coreh
"
])
*
100
))
not_line_match_format
,
i
))
print
(
'
{} out of {} lines in the file did not match the swf format
'
.
format
(
print
(
'
{} jobs were not valid
'
.
format
(
not_valid
))
not_line_match_format
,
i
))
print
(
'
{} jobs were not valid
'
.
format
(
not_valid
))
...
@@ -155,9 +151,7 @@ def main():
...
@@ -155,9 +151,7 @@ def main():
default
=
None
,
default
=
None
,
help
=
'
If set, this parameter is evaluated to choose which jobs should be kept
'
)
help
=
'
If set, this parameter is evaluated to choose which jobs should be kept
'
)
group
=
parser
.
add_mutually_exclusive_group
()
parser
.
add_argument
(
"
-q
"
,
"
--quiet
"
,
action
=
"
store_true
"
)
group
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
action
=
"
store_true
"
)
group
.
add_argument
(
"
-q
"
,
"
--quiet
"
,
action
=
"
store_true
"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -171,7 +165,6 @@ def main():
...
@@ -171,7 +165,6 @@ def main():
indent
=
args
.
indent
,
indent
=
args
.
indent
,
translate_submit_times
=
args
.
translate_submit_times
,
translate_submit_times
=
args
.
translate_submit_times
,
keep_only
=
args
.
keep_only
,
keep_only
=
args
.
keep_only
,
verbose
=
args
.
verbose
,
quiet
=
args
.
quiet
,
quiet
=
args
.
quiet
,
job_size_function_string
=
args
.
job_size_function
)
job_size_function_string
=
args
.
job_size_function
)
...
...
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