Skip to content
Open
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
35 changes: 34 additions & 1 deletion ui/e2e/group-run.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, type Page } from '@playwright/test';
import { expect, test, type Locator, type Page } from '@playwright/test';
import { FakeControl, type FakeGroupRun } from './support/fake-control';

// A group run's page: one tree of its jobs, folders and nodes beside the timeline, the 40/60 split above
Expand Down Expand Up @@ -541,6 +541,39 @@ test("jobs ticked beside a group run's graph are drawn as those jobs, closed, an
await expect(members).toHaveCount(3);
});

test("an opened job's folder cards count its waiting nodes beside those done, and its folder boxes close one level at a time while the job is selected", async ({ page }) => {
const { fake, run } = server(['load_orders', 'stage_orders', 'orders_mart'], 160);
const job = run.members.find((m) => m.jobKey === 'load_orders')!;
job.nodes['model:load_orders_0'] = 'success';
job.nodes['model:load_orders_1'] = 'running';
await fake.install(page);
await page.setViewportSize({ width: 1600, height: 1000 });
await page.goto(`/runs/${run.id}`);
await page.getByRole('tablist', { name: 'View' }).getByRole('tab', { name: 'Graph' }).click({ timeout: 20_000 });
// Clicking the job selects it and opens it in place.
await page.locator('.svelte-flow__node-member').filter({ hasText: 'load_orders' }).click({ timeout: 20_000 });
const folders = page.locator('.svelte-flow__node-folder');
const boxes = page.locator('.svelte-flow__node-folderBox');
await expect(folders).toHaveCount(1);
await expect(folders.locator('.status span')).toHaveText(['1 running', '1 ok', '158 waiting']);

await folders.first().click();
await expect(boxes).toHaveCount(1);
await folders.first().click();
await expect(boxes).toHaveCount(2);
// A person clicks the header by its chevron: there, not under the selected job's box, the inner box closes.
const heads = boxes.locator('.folder-head');
const press = async (head: Locator) => {
const at = (await head.boundingBox())!;
await page.mouse.click(at.x + 20, at.y + at.height / 2);
};
await press(heads.last());
await expect(boxes).toHaveCount(1);
await press(heads.first());
await expect(boxes).toHaveCount(0);
await expect(folders).toHaveCount(1);
});

test('a folder that shares its directory with another job ticks its own nodes, and ticks fully again after a node came back', async ({ page }) => {
// Two jobs of 60 models each, both in sql/models/shared/part_0 and part_1: 30 of each job per folder.
const { fake, run } = server(['load_orders', 'stage_orders'], 60);
Expand Down
3 changes: 3 additions & 0 deletions ui/src/lib/components/graph/compact-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,8 @@ const cardFamily = pageFamily('--font-mono', 'monospace');
/** The cards' name and status line font, as the status line measures it. */
export const measureText: Measure = measureIn(cardFamily, 0.62);

/** The folder cards' status line font, as the page sets `--font-sans` (Inter). */
export const measureSans: Measure = measureIn(pageFamily('--font-sans', 'sans-serif'), 0.56);

/** The pills' name font: whatever the page sets `--font-node-compact` to. */
export const measureCompact: Measure = measureIn(pageFamily('--font-node-compact', 'sans-serif'), 0.66);
7 changes: 4 additions & 3 deletions ui/src/lib/components/graph/graph-canvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,10 @@
/* Edges, plain, highlighted or selected, are drawn beneath every card, so they never take a card's
click. The library raises edges from inside an open box to the box's contents' level, above the
cards outside it; cards are put above every edge (and selected nodes are raised by at most about
1000 per level of boxes). Open boxes (`parent`) keep the library's order, beneath the edges inside
them. An edge is hit only on its stroke. */
.graph-canvas :global(.svelte-flow__node:not(.parent)) {
1000 per level of boxes). Open boxes keep the library's order, beneath the edges inside them; they are
known by type, since the library's `parent` class is fixed when a node mounts, and a job card that
opens in place would stay raised above the folder boxes inside it. An edge is hit only on its stroke. */
.graph-canvas :global(.svelte-flow__node:not(:is(.svelte-flow__node-memberBox, .svelte-flow__node-folderBox, .svelte-flow__node-job))) {
z-index: 100000 !important;
}
.graph-canvas :global(.svelte-flow__edges svg) {
Expand Down
27 changes: 20 additions & 7 deletions ui/src/lib/components/lineage/folder-node.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,32 @@
import { Handle, Position, type NodeProps } from '@xyflow/svelte';
import type { GroupCard } from '$lib/lineage/catalog-graph';
import CompactFace from '$lib/components/graph/compact-face.svelte';
import { measureSans } from '$lib/components/graph/compact-title';
import { fonts } from '$lib/components/graph/fonts.svelte';

let { id, data }: NodeProps = $props();
const d = $derived(data as GroupCard);
// Zoomed out, the folder's colour: anything running, as the run tree's rows do, then any failure, then any stale node, then ok.
// The status line's counts, most pressing first. When they don't fit in words, each keeps its dot and
// number; the card's title still names them all.
const counts = $derived(
[
{ n: d.running, word: 'running', mark: 'running' },
{ n: d.ok, word: 'ok', color: 'var(--sb-success)' },
{ n: d.stale, word: 'stale', color: 'var(--sb-stale)' },
{ n: d.failed, word: 'failed', color: 'var(--sb-error)' },
{ n: d.skipped, word: 'skipped', mark: 'skipped' },
{ n: d.waiting, word: 'waiting', mark: 'waiting' }
].filter((c): c is typeof c & { n: number } => !!c.n)
);
const said = $derived(counts.map((c) => `${c.n} ${c.word}`).join(', '));
/** The card's 236 px less its border and the status line's padding; each count is a 6 px dot and a 5 px gap, 10 px apart. Measured again once the font has loaded. */
const words = $derived((void fonts.ready, void fonts.version, counts.reduce((w, c) => w + 11 + measureSans(`${c.n} ${c.word}`, 11, 400), 10 * (counts.length - 1)) <= 236 - 2 - 32 - 10));
const tone = $derived(d.running ? 'var(--sb-running)' : d.failed ? 'var(--sb-error)' : d.stale ? 'var(--sb-stale)' : d.ok ? 'var(--sb-success)' : 'var(--sb-text-faint)');
</script>

<!-- A closed folder; clicking it opens the folder into a box around its folders and nodes. -->
<div class="group" class:dimmed={d.dimmed} title="Open {d.group}: {plural(d.count, d.noun ?? 'node')}">
<div class="group" class:dimmed={d.dimmed} title="Open {d.group}: {plural(d.count, d.noun ?? 'node')}{said && ` (${said})`}">
<Handle type="target" position={Position.Left} class="node-handle" />
<div class="head">
<FolderIcon size={14} strokeWidth={1.75} class="glyph" />
Expand All @@ -22,12 +39,8 @@
<span class="hit" aria-hidden="true"><ChevronRightIcon size={13} class="glyph" /></span>
</div>
<div class="status">
{#if d.running}<span><i class="sb-mark" data-state="running"></i>{d.running} running</span>{/if}
{#if d.ok}<span><i style:background="var(--sb-success)"></i>{d.ok} ok</span>{/if}
{#if d.stale}<span><i style:background="var(--sb-stale)"></i>{d.stale} stale</span>{/if}
{#if d.failed}<span><i style:background="var(--sb-error)"></i>{d.failed} failed</span>{/if}
{#if d.skipped}<span><i class="sb-mark" data-state="skipped"></i>{d.skipped} skipped</span>{/if}
{#if !d.ok && !d.stale && !d.failed && !d.running && !d.skipped}<span class="faint">{d.empty ?? 'No builds'}</span>{/if}
{#each counts as c (c.word)}<span><i class={c.mark && 'sb-mark'} data-state={c.mark} style:background={c.color}></i>{c.n}{#if words}&nbsp;{c.word}{/if}</span>{/each}
{#if !counts.length}<span class="faint">{d.empty ?? 'No builds'}</span>{/if}
</div>
<CompactFace {id} title={d.label ?? d.group} {tone} kind="group" badge={d.count} running={!!d.running} />
<Handle type="source" position={Position.Right} class="node-handle" />
Expand Down
7 changes: 4 additions & 3 deletions ui/src/lib/lineage/catalog-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const topFolder = (node: CatalogNode): string => folderOf(node).split('/'

/** A closed folder's card; `label` is its path below the open folder around it, when there is one. */
/** `noun` names what the folder counts: nodes, or jobs on a group's graph. */
export type GroupCard = { group: string; label?: string; count: number; ok: number; stale: number; failed: number; running?: number; skipped?: number; dimmed?: boolean; noun?: string; empty?: string };
export type GroupCard = { group: string; label?: string; count: number; ok: number; stale: number; failed: number; running?: number; skipped?: number; waiting?: number; dimmed?: boolean; noun?: string; empty?: string };

/**
* A folder's card: how many nodes it holds, and how many last built fine, are stale or failed. A node
Expand All @@ -120,7 +120,8 @@ export function groupCard(group: string, members: CatalogNode[]): GroupCard {
failed: built.filter((n) => n.status === 'failed').length + inRun('fail'),
running: inRun('run'),
skipped: inRun('skip'),
// A folder of a run's nodes that haven't started is waiting; one the run ended without running, not run.
...(live.length === members.length ? { empty: live.some((n) => n.liveStatus === 'wait') ? 'Waiting' : 'Not run' } : {})
waiting: inRun('wait'),
// A folder of a run's nodes the run ended without running.
...(live.length === members.length ? { empty: 'Not run' } : {})
};
}
Loading