Skip to content

Commit 63e1c81

Browse files
committed
[Accounting] Fix issues that were breaking the rendering of accounting info.
In particular: 1. fix the retrieval of compute nodes instance type to determine price estimate; 2. fix the generation of job properties rendered in the job accounting modal.
1 parent 7db92ed commit 63e1c81

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

api/PclusterApiHandler.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,27 @@ def ssm_command(region, instance_id, user, run_command):
282282
output = status["StandardOutputContent"]
283283
return output
284284

285+
286+
def _get_instance_types_for_compute_resource(compute_resource):
287+
if "Instances" in compute_resource:
288+
return [instance["InstanceType"] for instance in compute_resource["Instances"]]
289+
elif "InstanceType" in compute_resource:
290+
return [compute_resource["InstanceType"]]
291+
else:
292+
raise Exception("Cannot find instance types for compute resource: %s".format(compute_resource))
293+
294+
285295
def _price_estimate(cluster_name, region, queue_name):
286296
config_text = get_cluster_config_text(cluster_name, region)
287297
config_data = yaml.safe_load(config_text)
288298
queues = {q["Name"]: q for q in config_data["Scheduling"]["SlurmQueues"]}
289299
queue = queues[queue_name]
290300

291301
if len(queue["ComputeResources"]) == 1:
292-
instance_type = queue["ComputeResources"][0]["InstanceType"]
302+
instance_types = _get_instance_types_for_compute_resource(compute_resource=queue["ComputeResources"][0])
303+
if len(instance_types) > 1:
304+
return {"message": "Cost estimate not available for compute resources with multiple instance types."}, 400
305+
instance_type = instance_types[0]
293306
pricing_filters = [
294307
{"Field": "tenancy", "Value": "shared", "Type": "TERM_MATCH"},
295308
{"Field": "instanceType", "Value": instance_type, "Type": "TERM_MATCH"},

frontend/src/old-pages/Clusters/Accounting.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function JobProperties({job}: any) {
294294
<SpaceBetween direction="vertical" size="l">
295295
<ValueWithLabel label="Queue">{job.partition}</ValueWithLabel>
296296
<ValueWithLabel label="Return Code">
297-
{getIn(job, ['exit_code', 'return_code'])}
297+
{getIn(job, ['exit_code', 'return_code', 'number'])}
298298
</ValueWithLabel>
299299
<ValueWithLabel label="Exit Status">
300300
{
@@ -384,7 +384,7 @@ export default function ClusterAccounting() {
384384
clusterName,
385385
'accounting',
386386
'jobs',
387-
])
387+
]) || []
388388

389389
React.useEffect(() => {
390390
refreshAccounting({}, null, true)

0 commit comments

Comments
 (0)