Repository navigation
feat(studio): Anonymizer job detail page [ASTD-330] #962
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9245329
feat(studio): Anonymizer job detail page [ASTD-330]
marcusds 5e60f55
fix(studio): give the job source its own row [ASTD-330]
marcusds 7c896f2
fix(studio): download job results through the shared helper [ASTD-330]
marcusds 0d59ebd
fix(studio): surface results and logs query failures [ASTD-330]
marcusds 81bb5bd
feat(studio): preview job results and surface failed records [ASTD-330]
marcusds 6460227
refactor(studio): reuse parseDataFile and DataView in the job preview…
marcusds 0057555
perf(studio): stop the expanded-cell modal re-rendering the preview t…
marcusds ef6b5f9
refactor(studio): trim comments on the job detail route [ASTD-330]
marcusds cc56591
fix(studio): narrow original_text_column to a string [ASTD-330]
marcusds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
web/packages/studio/src/routes/AnonymizerJobDetailRoute/components/ExpandedCellModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import type { TableExpandableCellState } from '@nemo/common/src/components/DataView/TableExpandableCell'; | ||
| import { Button, Flex, Modal, Text } from '@nvidia/foundations-react-core'; | ||
| import type { FC } from 'react'; | ||
|
|
||
| interface ExpandedCellModalProps { | ||
| readonly cell: TableExpandableCellState | null; | ||
| readonly onClose: () => void; | ||
| } | ||
|
|
||
| export const ExpandedCellModal: FC<ExpandedCellModalProps> = ({ cell, onClose }) => ( | ||
| <Modal | ||
| open={cell !== null} | ||
| onOpenChange={(open) => { | ||
| if (!open) onClose(); | ||
| }} | ||
| slotHeading={cell?.title ?? 'Cell Content'} | ||
| className="w-[90vw] max-w-[1000px]" | ||
| slotFooter={ | ||
| <Flex justify="end" align="center" className="w-full"> | ||
| <Button kind="tertiary" onClick={onClose}> | ||
| Close | ||
| </Button> | ||
| </Flex> | ||
| } | ||
| > | ||
| <div className="max-h-[70vh] overflow-auto"> | ||
| <Text kind="body/regular/md" className="whitespace-pre-wrap"> | ||
| {cell?.content} | ||
| </Text> | ||
| </div> | ||
| </Modal> | ||
| ); |
80 changes: 80 additions & 0 deletions
80
web/packages/studio/src/routes/AnonymizerJobDetailRoute/components/FailedRecordsPanel.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { | ||
| Banner, | ||
| Panel, | ||
| TableBody, | ||
| TableDataCell, | ||
| TableHead, | ||
| TableHeaderCell, | ||
| TableRoot, | ||
| TableRow, | ||
| Text, | ||
| } from '@nvidia/foundations-react-core'; | ||
| import { useDatasetFileContent } from '@studio/api/datasets/useDatasetFileContent'; | ||
| import { parseArtifactUrl } from '@studio/routes/AnonymizerJobDetailRoute/util'; | ||
| import { useMemo, type FC } from 'react'; | ||
|
|
||
| interface FailedRecordsPanelProps { | ||
| readonly workspace: string; | ||
| readonly artifactUrl: string | undefined; | ||
| } | ||
|
|
||
| interface FailedRecord { | ||
| readonly record_id?: string; | ||
| readonly step?: string; | ||
| readonly reason?: string; | ||
| } | ||
|
|
||
| export const FailedRecordsPanel: FC<FailedRecordsPanelProps> = ({ workspace, artifactUrl }) => { | ||
| const location = parseArtifactUrl(artifactUrl); | ||
|
|
||
| const { data, error } = useDatasetFileContent({ | ||
| workspace, | ||
| name: location?.fileset ?? '', | ||
| path: `${location?.basePath}/failed_records.json`, | ||
| // A truncated JSON array parses to nothing, hiding every failure. | ||
| fullContent: true, | ||
| enabled: !!location, | ||
| }); | ||
|
|
||
| const records = useMemo<FailedRecord[]>(() => { | ||
| try { | ||
| const parsed = JSON.parse(data ?? '[]'); | ||
| return Array.isArray(parsed) ? (parsed as FailedRecord[]) : []; | ||
| } catch { | ||
| return []; | ||
| } | ||
| }, [data]); | ||
|
|
||
| if (error || !records.length) return null; | ||
|
|
||
| return ( | ||
| <Panel slotHeading={`Failed Records (${records.length})`} elevation="high" density="compact"> | ||
| <Banner kind="inline" status="warning"> | ||
| These records were dropped during processing and are absent from the results. | ||
| </Banner> | ||
| <TableRoot className="bg-transparent w-full mt-density-md" align="left"> | ||
| <TableHead> | ||
| <TableRow> | ||
| <TableHeaderCell>Record</TableHeaderCell> | ||
| <TableHeaderCell>Step</TableHeaderCell> | ||
| <TableHeaderCell>Reason</TableHeaderCell> | ||
| </TableRow> | ||
| </TableHead> | ||
| <TableBody> | ||
| {records.map((record, index) => ( | ||
| <TableRow key={record.record_id ?? index}> | ||
| <TableDataCell> | ||
| <Text kind="body/regular/sm">{record.record_id ?? '—'}</Text> | ||
| </TableDataCell> | ||
| <TableDataCell>{record.step ?? '—'}</TableDataCell> | ||
| <TableDataCell>{record.reason ?? '—'}</TableDataCell> | ||
| </TableRow> | ||
| ))} | ||
| </TableBody> | ||
| </TableRoot> | ||
| </Panel> | ||
| ); | ||
| }; | ||
51 changes: 51 additions & 0 deletions
51
web/packages/studio/src/routes/AnonymizerJobDetailRoute/components/JobSummaryPanel.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { KVPair } from '@nemo/common/src/components/KVPair'; | ||
| import { RelativeTime } from '@nemo/common/src/components/RelativeTime'; | ||
| import { StatusBadge } from '@nemo/common/src/components/StatusBadge'; | ||
| import type { RunJob } from '@nemo/sdk/generated/anonymizer/schema'; | ||
| import { Banner, Grid, Panel, Stack } from '@nvidia/foundations-react-core'; | ||
| import { EMPTY_FIELD_VALUE } from '@studio/constants/constants'; | ||
| import { jobSource, jobStrategy } from '@studio/routes/AnonymizerJobDetailRoute/util'; | ||
| import type { FC } from 'react'; | ||
|
|
||
| interface JobSummaryPanelProps { | ||
| readonly job: RunJob; | ||
| } | ||
|
|
||
| export const JobSummaryPanel: FC<JobSummaryPanelProps> = ({ job }) => { | ||
| const errorMessage = job.error_details?.message as string | undefined; | ||
|
|
||
| return ( | ||
| <Panel slotHeading="Job Details" elevation="high" density="compact"> | ||
| <Stack gap="density-xl"> | ||
| <Grid cols={{ base: 1, md: 2 }} gap="density-lg"> | ||
| <KVPair | ||
| label="Status" | ||
| value={job.status ? <StatusBadge status={job.status} /> : EMPTY_FIELD_VALUE} | ||
| /> | ||
| <KVPair label="Strategy" value={jobStrategy(job) ?? EMPTY_FIELD_VALUE} /> | ||
| <KVPair | ||
| label="Created" | ||
| value={job.created_at ? <RelativeTime datetime={job.created_at} /> : EMPTY_FIELD_VALUE} | ||
| /> | ||
| <KVPair | ||
| label="Updated" | ||
| value={job.updated_at ? <RelativeTime datetime={job.updated_at} /> : EMPTY_FIELD_VALUE} | ||
| /> | ||
| <KVPair | ||
| label="Created by" | ||
| value={(job.ownership?.created_by as string | undefined) ?? EMPTY_FIELD_VALUE} | ||
| /> | ||
| </Grid> | ||
| <KVPair label="Source" value={jobSource(job) ?? EMPTY_FIELD_VALUE} /> | ||
| {errorMessage ? ( | ||
| <Banner kind="inline" status="error"> | ||
| {errorMessage} | ||
| </Banner> | ||
| ) : null} | ||
| </Stack> | ||
| </Panel> | ||
| ); | ||
| }; |
81 changes: 81 additions & 0 deletions
81
web/packages/studio/src/routes/AnonymizerJobDetailRoute/components/ResultsPanel.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { triggerDownload } from '@nemo/common/src/utils/file'; | ||
| import { anonymizerDownloadRunJobResult } from '@nemo/sdk/generated/anonymizer/api'; | ||
| import type { PlatformJobResultResponse } from '@nemo/sdk/generated/anonymizer/schema'; | ||
| import { Banner, Button, Flex, Panel, Spinner, Stack, Text } from '@nvidia/foundations-react-core'; | ||
| import { Download } from 'lucide-react'; | ||
| import { useState, type FC } from 'react'; | ||
|
|
||
| interface ResultsPanelProps { | ||
| readonly workspace: string; | ||
| readonly jobName: string; | ||
| readonly results: readonly PlatformJobResultResponse[]; | ||
| readonly isLoading: boolean; | ||
| readonly isTerminal: boolean; | ||
| readonly loadError: boolean; | ||
| } | ||
|
|
||
| export const ResultsPanel: FC<ResultsPanelProps> = ({ | ||
| workspace, | ||
| jobName, | ||
| results, | ||
| isLoading, | ||
| isTerminal, | ||
| loadError, | ||
| }) => { | ||
| const [downloading, setDownloading] = useState<string | null>(null); | ||
| const [error, setError] = useState<string | undefined>(undefined); | ||
|
|
||
| const download = async (name: string) => { | ||
| setDownloading(name); | ||
| setError(undefined); | ||
| try { | ||
| const blob = await anonymizerDownloadRunJobResult(workspace, jobName, name); | ||
| triggerDownload(blob, name); | ||
| } catch { | ||
| setError(`Could not download ${name}`); | ||
| } finally { | ||
| setDownloading(null); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <Panel slotHeading="Results" elevation="high" density="compact"> | ||
| <Stack gap="density-md"> | ||
| {error ? ( | ||
| <Banner kind="inline" status="error"> | ||
| {error} | ||
| </Banner> | ||
| ) : null} | ||
| {loadError ? ( | ||
| <Banner kind="inline" status="error"> | ||
| Could not load results for this job. | ||
| </Banner> | ||
| ) : isLoading ? ( | ||
| <Spinner aria-label="Loading results" /> | ||
| ) : results.length ? ( | ||
| results.map((result) => ( | ||
| <Flex key={result.name} align="center" justify="between" gap="density-md"> | ||
| <Text kind="body/regular/md">{result.name}</Text> | ||
| <Button | ||
| kind="tertiary" | ||
| size="small" | ||
| disabled={downloading === result.name} | ||
| onClick={() => download(result.name)} | ||
| > | ||
| <Download /> | ||
| Download | ||
| </Button> | ||
| </Flex> | ||
| )) | ||
| ) : ( | ||
| <Text kind="body/regular/md"> | ||
| {isTerminal ? 'This job produced no results.' : 'Results appear once the job finishes.'} | ||
| </Text> | ||
| )} | ||
| </Stack> | ||
| </Panel> | ||
| ); | ||
| }; |
42 changes: 42 additions & 0 deletions
42
web/packages/studio/src/routes/AnonymizerJobDetailRoute/components/ResultsPreviewPanel.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import type { TableExpandableCellState } from '@nemo/common/src/components/DataView/TableExpandableCell'; | ||
| import { Banner, Panel, Spinner, Stack, Text } from '@nvidia/foundations-react-core'; | ||
| import { ExpandedCellModal } from '@studio/routes/AnonymizerJobDetailRoute/components/ExpandedCellModal'; | ||
| import { ResultsPreviewTable } from '@studio/routes/AnonymizerJobDetailRoute/components/ResultsPreviewTable'; | ||
| import { useResultPreview } from '@studio/routes/AnonymizerJobDetailRoute/useResultPreview'; | ||
| import { useCallback, useState, type FC } from 'react'; | ||
|
|
||
| interface ResultsPreviewPanelProps { | ||
| readonly workspace: string; | ||
| readonly artifactUrl: string | undefined; | ||
| } | ||
|
|
||
| export const ResultsPreviewPanel: FC<ResultsPreviewPanelProps> = ({ workspace, artifactUrl }) => { | ||
| const { rows, columns, isLoading, error } = useResultPreview(workspace, artifactUrl); | ||
| const [expandedCell, setExpandedCell] = useState<TableExpandableCellState | null>(null); | ||
| const closeExpandedCell = useCallback(() => setExpandedCell(null), []); | ||
|
|
||
| return ( | ||
| <Panel slotHeading="Preview" elevation="high" density="compact"> | ||
| {error ? ( | ||
| <Banner kind="inline" status="error"> | ||
| Could not load the result preview. | ||
| </Banner> | ||
| ) : isLoading ? ( | ||
| <Spinner aria-label="Loading preview" /> | ||
| ) : rows.length ? ( | ||
| <Stack gap="density-md"> | ||
| <ResultsPreviewTable rows={rows} columns={columns} onExpand={setExpandedCell} /> | ||
| <Text kind="body/regular/sm"> | ||
| Showing the first {rows.length} records. Download the result for the full dataset. | ||
| </Text> | ||
| </Stack> | ||
| ) : ( | ||
| <Text kind="body/regular/md">No preview available for this job.</Text> | ||
| )} | ||
| <ExpandedCellModal cell={expandedCell} onClose={closeExpandedCell} /> | ||
| </Panel> | ||
| ); | ||
| }; |
71 changes: 71 additions & 0 deletions
71
web/packages/studio/src/routes/AnonymizerJobDetailRoute/components/ResultsPreviewTable.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { StudioDataView } from '@nemo/common/src/components/DataView/StudioDataView'; | ||
| import { | ||
| TableExpandableCell, | ||
| type TableExpandableCellState, | ||
| } from '@nemo/common/src/components/DataView/TableExpandableCell'; | ||
| import { useStudioDataViewState } from '@nemo/common/src/hooks/useStudioDataViewState'; | ||
| import { Text } from '@nvidia/foundations-react-core'; | ||
| import type { DataFileRow } from '@studio/components/FileRowEditor/types'; | ||
| import { RESULT_PREVIEW_ROWS } from '@studio/routes/AnonymizerJobDetailRoute/util'; | ||
| import { memo, useCallback, useMemo, type ComponentProps, type FC } from 'react'; | ||
|
|
||
| interface ResultsPreviewTableProps { | ||
| readonly rows: readonly DataFileRow[]; | ||
| readonly columns: readonly string[]; | ||
| readonly onExpand: (cell: TableExpandableCellState) => void; | ||
| } | ||
|
|
||
| const cellText = (value: unknown): string => | ||
| typeof value === 'object' ? JSON.stringify(value) : String(value); | ||
|
|
||
| /** Memoized so opening the expanded-cell modal does not re-render every cell. */ | ||
| export const ResultsPreviewTable: FC<ResultsPreviewTableProps> = memo( | ||
| ({ rows, columns, onExpand }) => { | ||
| const dataViewState = useStudioDataViewState({ defaultPageSize: RESULT_PREVIEW_ROWS }); | ||
|
|
||
| const { pageIndex, pageSize } = dataViewState.pagination.state; | ||
| const pageRows = useMemo( | ||
| () => rows.slice(pageIndex * pageSize, (pageIndex + 1) * pageSize), | ||
| [rows, pageIndex, pageSize] | ||
| ); | ||
|
|
||
| const makeColumns = useCallback< | ||
| ComponentProps<typeof StudioDataView<DataFileRow>>['makeColumns'] | ||
| >( | ||
| (col) => | ||
| columns.map((column) => | ||
| col.display({ | ||
| id: column, | ||
| header: column, | ||
| cell: ({ row }) => { | ||
| const value = row.original[column]; | ||
| return value == null ? ( | ||
| <Text kind="body/regular/sm" color="secondary"> | ||
| — | ||
| </Text> | ||
| ) : ( | ||
| <TableExpandableCell content={cellText(value)} title={column} onExpand={onExpand} /> | ||
| ); | ||
| }, | ||
| }) | ||
| ), | ||
| [columns, onExpand] | ||
| ); | ||
|
|
||
| return ( | ||
| <div className="flex flex-col min-h-[400px] max-h-[640px]"> | ||
| <StudioDataView<DataFileRow> | ||
| dataViewState={dataViewState} | ||
| makeColumns={makeColumns} | ||
| maxTwoLines={false} | ||
| attributes={{ DataViewRoot: { data: pageRows, totalCount: rows.length } }} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| ResultsPreviewTable.displayName = 'ResultsPreviewTable'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.