mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-01 11:13:50 +02:00
Migrate jobView components
This commit is contained in:
parent
d731611e0c
commit
d7379a1af2
@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
getContext
|
getContext,
|
||||||
|
onMount
|
||||||
} from "svelte";
|
} from "svelte";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
@ -21,17 +22,26 @@
|
|||||||
} from "@sveltestrap/sveltestrap";
|
} from "@sveltestrap/sveltestrap";
|
||||||
import { round } from "mathjs";
|
import { round } from "mathjs";
|
||||||
|
|
||||||
export let jobId;
|
/* Svelte 5 Props */
|
||||||
export let jobEnergy = null;
|
let {
|
||||||
export let jobEnergyFootprint = null;
|
jobId,
|
||||||
|
jobEnergy = null,
|
||||||
|
jobEnergyFootprint = null
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
/* Const Init */
|
||||||
const carbonPerkWh = getContext("emission");
|
const carbonPerkWh = getContext("emission");
|
||||||
let carbonMass;
|
|
||||||
|
|
||||||
$: if (carbonPerkWh) {
|
/* State Init */
|
||||||
// ( kWh * g/kWh) / 1000 = kg || Rounded to 2 Digits via [ round(x * 100) / 100 ]
|
let carbonMass = $state(0);
|
||||||
carbonMass = round( ((jobEnergy ? jobEnergy : 0.0) * carbonPerkWh) / 10 ) / 100;
|
|
||||||
}
|
/* On Mount */
|
||||||
|
onMount(() => {
|
||||||
|
if (carbonPerkWh) {
|
||||||
|
// ( kWh * g/kWh) / 1000 = kg || Rounded to 2 Digits via [ round(x * 100) / 100 ]
|
||||||
|
carbonMass = round( ((jobEnergy ? jobEnergy : 0.0) * carbonPerkWh) / 10 ) / 100;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
|
@ -7,73 +7,78 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
queryStore,
|
queryStore,
|
||||||
gql,
|
gql,
|
||||||
getContextClient
|
getContextClient
|
||||||
} from "@urql/svelte";
|
} from "@urql/svelte";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
Spinner
|
Spinner
|
||||||
} from "@sveltestrap/sveltestrap";
|
} from "@sveltestrap/sveltestrap";
|
||||||
import {
|
import {
|
||||||
transformDataForRoofline,
|
transformDataForRoofline,
|
||||||
} from "../generic/utils.js";
|
} from "../generic/utils.js";
|
||||||
import Roofline from "../generic/plots/Roofline.svelte";
|
import Roofline from "../generic/plots/Roofline.svelte";
|
||||||
|
|
||||||
export let job;
|
/* Svelte 5 Props */
|
||||||
export let clusters;
|
let {
|
||||||
|
job,
|
||||||
|
clusters,
|
||||||
|
} = $props();
|
||||||
|
|
||||||
let roofWidth;
|
/* Const Init */
|
||||||
|
const client = getContextClient();
|
||||||
const client = getContextClient();
|
const roofQuery = gql`
|
||||||
const roofQuery = gql`
|
query ($dbid: ID!, $selectedMetrics: [String!]!, $selectedScopes: [MetricScope!]!, $selectedResolution: Int) {
|
||||||
query ($dbid: ID!, $selectedMetrics: [String!]!, $selectedScopes: [MetricScope!]!, $selectedResolution: Int) {
|
jobMetrics(id: $dbid, metrics: $selectedMetrics, scopes: $selectedScopes, resolution: $selectedResolution) {
|
||||||
jobMetrics(id: $dbid, metrics: $selectedMetrics, scopes: $selectedScopes, resolution: $selectedResolution) {
|
name
|
||||||
name
|
scope
|
||||||
scope
|
metric {
|
||||||
metric {
|
series {
|
||||||
series {
|
data
|
||||||
data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
`;
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
// Roofline: Always load roofMetrics with configured timestep (Resolution: 0)
|
/* State Init */
|
||||||
$: roofMetrics = queryStore({
|
let roofWidth = $state(0);
|
||||||
client: client,
|
|
||||||
query: roofQuery,
|
|
||||||
variables: { dbid: job.id, selectedMetrics: ["flops_any", "mem_bw"], selectedScopes: ["node"], selectedResolution: 0 },
|
|
||||||
});
|
|
||||||
|
|
||||||
|
/* Derived */
|
||||||
|
// Roofline: Always load roofMetrics with configured timestep (Resolution: 0)
|
||||||
|
const roofMetrics = $derived(queryStore({
|
||||||
|
client: client,
|
||||||
|
query: roofQuery,
|
||||||
|
variables: { dbid: job.id, selectedMetrics: ["flops_any", "mem_bw"], selectedScopes: ["node"], selectedResolution: 0 },
|
||||||
|
})
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $roofMetrics.error}
|
{#if $roofMetrics.error}
|
||||||
<Card body color="danger">{$roofMetrics.error.message}</Card>
|
<Card body color="danger">{$roofMetrics.error.message}</Card>
|
||||||
{:else if $roofMetrics?.data}
|
{:else if $roofMetrics?.data}
|
||||||
<Card style="height: 400px;">
|
<Card style="height: 400px;">
|
||||||
<div bind:clientWidth={roofWidth}>
|
<div bind:clientWidth={roofWidth}>
|
||||||
<Roofline
|
<Roofline
|
||||||
width={roofWidth}
|
width={roofWidth}
|
||||||
subCluster={clusters
|
subCluster={clusters
|
||||||
.find((c) => c.name == job.cluster)
|
.find((c) => c.name == job.cluster)
|
||||||
.subClusters.find((sc) => sc.name == job.subCluster)}
|
.subClusters.find((sc) => sc.name == job.subCluster)}
|
||||||
data={transformDataForRoofline(
|
data={transformDataForRoofline(
|
||||||
$roofMetrics.data?.jobMetrics?.find(
|
$roofMetrics.data?.jobMetrics?.find(
|
||||||
(m) => m.name == "flops_any" && m.scope == "node",
|
(m) => m.name == "flops_any" && m.scope == "node",
|
||||||
)?.metric,
|
)?.metric,
|
||||||
$roofMetrics.data?.jobMetrics?.find(
|
$roofMetrics.data?.jobMetrics?.find(
|
||||||
(m) => m.name == "mem_bw" && m.scope == "node",
|
(m) => m.name == "mem_bw" && m.scope == "node",
|
||||||
)?.metric,
|
)?.metric,
|
||||||
)}
|
)}
|
||||||
allowSizeChange
|
allowSizeChange
|
||||||
renderTime
|
renderTime
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
{:else}
|
{:else}
|
||||||
<Spinner secondary />
|
<Spinner secondary />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -26,16 +26,14 @@
|
|||||||
import MetricSelection from "../generic/select/MetricSelection.svelte";
|
import MetricSelection from "../generic/select/MetricSelection.svelte";
|
||||||
import StatsTable from "./statstab/StatsTable.svelte";
|
import StatsTable from "./statstab/StatsTable.svelte";
|
||||||
|
|
||||||
export let job;
|
/* Svelte 5 Props */
|
||||||
export let clusters;
|
let {
|
||||||
export let tabActive;
|
job,
|
||||||
|
clusters,
|
||||||
let loadScopes = false;
|
tabActive,
|
||||||
let selectedScopes = [];
|
} = $props();
|
||||||
let selectedMetrics = [];
|
|
||||||
let totalMetrics = 0; // For Info Only, filled by MetricSelection Component
|
|
||||||
let isMetricSelectionOpen = false;
|
|
||||||
|
|
||||||
|
/* Const Init */
|
||||||
const client = getContextClient();
|
const client = getContextClient();
|
||||||
const query = gql`
|
const query = gql`
|
||||||
query ($dbid: ID!, $selectedMetrics: [String!]!, $selectedScopes: [MetricScope!]!) {
|
query ($dbid: ID!, $selectedMetrics: [String!]!, $selectedScopes: [MetricScope!]!) {
|
||||||
@ -55,16 +53,29 @@
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
$: scopedStats = queryStore({
|
/* State Init */
|
||||||
client: client,
|
let moreScopes = $state(false);
|
||||||
query: query,
|
let selectedScopes = $state([]);
|
||||||
variables: { dbid: job.id, selectedMetrics, selectedScopes },
|
let selectedMetrics = $state([]);
|
||||||
});
|
let totalMetrics = $state(0); // For Info Only, filled by MetricSelection Component
|
||||||
|
let isMetricSelectionOpen = $state(false);
|
||||||
|
|
||||||
$: if (loadScopes) {
|
/* Derived */
|
||||||
|
const scopedStats = $derived(queryStore({
|
||||||
|
client: client,
|
||||||
|
query: query,
|
||||||
|
variables: { dbid: job.id, selectedMetrics, selectedScopes },
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Functions */
|
||||||
|
function loadScopes() {
|
||||||
|
// Archived Jobs Load All Scopes By Default (See Backend)
|
||||||
|
moreScopes = true;
|
||||||
selectedScopes = ["node", "socket", "core", "hwthread", "accelerator"];
|
selectedScopes = ["node", "socket", "core", "hwthread", "accelerator"];
|
||||||
}
|
};
|
||||||
|
|
||||||
|
/* On Init */
|
||||||
// Handle Job Query on Init -> is not executed anymore
|
// Handle Job Query on Init -> is not executed anymore
|
||||||
getContext("on-init")(() => {
|
getContext("on-init")(() => {
|
||||||
if (!job) return;
|
if (!job) return;
|
||||||
@ -98,12 +109,12 @@
|
|||||||
<TabPane tabId="stats" tab="Statistics Table" class="overflow-x-auto" active={tabActive}>
|
<TabPane tabId="stats" tab="Statistics Table" class="overflow-x-auto" active={tabActive}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col class="m-2">
|
<Col class="m-2">
|
||||||
<Button outline on:click={() => (isMetricSelectionOpen = true)} class="px-2" color="primary" style="margin-right:0.5rem">
|
<Button outline onclick={() => (isMetricSelectionOpen = true)} class="px-2" color="primary" style="margin-right:0.5rem">
|
||||||
Select Metrics (Selected {selectedMetrics.length} of {totalMetrics} available)
|
Select Metrics (Selected {selectedMetrics.length} of {totalMetrics} available)
|
||||||
</Button>
|
</Button>
|
||||||
{#if job.numNodes > 1}
|
{#if job.numNodes > 1 && job.state === "running"}
|
||||||
<Button class="px-2 ml-auto" color="success" outline on:click={() => (loadScopes = !loadScopes)} disabled={loadScopes}>
|
<Button class="px-2 ml-auto" color="success" outline onclick={loadScopes} disabled={moreScopes}>
|
||||||
{#if !loadScopes}
|
{#if !moreScopes}
|
||||||
<Icon name="plus-square-fill" style="margin-right:0.25rem"/> Add More Scopes
|
<Icon name="plus-square-fill" style="margin-right:0.25rem"/> Add More Scopes
|
||||||
{:else}
|
{:else}
|
||||||
<Icon name="check-square-fill" style="margin-right:0.25rem"/> OK: Scopes Added
|
<Icon name="check-square-fill" style="margin-right:0.25rem"/> OK: Scopes Added
|
||||||
|
Loading…
x
Reference in New Issue
Block a user