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

Add ability to delete traces #314

Merged
merged 3 commits into from
Jan 14, 2025
Merged

Conversation

nidhi-wa
Copy link
Contributor

@nidhi-wa nidhi-wa commented Jan 11, 2025

This PR add a functionality of deleting an individual trace.

  • Added a delete button next to each trace in the trace view.
  • Implemented function to make a DELETE request to the API.
  • Delete a trace that exists in the database.

#282


Important

Add functionality to delete traces with a DELETE API endpoint and UI updates for trace deletion.

  • Backend:
    • Add DELETE method in route.ts to handle trace deletion from the database.
    • Returns 404 if trace not found, 200 if successful, and 500 for server errors.
  • Frontend:
    • Add delete button in TraceView component in trace-view.tsx.
    • Implement handleDeleteTrace function in traces.tsx to call DELETE API and update UI.
    • Reloads page on successful deletion, shows toast on error.

This description was created by Ellipsis for b59910e. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to b59910e in 1 minute and 21 seconds

More details
  • Looked at 126 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_Wqk9qcu35d8Dhm41


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -20,3 +23,28 @@ export async function GET(
}
});
}

export async function DELETE(
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding authorization checks to ensure that the user has permission to delete the trace. This will prevent unauthorized deletions.

Copy link
Member

Choose a reason for hiding this comment

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

This is handled in the middleware

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

Comment on lines 158 to 164
<Button
onClick={() => {
onDelete(traceId, projectId);
}}
>
Delete Trace
</Button>
Copy link
Member

Choose a reason for hiding this comment

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

We probably don't need the separate button in the trace view. I was rather thinking to implement a small overlay in the datatable view, similar to what we have in evaluations, evaluation, datasets, and dataset.

Copy link
Member

Choose a reason for hiding this comment

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

Speaking of which, it would be great if you could factor out https://github.com/lmnr-ai/lmnr/blob/main/frontend/components/dataset/dataset.tsx#L220-L246 into a separate component, components/ui/DeleteSelectedRows.tsx e.g., and re-use it across the aforementioned components and both the traces and spans tables

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@dinmukhamedm dinmukhamedm left a comment

Choose a reason for hiding this comment

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

We've upgraded to Next.js 15, which breaks some of the routes (now params must be awaited). Please sync the fork and merge the latest dev to your branch. Also, left a small nit comment. Otherwise, LGTM

<DeleteSelectedRows
selectedRowIds={selectedRowIds}
onDelete={handleDeleteEvaluations}
entityName="Evaluations"
Copy link
Member

Choose a reason for hiding this comment

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

nit. Names must start with lowercase here and elsewhere

Copy link
Member

@dinmukhamedm dinmukhamedm left a comment

Choose a reason for hiding this comment

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

Great work! Looks good, I'll test this manually tomorrow and, if all works, will merge that to dev

@dinmukhamedm dinmukhamedm merged commit c8511f3 into lmnr-ai:dev Jan 14, 2025
2 checks passed
@nidhi-wa
Copy link
Contributor Author

Thank you ! I truly appreciate your time and effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants