Skip to content

Commit 7c29d35

Browse files
committed
o2dpg_workflow_runner.py: Adapt format for --update-resources to that of o2dpg_sim_metrics.py
1 parent 9e82588 commit 7c29d35

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

MC/bin/o2_dpg_workflow_runner.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ def getweight(tid):
440440

441441
# update the resource estimates of a workflow based on resources given via JSON
442442
def update_resource_estimates(workflow, resource_json):
443+
# the resource_dict here is generated by tool o2dpg_sim_metrics.py json-stat
443444
resource_dict = load_json(resource_json)
444445
stages = workflow["stages"]
445446

@@ -455,17 +456,18 @@ def update_resource_estimates(workflow, resource_json):
455456
new_resources = resource_dict[name]
456457

457458
# memory
458-
newmem = new_resources.get("mem", None)
459+
newmem = new_resources.get("pss", {}).get("max", None)
459460
if newmem is not None:
460461
oldmem = task["resources"]["mem"]
461462
actionlogger.info("Updating mem estimate for " + task["name"] + " from " + str(oldmem) + " to " + str(newmem))
462463
task["resources"]["mem"] = newmem
463464

464465
# cpu
465-
newcpu = new_resources.get("cpu", None)
466+
newcpu = new_resources.get("cpu", {}).get("mean", None)
466467
if newcpu is not None:
467468
oldcpu = task["resources"]["cpu"]
468469
rel_cpu = task["resources"]["relative_cpu"]
470+
# TODO: No longer sure about this since we inject numbers from actually measured workloads
469471
if rel_cpu is not None:
470472
# respect the relative CPU settings
471473
# By default, the CPU value in the workflow is already scaled if relative_cpu is given.
@@ -597,7 +599,7 @@ def __init__(self, tid, name, cpu, cpu_relative, mem, resource_boundaries):
597599
# sampled resources of this
598600
self.cpu_sampled = None
599601
self.mem_sampled = None
600-
# Set these after a task has finished to compute new estomates for related tasks
602+
# Set these after a task has finished to compute new estimates for related tasks
601603
self.walltime = None
602604
self.cpu_taken = None
603605
self.mem_taken = None

MC/utils/o2dpg_sim_metrics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,16 +1004,19 @@ def merge_stats_into(list_of_json_stats, outputfile, metadata):
10041004
running = {}
10051005
# read all the inputs
10061006
for inp_json in list_of_json_stats:
1007+
# we may have to strip the meta-data section first of all
10071008
running = merge_stats(inp_json, running)
10081009

10091010
# attach meta-data
10101011
running["meta-data"] = metadata
10111012

10121013
# now write out the result into the output file
1013-
if running:
1014+
if running and outputfile != None:
10141015
with open(outputfile, 'w') as f:
10151016
json.dump(running, f)
10161017

1018+
return running
1019+
10171020

10181021
def build_meta_header(stringarg):
10191022
meta = {}

0 commit comments

Comments
 (0)