Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Accounting] Fix issues that were breaking the rendering of accounting info #340

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions frontend/src/old-pages/Clusters/Accounting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function CostEstimate({job}: any) {
}

function JobProperties({job}: any) {
console.log(job)
console.log("Processing job properties for job", job)
return (
<Container>
<SpaceBetween direction="vertical" size="l">
Expand Down 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
Loading