Skip to content

Commit

Permalink
object viewer support for deleted refs
Browse files Browse the repository at this point in the history
  • Loading branch information
gtarpenning committed Oct 30, 2024
1 parent 1731d8f commit 3d80f49
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ export const SmallRef: FC<{
const objectVersion = useObjectVersion(objVersionKey);
const opVersion = useOpVersion(opVersionKey);

const isDeleted = objectVersion?.error || opVersion?.error;
const isDeleted =
isObjDeleteError(objectVersion?.error) ||
isObjDeleteError(opVersion?.error);

const versionIndex =
objectVersion.result?.versionIndex ?? opVersion.result?.versionIndex;
Expand Down Expand Up @@ -212,3 +214,12 @@ export const parseRefMaybe = (s: string): ObjectRef | null => {
return null;
}
};

export const isObjDeleteError = (e: any): boolean => {
if (e == null) {
return false;
}
const errorStr = String(e);
const regex = /Obj .* was deleted at .*/;
return regex.test(errorStr);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
GridRowId,
} from '@mui/x-data-grid-pro';
import {Button} from '@wandb/weave/components/Button';
import {parseRef} from '@wandb/weave/react';
import _ from 'lodash';
import React, {
Dispatch,
Expand All @@ -20,7 +21,7 @@ import React, {

import {LoadingDots} from '../../../../../LoadingDots';
import {Browse2OpDefCode} from '../../../Browse2/Browse2OpDefCode';
import {parseRefMaybe} from '../../../Browse2/SmallRef';
import {objectRefDisplayName, parseRefMaybe} from '../../../Browse2/SmallRef';
import {isWeaveRef} from '../../filters/common';
import {StyledDataGrid} from '../../StyledDataGrid';
import {isCustomWeaveTypePayload} from '../../typeViews/customWeaveType.types';
Expand Down Expand Up @@ -151,10 +152,17 @@ export const ObjectViewer = ({

const refValues: RefValues = {};
for (const [r, v] of _.zip(refs, resolvedRefData)) {
if (!r || !v) {
if (!r) {
// Shouldn't be possible
continue;
}
if (!v) {
// Value for ref not found, probably deleted
refValues[r] = {
_weave_is_deleted_ref: objectRefDisplayName(parseRef(r)).label,
};
continue;
}
let val = r;
if (v == null) {
console.error('Error resolving ref', r);
Expand Down Expand Up @@ -394,6 +402,19 @@ export const ObjectViewer = ({
return null;
}

// Hack to show the object name with a strikethrough if deleted
if (params.row.value?._weave_is_deleted_ref) {
return (
<Box
sx={{
textOverflow: 'ellipsis',
textDecoration: 'line-through',
}}>
{params.row.value?._weave_is_deleted_ref}
</Box>
);
}

return (
<ObjectViewerGroupingCell
{...params}
Expand Down
2 changes: 0 additions & 2 deletions weave/trace_server/clickhouse_trace_server_batched.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,6 @@ def _obj_read(
if len(objs) == 0:
raise NotFoundError(f"Obj {object_id}:{digest} not found")

print(objs)

if objs[0].deleted_at is not None:
raise ObjectDeletedError(
f"Obj {object_id}:v{objs[0].version_index} was deleted at {objs[0].deleted_at}"
Expand Down

0 comments on commit 3d80f49

Please sign in to comment.