Skip to content
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

feat: object and op deletion backend + basic sdk + basic fe #2319

Draft
wants to merge 78 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
fbb11a8
wip
gtarpenning Sep 5, 2024
83ac645
wip
gtarpenning Sep 5, 2024
021e07f
Merge branch 'master' into griffin/objs-delete
gtarpenning Sep 5, 2024
6c14fff
wip, working??
gtarpenning Sep 5, 2024
52abf53
obj.delete()
gtarpenning Sep 5, 2024
e78dc87
Merge branch 'master' into griffin/objs-delete
gtarpenning Sep 6, 2024
29e2376
add test
gtarpenning Sep 6, 2024
52839eb
wip, now with configurable include_deleted flag
gtarpenning Sep 6, 2024
ff13b45
wip
gtarpenning Sep 6, 2024
99fc486
print
gtarpenning Sep 6, 2024
50c5728
wip
gtarpenning Sep 9, 2024
6cb4446
insert with full data payload
gtarpenning Sep 9, 2024
c8b20aa
retain version #
gtarpenning Sep 9, 2024
4d3194e
query magic
gtarpenning Sep 9, 2024
d553d21
merge
gtarpenning Sep 9, 2024
1fb0080
working with ops
gtarpenning Sep 9, 2024
f5a9c90
wip simple object deletion fe
gtarpenning Sep 10, 2024
07da651
refetch on delete
gtarpenning Sep 10, 2024
7569b84
simpler
gtarpenning Sep 10, 2024
49c559b
add order by
gtarpenning Sep 10, 2024
4182a24
merge
gtarpenning Sep 30, 2024
54ec61e
lint
gtarpenning Sep 30, 2024
18105cc
lint
gtarpenning Sep 30, 2024
92106bc
NotFoundError
gtarpenning Sep 30, 2024
c96b5cd
add back sqlite handling
gtarpenning Sep 30, 2024
04cd07e
undo
gtarpenning Sep 30, 2024
b76724a
cleanup
gtarpenning Oct 1, 2024
c3fe08b
merge
gtarpenning Oct 1, 2024
6a1a037
Merge branch 'master' into griffin/objs-delete
gtarpenning Oct 1, 2024
d381dfd
better error handling
gtarpenning Oct 1, 2024
fd09f90
sort by asc default
gtarpenning Oct 1, 2024
b92153c
merge
gtarpenning Oct 2, 2024
07917cf
add support for purging object values
gtarpenning Oct 2, 2024
41191fd
merge
gtarpenning Oct 6, 2024
4715f41
wip
gtarpenning Oct 7, 2024
17c8cd7
better
gtarpenning Oct 7, 2024
939621f
Merge branch 'master' into griffin/objs-delete
gtarpenning Oct 7, 2024
8bfd8c7
lint
gtarpenning Oct 7, 2024
f0cb066
merge
gtarpenning Oct 11, 2024
d10a9b7
now working with identical objects
gtarpenning Oct 11, 2024
3772edd
limit-1
gtarpenning Oct 14, 2024
72112cf
merge
gtarpenning Oct 30, 2024
d12d667
Merge branch 'master' into griffin/objs-delete
gtarpenning Oct 30, 2024
667ccf5
Merge branch 'master' into griffin/objs-delete
gtarpenning Oct 30, 2024
b6c2a16
use groupby
gtarpenning Oct 30, 2024
1731d8f
refactor delete and add op delete
gtarpenning Oct 30, 2024
3d80f49
object viewer support for deleted refs
gtarpenning Oct 30, 2024
fe1c7d4
better hack
gtarpenning Oct 30, 2024
32b466e
wip recursive
gtarpenning Oct 30, 2024
38c4074
simpler
gtarpenning Nov 7, 2024
226e1e3
merge
gtarpenning Nov 15, 2024
d42d1ec
merge
gtarpenning Nov 26, 2024
c1629fa
fix
gtarpenning Nov 26, 2024
8ae0003
fixes, working
gtarpenning Nov 26, 2024
d3c63f9
costmetic code refactor
gtarpenning Dec 3, 2024
4f1fc99
whitespace
gtarpenning Dec 3, 2024
e433562
Merge branch 'master' into griffin/objs-delete
gtarpenning Dec 3, 2024
3bcc8af
cleanup
gtarpenning Dec 3, 2024
6d4aa7e
fix test
gtarpenning Dec 3, 2024
7d0d151
merge
gtarpenning Dec 4, 2024
964a4a9
fix-sqlite-dupes
gtarpenning Dec 4, 2024
827b1ee
with lock
gtarpenning Dec 4, 2024
05bf534
lint
gtarpenning Dec 4, 2024
f56870a
cleaner
gtarpenning Dec 5, 2024
6a22665
Merge branch 'master' into griffin/objs-delete
gtarpenning Dec 5, 2024
5b37bcf
w
gtarpenning Dec 5, 2024
72a25c9
WIP
gtarpenning Dec 9, 2024
b795953
obj_delete with optional digests list
gtarpenning Dec 9, 2024
feef47e
lint
gtarpenning Dec 9, 2024
a8c7e95
merge
gtarpenning Dec 9, 2024
c343ec0
fix
gtarpenning Dec 9, 2024
add641f
lint
gtarpenning Dec 9, 2024
014d108
update
gtarpenning Dec 9, 2024
f0015a3
fixtest
gtarpenning Dec 9, 2024
e7ced6c
fix button spacing and delete modal autosizing
gtarpenning Dec 11, 2024
3e634d5
cache handling fe
gtarpenning Dec 11, 2024
f3e513b
dont do table delete on object delete
gtarpenning Dec 11, 2024
c30ef52
add back importand val_dump step
gtarpenning Dec 12, 2024
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import {
Dialog,
DialogActions as MaterialDialogActions,
DialogContent as MaterialDialogContent,
DialogTitle as MaterialDialogTitle,
} from '@material-ui/core';
import Box from '@mui/material/Box';
import Stack from '@mui/material/Stack';
import {Button} from '@wandb/weave/components/Button';
import {useObjectViewEvent} from '@wandb/weave/integrations/analytics/useViewEvents';
import React, {useMemo} from 'react';
import React, {useMemo, useState} from 'react';
import styled from 'styled-components';

import {maybePluralizeWord} from '../../../../../core/util/string';
import {LoadingDots} from '../../../../LoadingDots';
import {useClosePeek} from '../context';
import {NotFoundPanel} from '../NotFoundPanel';
import {CustomWeaveTypeProjectContext} from '../typeViews/CustomWeaveTypeDispatcher';
import {WeaveCHTableSourceRefContext} from './CallPage/DataTableView';
Expand Down Expand Up @@ -124,60 +134,83 @@ const ObjectVersionPageInner: React.FC<{
return viewerData;
}, [viewerData]);

const [deleteModalOpen, setDeleteModalOpen] = useState(false);

return (
<SimplePageLayoutWithHeader
title={objectVersionText(objectName, objectVersionIndex)}
headerContent={
<SimpleKeyValueTable
data={{
[refExtra ? 'Parent Object' : 'Name']: (
<>
{objectName}{' '}
{objectVersions.loading ? (
<LoadingDots />
) : (
<Stack
direction="row"
justifyContent="space-between"
alignItems="flex-start"
width="100%">
<Box flexGrow={1}>
<SimpleKeyValueTable
data={{
[refExtra ? 'Parent Object' : 'Name']: (
<>
[
<ObjectVersionsLink
entity={entityName}
project={projectName}
filter={{
objectName,
}}
versionCount={objectVersionCount}
neverPeek
variant="secondary"
/>
]
{objectName}{' '}
{objectVersions.loading ? (
<LoadingDots />
) : (
<>
[
<ObjectVersionsLink
entity={entityName}
project={projectName}
filter={{
objectName,
}}
versionCount={objectVersionCount}
neverPeek
variant="secondary"
/>
]
</>
)}
</>
)}
</>
),
Version: <>{objectVersionIndex}</>,
...(baseObjectClass
? {
Category: (
<TypeVersionCategoryChip
baseObjectClass={baseObjectClass}
/>
),
}
: {}),
...(refExtra
? {
Subpath: refExtra,
}
: {}),
// 'Type Version': (
// <TypeVersionLink
// entityName={entityName}
// projectName={projectName}
// typeName={typeName}
// version={typeVersionHash}
// />
// ),
}}
/>
),
Version: <>{objectVersionIndex}</>,
...(baseObjectClass
? {
Category: (
<TypeVersionCategoryChip
baseObjectClass={baseObjectClass}
/>
),
}
: {}),
...(refExtra
? {
Subpath: refExtra,
}
: {}),
// 'Type Version': (
// <TypeVersionLink
// entityName={entityName}
// projectName={projectName}
// typeName={typeName}
// version={typeVersionHash}
// />
// ),
}}
/>
</Box>

<Box mr={1}>
<Button
icon="delete"
variant="ghost"
onClick={() => setDeleteModalOpen(true)}
/>
</Box>
<DeleteModal
object={objectVersion}
open={deleteModalOpen}
onClose={() => setDeleteModalOpen(false)}
/>
</Stack>
}
// menuItems={[
// {
Expand Down Expand Up @@ -500,3 +533,96 @@ const OpVersionCallsLink: React.FC<{
</>
);
};

const DialogContent = styled(MaterialDialogContent)`
padding: 0 32px !important;
`;
DialogContent.displayName = 'S.DialogContent';

const DialogTitle = styled(MaterialDialogTitle)`
padding: 32px 32px 16px 32px !important;

h2 {
font-weight: 600;
font-size: 24px;
line-height: 30px;
}
`;
DialogTitle.displayName = 'S.DialogTitle';

const DialogActions = styled(MaterialDialogActions)<{$align: string}>`
justify-content: ${({$align}) =>
$align === 'left' ? 'flex-start' : 'flex-end'} !important;
padding: 32px 32px 32px 32px !important;
`;
DialogActions.displayName = 'S.DialogActions';

const DeleteModal: React.FC<{
object: ObjectVersionSchema;
open: boolean;
onClose: () => void;
}> = ({object, open, onClose}) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: dry this with the call delete modal

const {useObjectDeleteFunc} = useWFHooks();
const objectDelete = useObjectDeleteFunc();
const closePeek = useClosePeek();

const [deleteLoading, setDeleteLoading] = useState(false);
const [error, setError] = useState<string | null>(null);

const deleteTargetStr = object.baseObjectClass ?? 'object';

const onDelete = () => {
setDeleteLoading(true);
objectDelete(object)
.then(() => {
onClose();
closePeek();
})
.catch(err => {
setError(err.message);
})
.finally(() => {
setDeleteLoading(false);
});
};

return (
<Dialog
open={open}
onClose={() => {
onClose();
setError(null);
}}
maxWidth="xs"
fullWidth>
<DialogTitle>Delete {deleteTargetStr}</DialogTitle>
<DialogContent style={{overflow: 'hidden'}}>
{error != null ? (
<p style={{color: 'red'}}>{error}</p>
) : (
<p>Are you sure you want to delete?</p>
)}
<span style={{fontSize: '16px', fontWeight: '600'}}>
{object.objectId}:v{object.versionIndex}
</span>
</DialogContent>
<DialogActions $align="left">
<Button
variant="destructive"
disabled={error != null || deleteLoading}
onClick={onDelete}>
{`Delete ${deleteTargetStr}`}
</Button>
<Button
variant="ghost"
disabled={deleteLoading}
onClick={() => {
onClose();
setError(null);
}}>
Cancel
</Button>
</DialogActions>
</Dialog>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
FeedbackPurgeRes,
TraceCallsDeleteReq,
TraceCallUpdateReq,
TraceObjDeleteReq,
TraceRefsReadBatchReq,
TraceRefsReadBatchRes,
} from './traceServerClientTypes';
Expand All @@ -24,14 +25,17 @@ export class TraceServerClient extends DirectTraceServerClient {
private onDeleteListeners: Array<() => void>;
private onRenameListeners: Array<() => void>;
private onFeedbackListeners: Record<string, Array<() => void>>;
private onObjectListeners: Array<() => void>;

constructor(baseUrl: string) {
super(baseUrl);
this.readBatchCollectors = [];
this.scheduleReadBatch();

this.onDeleteListeners = [];
this.onRenameListeners = [];
this.onFeedbackListeners = {};
this.onObjectListeners = [];
}

/**
Expand Down Expand Up @@ -77,6 +81,14 @@ export class TraceServerClient extends DirectTraceServerClient {
}
};
}
public registerOnObjectListener(callback: () => void): () => void {
this.onObjectListeners.push(callback);
return () => {
this.onObjectListeners = this.onObjectListeners.filter(
listener => listener !== callback
);
};
}

public callsDelete(req: TraceCallsDeleteReq): Promise<void> {
const res = super.callsDelete(req).then(() => {
Expand Down Expand Up @@ -113,6 +125,13 @@ export class TraceServerClient extends DirectTraceServerClient {
return res;
}

public objectDelete(req: TraceObjDeleteReq): Promise<void> {
const res = super.objectDelete(req).then(() => {
this.onObjectListeners.forEach(listener => listener());
});
return res;
}

public readBatch(req: TraceRefsReadBatchReq): Promise<TraceRefsReadBatchRes> {
return this.requestReadBatch(req);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ export type TraceObjReadRes = {
obj: TraceObjSchema;
};

export type TraceObjDeleteReq = {
project_id: string;
object_id: string;
digest: string;
};

export type TraceRefsReadBatchReq = {
refs: string[];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
TraceCallUpdateReq,
TraceFileContentReadReq,
TraceFileContentReadRes,
TraceObjDeleteReq,
TraceObjQueryReq,
TraceObjQueryRes,
TraceObjReadReq,
Expand Down Expand Up @@ -222,6 +223,10 @@ export class DirectTraceServerClient {
return this.makeRequest<TraceObjReadReq, TraceObjReadRes>('/obj/read', req);
}

public objectDelete(req: TraceObjDeleteReq): Promise<void> {
return this.makeRequest<TraceObjDeleteReq, void>('/obj/delete', req);
}

public readBatch(req: TraceRefsReadBatchReq): Promise<TraceRefsReadBatchRes> {
return this.makeRequest<TraceRefsReadBatchReq, TraceRefsReadBatchRes>(
'/refs/read_batch',
Expand Down
Loading
Loading