Skip to content
Snippets Groups Projects
Commit d3df2efe authored by Maël Madon's avatar Maël Madon
Browse files

improve verbose mode in swf_filter

parent 0e4f203a
No related branches found
No related tags found
No related merge requests found
#!/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 % 100000 == 0: if not quiet and i % 10000 == 0:
print("Processing swf line", i) print(f"\r\033[KProcessing 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('-------------------\nEnd parsing') if not quiet:
print('Total {} jobs and {} users have been created.'.format( print('\n-------------------\nEnd 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment