2024-07-25 17:10:00 +02:00
|
|
|
<!--
|
|
|
|
@component Metric plot wrapper with user scope selection; used in job detail view
|
|
|
|
|
|
|
|
Properties:
|
|
|
|
- `job Object`: The GQL job object
|
|
|
|
- `metricName String`: The metrics name
|
|
|
|
- `metricUnit Object`: The metrics GQL unit object
|
|
|
|
- `nativeScope String`: The metrics native scope
|
|
|
|
- `scopes [String]`: The scopes returned for this metric
|
|
|
|
- `width Number`: Nested plot width
|
|
|
|
- `rawData [Object]`: Metric data for all scopes returned for this metric
|
|
|
|
- `isShared Bool?`: If this job used shared resources; will adapt threshold indicators accordingly in downstream plots [Default: false]
|
|
|
|
-->
|
|
|
|
|
2022-06-22 11:20:57 +02:00
|
|
|
<script>
|
2024-07-22 15:41:33 +02:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2024-03-09 10:30:40 +01:00
|
|
|
import Timeseries from "./plots/MetricPlot.svelte";
|
|
|
|
import {
|
|
|
|
InputGroup,
|
|
|
|
InputGroupText,
|
|
|
|
Spinner,
|
|
|
|
Card,
|
|
|
|
} from "@sveltestrap/sveltestrap";
|
2024-07-22 15:41:33 +02:00
|
|
|
import { minScope } from "./utils";
|
2022-06-22 11:20:57 +02:00
|
|
|
|
2024-03-09 10:30:40 +01:00
|
|
|
export let job;
|
|
|
|
export let metricName;
|
2024-07-22 15:41:33 +02:00
|
|
|
export let metricUnit;
|
|
|
|
export let nativeScope;
|
2024-03-09 10:30:40 +01:00
|
|
|
export let scopes;
|
|
|
|
export let width;
|
|
|
|
export let rawData;
|
|
|
|
export let isShared = false;
|
2022-06-22 11:20:57 +02:00
|
|
|
|
2024-03-09 10:30:40 +01:00
|
|
|
const dispatch = createEventDispatcher();
|
2024-07-22 15:41:33 +02:00
|
|
|
const unit = (metricUnit?.prefix ? metricUnit.prefix : "") + (metricUnit?.base ? metricUnit.base : "")
|
|
|
|
|
2024-03-09 10:30:40 +01:00
|
|
|
let selectedHost = null,
|
|
|
|
plot,
|
|
|
|
fetching = false,
|
|
|
|
error = null;
|
|
|
|
let selectedScope = minScope(scopes);
|
2022-06-22 11:20:57 +02:00
|
|
|
|
2024-05-08 16:17:42 +02:00
|
|
|
let statsPattern = /(.*)-stat$/
|
2024-05-02 16:32:01 +02:00
|
|
|
let statsSeries = rawData.map((data) => data?.statisticsSeries ? data.statisticsSeries : null)
|
|
|
|
let selectedScopeIndex
|
|
|
|
|
2024-03-09 10:30:40 +01:00
|
|
|
$: availableScopes = scopes;
|
2024-05-02 16:32:01 +02:00
|
|
|
$: patternMatches = statsPattern.exec(selectedScope)
|
|
|
|
$: if (!patternMatches) {
|
|
|
|
selectedScopeIndex = scopes.findIndex((s) => s == selectedScope);
|
|
|
|
} else {
|
|
|
|
selectedScopeIndex = scopes.findIndex((s) => s == patternMatches[1]);
|
|
|
|
}
|
2024-03-09 10:30:40 +01:00
|
|
|
$: data = rawData[selectedScopeIndex];
|
|
|
|
$: series = data?.series.filter(
|
|
|
|
(series) => selectedHost == null || series.hostname == selectedHost,
|
|
|
|
);
|
|
|
|
|
2024-07-22 15:41:33 +02:00
|
|
|
$: if (selectedScope == "load-all") dispatch("load-all");
|
2022-06-22 11:20:57 +02:00
|
|
|
</script>
|
2024-03-09 10:30:40 +01:00
|
|
|
|
2022-06-22 11:20:57 +02:00
|
|
|
<InputGroup>
|
2024-03-09 10:30:40 +01:00
|
|
|
<InputGroupText style="min-width: 150px;">
|
2024-07-22 15:41:33 +02:00
|
|
|
{metricName} ({unit})
|
2024-03-09 10:30:40 +01:00
|
|
|
</InputGroupText>
|
|
|
|
<select class="form-select" bind:value={selectedScope}>
|
2024-05-02 16:32:01 +02:00
|
|
|
{#each availableScopes as scope, index}
|
2024-03-09 10:30:40 +01:00
|
|
|
<option value={scope}>{scope}</option>
|
2024-05-02 16:32:01 +02:00
|
|
|
{#if statsSeries[index]}
|
2024-05-08 16:17:42 +02:00
|
|
|
<option value={scope + '-stat'}>stats series ({scope})</option>
|
2024-05-02 16:32:01 +02:00
|
|
|
{/if}
|
2024-03-09 10:30:40 +01:00
|
|
|
{/each}
|
2024-07-22 15:41:33 +02:00
|
|
|
{#if availableScopes.length == 1 && nativeScope != "node"}
|
|
|
|
<option value={"load-all"}>Load all...</option>
|
2022-06-22 11:20:57 +02:00
|
|
|
{/if}
|
2024-03-09 10:30:40 +01:00
|
|
|
</select>
|
|
|
|
{#if job.resources.length > 1}
|
2024-05-02 16:32:01 +02:00
|
|
|
<select class="form-select" bind:value={selectedHost} disabled={patternMatches}>
|
2024-03-09 10:30:40 +01:00
|
|
|
<option value={null}>All Hosts</option>
|
|
|
|
{#each job.resources as { hostname }}
|
|
|
|
<option value={hostname}>{hostname}</option>
|
|
|
|
{/each}
|
|
|
|
</select>
|
|
|
|
{/if}
|
2022-06-22 11:20:57 +02:00
|
|
|
</InputGroup>
|
|
|
|
{#key series}
|
2024-03-09 10:30:40 +01:00
|
|
|
{#if fetching == true}
|
|
|
|
<Spinner />
|
|
|
|
{:else if error != null}
|
|
|
|
<Card body color="danger">{error.message}</Card>
|
2024-05-02 16:32:01 +02:00
|
|
|
{:else if series != null && !patternMatches}
|
|
|
|
<Timeseries
|
|
|
|
bind:this={plot}
|
|
|
|
{width}
|
|
|
|
height={300}
|
2024-07-22 15:41:33 +02:00
|
|
|
cluster={job.cluster}
|
|
|
|
subCluster={job.subCluster}
|
2024-05-02 16:32:01 +02:00
|
|
|
timestep={data.timestep}
|
|
|
|
scope={selectedScope}
|
|
|
|
metric={metricName}
|
|
|
|
{series}
|
|
|
|
{isShared}
|
|
|
|
resources={job.resources}
|
|
|
|
/>
|
|
|
|
{:else if statsSeries[selectedScopeIndex] != null && patternMatches}
|
2024-03-09 10:30:40 +01:00
|
|
|
<Timeseries
|
|
|
|
bind:this={plot}
|
|
|
|
{width}
|
|
|
|
height={300}
|
2024-07-22 15:41:33 +02:00
|
|
|
cluster={job.cluster}
|
|
|
|
subCluster={job.subCluster}
|
2024-03-09 10:30:40 +01:00
|
|
|
timestep={data.timestep}
|
|
|
|
scope={selectedScope}
|
|
|
|
metric={metricName}
|
|
|
|
{series}
|
|
|
|
{isShared}
|
|
|
|
resources={job.resources}
|
2024-05-02 16:32:01 +02:00
|
|
|
statisticsSeries={statsSeries[selectedScopeIndex]}
|
|
|
|
useStatsSeries={!!statsSeries[selectedScopeIndex]}
|
2024-03-09 10:30:40 +01:00
|
|
|
/>
|
|
|
|
{/if}
|
2022-06-22 11:20:57 +02:00
|
|
|
{/key}
|