-
Notifications
You must be signed in to change notification settings - Fork 219
feat(client): add methods to langfuse client to fetch and delete dataset runs #1453
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, no comments
| raise e | ||
|
|
||
| def get_dataset_run( | ||
| self, dataset_name: str, *, run_name: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have all arguments here as keyword arguments
|
|
||
| def get_dataset_runs( | ||
| self, | ||
| dataset_name: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have all arguments here as keyword arguments
| raise e | ||
|
|
||
| def delete_dataset_run( | ||
| self, dataset_name: str, *, run_name: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have all arguments here as keyword arguments
| try: | ||
| return self.api.datasets.get_run( | ||
| dataset_name=self._url_encode(dataset_name), | ||
| run_name=self._url_encode(run_name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If run_name is being passed as a query param, we would have to set url_param=True in _url_encode to avoid double encoding by newer httpx versions.
In any case, we should add a few tests here to cover all works as expected with the encoding 👍🏾
Important
Adds methods to Langfuse client for fetching and deleting dataset runs with error handling.
get_dataset_run(): Fetches a dataset run bydataset_nameandrun_name, returningDatasetRunWithItems.get_dataset_runs(): Fetches all runs for a dataset, with pagination support, returningPaginatedDatasetRuns.delete_dataset_run(): Deletes a dataset run bydataset_nameandrun_name, returningDeleteDatasetRunResponse.handle_fern_exception()for error handling and re-raise exceptions.This description was created by
for 0d9bd8f. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Overview
Greptile Summary
Added three new methods to the Langfuse client for managing dataset runs:
get_dataset_run,get_dataset_runs, anddelete_dataset_run.get_dataset_run: fetches a single dataset run by dataset name and run nameget_dataset_runs: retrieves paginated list of runs for a datasetdelete_dataset_run: permanently deletes a dataset run and all its itemsDatasetRunWithItems,DeleteDatasetRunResponse, andPaginatedDatasetRunstypesIssues found:
is_url_param=Trueflag in_url_encode()calls for path parameters across all three methods. These parameters are embedded in URL paths and passed to httpx, which handles encoding automatically in v0.28+. This inconsistency with the existingget_datasetmethod (line 2445) could cause double-encoding issues.Confidence Score: 3/5
is_url_param=Trueflags could cause encoding issues with special characters in dataset/run names. The fix is simple but critical for correctness._url_encode()calls inlangfuse/_client/client.pyto includeis_url_param=Truefor all path parametersImportant Files Changed
File Analysis
get_dataset_run,get_dataset_runs,delete_dataset_run); missingis_url_param=Trueflag in URL encoding calls for path parametersSequence Diagram
sequenceDiagram participant User participant Langfuse participant API as Langfuse API Note over User,API: Get Dataset Run User->>Langfuse: get_dataset_run(dataset_name, run_name) Langfuse->>Langfuse: _url_encode(dataset_name) Langfuse->>Langfuse: _url_encode(run_name) Langfuse->>API: datasets.get_run(dataset_name, run_name) API-->>Langfuse: DatasetRunWithItems Langfuse-->>User: DatasetRunWithItems Note over User,API: Get Dataset Runs (Paginated) User->>Langfuse: get_dataset_runs(dataset_name, page, limit) Langfuse->>Langfuse: _url_encode(dataset_name) Langfuse->>API: datasets.get_runs(dataset_name, page, limit) API-->>Langfuse: PaginatedDatasetRuns Langfuse-->>User: PaginatedDatasetRuns Note over User,API: Delete Dataset Run User->>Langfuse: delete_dataset_run(dataset_name, run_name) Langfuse->>Langfuse: _url_encode(dataset_name) Langfuse->>Langfuse: _url_encode(run_name) Langfuse->>API: datasets.delete_run(dataset_name, run_name) API-->>Langfuse: DeleteDatasetRunResponse Langfuse-->>User: DeleteDatasetRunResponse