@milabench/bujang 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3616 -3574
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/views/OverviewPanels.tsx +54 -8
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The panels of a job's Overview layout: the log view and the charts, and the bar saying where the layout comes from. */
|
|
2
|
-
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import React, { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { Alert, Badge, Box, Button, Card, Code, Dialog, Flex, HStack, Input, NativeSelect, Spinner, Table, Text, VStack, Wrap } from '@chakra-ui/react';
|
|
4
4
|
import { useQueries, useQuery } from '@tanstack/react-query';
|
|
5
5
|
import { LuArrowDown, LuArrowLeft, LuArrowRight, LuArrowUp, LuChevronDown, LuChevronRight, LuColumns2, LuDownload, LuExternalLink, LuFile, LuFilter, LuFilterX, LuFolder, LuPlus, LuSettings, LuX } from 'react-icons/lu';
|
|
@@ -203,6 +203,20 @@ export const LogPanel: React.FC<PanelProps<'logs'>> = ({ jrJobId, files, panel,
|
|
|
203
203
|
const total = (rows?.length || 0) + (eventsOn ? eventRows?.length || 0 : 0);
|
|
204
204
|
const truncated = (rows?.length || 0) >= LOG_LIMIT || (eventsOn && (eventRows?.length || 0) >= LOG_LIMIT);
|
|
205
205
|
|
|
206
|
+
// follow the end of the log: on until the user scrolls up, on again at the bottom
|
|
207
|
+
const listRef = useRef<HTMLDivElement>(null);
|
|
208
|
+
const [follow, setFollow] = useState(true);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
const list = listRef.current;
|
|
211
|
+
if (follow && list) list.scrollTop = list.scrollHeight;
|
|
212
|
+
}, [follow, shown]);
|
|
213
|
+
const onScroll = () => {
|
|
214
|
+
const list = listRef.current;
|
|
215
|
+
if (!list) return;
|
|
216
|
+
const atBottom = list.scrollHeight - list.scrollTop - list.clientHeight < 8;
|
|
217
|
+
if (atBottom !== follow) setFollow(atBottom);
|
|
218
|
+
};
|
|
219
|
+
|
|
206
220
|
return (
|
|
207
221
|
<PanelFrame
|
|
208
222
|
title={panel.title || 'Logs'}
|
|
@@ -243,6 +257,15 @@ export const LogPanel: React.FC<PanelProps<'logs'>> = ({ jrJobId, files, panel,
|
|
|
243
257
|
</Button>
|
|
244
258
|
)}
|
|
245
259
|
<Input size="xs" w="220px" placeholder={withEvents ? 'search messages / events' : 'search logger / message'} value={search} onChange={(e) => setSearch(e.target.value)} />
|
|
260
|
+
<Button
|
|
261
|
+
size="2xs"
|
|
262
|
+
variant={follow ? 'solid' : 'outline'}
|
|
263
|
+
aria-pressed={follow}
|
|
264
|
+
onClick={() => setFollow(!follow)}
|
|
265
|
+
title="Keep the end of the log in view as records arrive (scrolling up stops it, the bottom starts it again)"
|
|
266
|
+
>
|
|
267
|
+
<LuArrowDown /> follow
|
|
268
|
+
</Button>
|
|
246
269
|
</Wrap>
|
|
247
270
|
{withEvents && (
|
|
248
271
|
<Wrap gap={1} mb={2} align="center">
|
|
@@ -266,10 +289,10 @@ export const LogPanel: React.FC<PanelProps<'logs'>> = ({ jrJobId, files, panel,
|
|
|
266
289
|
)}
|
|
267
290
|
{rows && !rows.length && !eventsOn && (
|
|
268
291
|
<Text fontSize="sm" color="var(--color-text-muted)">
|
|
269
|
-
No log records. A job writes them with <Code>bujang.instrumentation.
|
|
292
|
+
No log records. A job writes them with <Code>bujang.instrumentation.setup_events(attach_logging=True)</Code>.
|
|
270
293
|
</Text>
|
|
271
294
|
)}
|
|
272
|
-
<Box maxH="360px" overflowY="auto" fontFamily="mono" fontSize="xs">
|
|
295
|
+
<Box ref={listRef} onScroll={onScroll} maxH="360px" overflowY="auto" fontFamily="mono" fontSize="xs">
|
|
273
296
|
{shown.map(({ row: r, event }, i) => (
|
|
274
297
|
<Box
|
|
275
298
|
key={i}
|
|
@@ -514,7 +537,7 @@ const STATS: StatName[] = ['count', 'mean', 'std', 'min', 'median', 'p95', 'p99'
|
|
|
514
537
|
|
|
515
538
|
const STAT_HELP: Partial<Record<StatName, string>> = {
|
|
516
539
|
total: 'sum of the values',
|
|
517
|
-
busy: 'total over the time from the first start to the last end of these rows',
|
|
540
|
+
busy: 'total over the time from the first start to the last end of these rows (above 100% when they overlap: workers combined)',
|
|
518
541
|
};
|
|
519
542
|
|
|
520
543
|
const splitBy = (by: string | undefined) => (by ?? '').split(',').map((f) => f.trim()).filter(Boolean);
|
|
@@ -548,9 +571,9 @@ const formatStat = (value: number) => {
|
|
|
548
571
|
return size !== 0 && size < 1e-3 ? value.toExponential(3) : String(+value.toPrecision(5));
|
|
549
572
|
};
|
|
550
573
|
|
|
551
|
-
/** The table rows of a metric: one, or one per value of its `by` fields, the largest total first */
|
|
552
|
-
const metricRows = (m: StatsMetric, rows: Record<string, unknown>[]): { label: string | null; stats: Stats | null }[] => {
|
|
553
|
-
const by = splitBy(m.by);
|
|
574
|
+
/** The table rows of a metric: one, or one per value of its `by` fields (but the `combined` ones), the largest total first */
|
|
575
|
+
const metricRows = (m: StatsMetric, rows: Record<string, unknown>[], combined: string[] = []): { label: string | null; stats: Stats | null }[] => {
|
|
576
|
+
const by = splitBy(m.by).filter((f) => !combined.includes(f));
|
|
554
577
|
const groups = new Map<string, Record<string, unknown>[]>();
|
|
555
578
|
rows.forEach((r) => {
|
|
556
579
|
if (!isNumber(valueOf(r, m.field))) return;
|
|
@@ -604,6 +627,9 @@ export const StatsPanel: React.FC<PanelProps<'stats'>> = ({ jrJobId, files, pane
|
|
|
604
627
|
const error = results.find((r) => r.error)?.error as ApiError | undefined;
|
|
605
628
|
const rowsOf = (event: string) => results[events.indexOf(event)]?.data;
|
|
606
629
|
const truncated = results.some((r) => (r.data?.length ?? 0) >= ROW_LIMIT);
|
|
630
|
+
// the `by` fields of the metrics: each one can be combined (its values in one row: the workers together)
|
|
631
|
+
const byFields = useMemo(() => [...new Set(metrics.flatMap((m) => splitBy(m.by)))], [metrics]);
|
|
632
|
+
const [combined, setCombined] = useState<string[]>([]);
|
|
607
633
|
|
|
608
634
|
return (
|
|
609
635
|
<PanelFrame
|
|
@@ -613,6 +639,26 @@ export const StatsPanel: React.FC<PanelProps<'stats'>> = ({ jrJobId, files, pane
|
|
|
613
639
|
onSettings={() => setOpen(true)}
|
|
614
640
|
settingsTitle="Pick the fields of the stats"
|
|
615
641
|
info={<>
|
|
642
|
+
{metrics.length > 0 && byFields.length > 0 && (
|
|
643
|
+
<HStack gap={1}>
|
|
644
|
+
<Text>a row per</Text>
|
|
645
|
+
{byFields.map((field) => {
|
|
646
|
+
const on = !combined.includes(field);
|
|
647
|
+
return (
|
|
648
|
+
<Button
|
|
649
|
+
key={field}
|
|
650
|
+
size="2xs"
|
|
651
|
+
variant={on ? 'solid' : 'outline'}
|
|
652
|
+
aria-pressed={on}
|
|
653
|
+
onClick={() => setCombined(on ? [...combined, field] : combined.filter((f) => f !== field))}
|
|
654
|
+
title={on ? `Combine the values of ${field} in one row` : `A row per value of ${field}`}
|
|
655
|
+
>
|
|
656
|
+
{field}
|
|
657
|
+
</Button>
|
|
658
|
+
);
|
|
659
|
+
})}
|
|
660
|
+
</HStack>
|
|
661
|
+
)}
|
|
616
662
|
{results.some((r) => r.isFetching) && <Spinner size="xs" />}
|
|
617
663
|
{truncated && <Text>first {ROW_LIMIT} rows only</Text>}
|
|
618
664
|
</>}
|
|
@@ -638,7 +684,7 @@ export const StatsPanel: React.FC<PanelProps<'stats'>> = ({ jrJobId, files, pane
|
|
|
638
684
|
<Table.Body>
|
|
639
685
|
{metrics.map((m, i) => {
|
|
640
686
|
const rows = rowsOf(m.event);
|
|
641
|
-
const lines = rows ? metricRows(m, rows) : [{ label: null, stats: null }];
|
|
687
|
+
const lines = rows ? metricRows(m, rows, combined) : [{ label: null, stats: null }];
|
|
642
688
|
return lines.map(({ label, stats }) => (
|
|
643
689
|
<Table.Row key={`${i}:${m.event}:${m.field}:${label ?? ''}`}>
|
|
644
690
|
<Table.Cell fontFamily="mono" fontSize="xs" whiteSpace="nowrap" title={`${m.field} of the ${m.event || 'records'} rows`}>
|