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

pretty printing and change .format to f-strings

parent f7dbc8c8
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,7 @@ def generate_workload(input_swf, output_folder,
submit_time = max(0, float(res.group(SwfField.SUBMIT_TIME.value)))
walltime = max(job_walltime_factor * run_time,
float(res.group(SwfField.REQUESTED_TIME.value)))
user_id = str(res.group(SwfField.USER_ID.value))
user_id = int(res.group(SwfField.USER_ID.value))
# nb_res may be changed by calling a user-given function
nb_res = eval(job_size_function_string)
......@@ -119,19 +119,18 @@ def generate_workload(input_swf, output_folder,
'version': version,
'command': ' '.join(sys.argv[:]),
'date': datetime.datetime.now().isoformat(' '),
'description': 'Workload for user {}'.format(user_id),
'description': f'Workload for user {user_id}',
'nb_res': biggest_job,
'jobs': djobs}
try:
output_json = output_folder + "/user" + user_id + ".json"
outFile = open(output_json, 'w')
output_json = f"{output_folder}/user{user_id}.json"
out_file = open(output_json, 'w')
json.dump(data, outFile, indent=indent, sort_keys=True)
json.dump(data, out_file, indent=indent, sort_keys=True)
if not quiet:
print('user {}:'.format(user_id))
print(' {} jobs had been created'.format(len(djobs)))
print(f"user{user_id:3d}: {len(djobs):10d} jobs")
except IOError:
......@@ -139,11 +138,11 @@ def generate_workload(input_swf, output_folder,
if not quiet:
print('-------------------')
print('Total {} jobs and {} users have been created.'.format(
sum([len(jobs) for jobs in users.values()]), len(users)))
print('{} out of {} lines in the file did not match the swf format'.format(
not_line_match_format, i))
print('{} jobs were not valid'.format(not_valid))
print(f"Total {sum([len(jobs) for jobs in users.values()])} jobs and "
f"{len(users)} users have been created.")
print(f"{not_line_match_format} out of {i} lines in the file did not "
"match the swf format")
print(f"{not_valid} jobs were not valid")
def main():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment