Skip to content

Commit

Permalink
[Accounting] Fix issues that were breaking the rendering of accountin…
Browse files Browse the repository at this point in the history
…g 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.
  • Loading branch information
gmarciani committed Jul 15, 2024
1 parent 7db92ed commit b8a4830
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 14 additions & 1 deletion api/PclusterApiHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,27 @@ def ssm_command(region, instance_id, user, run_command):
output = status["StandardOutputContent"]
return output


def _get_instance_types_for_compute_resource(compute_resource):
if "Instances" in compute_resource:
return [instance["InstanceType"] for instance in compute_resource["Instances"]]
elif "InstanceType" in compute_resource:
return [compute_resource["InstanceType"]]
else:
raise Exception("Cannot find instance types for compute resource: %s".format(compute_resource))


def _price_estimate(cluster_name, region, queue_name):
config_text = get_cluster_config_text(cluster_name, region)
config_data = yaml.safe_load(config_text)
queues = {q["Name"]: q for q in config_data["Scheduling"]["SlurmQueues"]}
queue = queues[queue_name]

if len(queue["ComputeResources"]) == 1:
instance_type = queue["ComputeResources"][0]["InstanceType"]
instance_types = _get_instance_types_for_compute_resource(compute_resource=queue["ComputeResources"][0])
if len(instance_types) > 1:
return {"message": "Cost estimate not available for compute resources with multiple instance types."}, 400
instance_type = instance_types[0]
pricing_filters = [
{"Field": "tenancy", "Value": "shared", "Type": "TERM_MATCH"},
{"Field": "instanceType", "Value": instance_type, "Type": "TERM_MATCH"},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ function SlurmAccounting(
request('post', url, args)
.then((response: any) => {
if (response.status === 200) {
console.log(response.data)
console.log("Accounting data retrieved", response.data)
successCallback && successCallback(response.data)
}
})
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/old-pages/Clusters/Accounting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function JobProperties({job}: any) {
<SpaceBetween direction="vertical" size="l">
<ValueWithLabel label="Queue">{job.partition}</ValueWithLabel>
<ValueWithLabel label="Return Code">
{getIn(job, ['exit_code', 'return_code'])}
{getIn(job, ['exit_code', 'return_code', 'number'])}
</ValueWithLabel>
<ValueWithLabel label="Exit Status">
{
Expand Down Expand Up @@ -384,7 +384,7 @@ export default function ClusterAccounting() {
clusterName,
'accounting',
'jobs',
])
]) || []

React.useEffect(() => {
refreshAccounting({}, null, true)
Expand Down

0 comments on commit b8a4830

Please sign in to comment.