-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[OPIK-4149] [SDK] Add DatasetVersion support to TypeScript SDK #5068
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
Conversation
📋 PR Linter Failed❌ Incomplete Details Section. The |
📋 PR Linter Failed❌ Incomplete Details Section. The |
📋 PR Linter Failed❌ Missing Section. The description is missing the |
2 similar comments
📋 PR Linter Failed❌ Missing Section. The description is missing the |
📋 PR Linter Failed❌ Missing Section. The description is missing the |
Add dataset versioning capabilities allowing users to work with specific snapshots of datasets. This enables reproducible evaluations by pinning to a specific version. Changes: - Add DatasetVersion class for read-only version views - Add Dataset.getVersionView(), getCurrentVersionName(), getVersionInfo() - Support DatasetVersion in evaluate() with version tracking - Add DatasetVersionNotFoundError for version lookup failures - Export Dataset, DatasetVersion, DatasetVersionNotFoundError from SDK - Add comprehensive unit tests (32 tests) and integration tests (3 tests)
- Remove redundant if wrapper in toJson keysMapping loop - Export DatasetVersionPublic type from SDK public API - Update test imports to use public SDK exports Co-Authored-By: Claude Opus 4.5 <[email protected]>
4a177a7 to
b4eff96
Compare
- Add "Working with Dataset Versions" section to datasets.mdx with examples for getVersionView, getCurrentVersionName, and getVersionInfo methods - Document DatasetVersion class properties and methods in API reference - Update evaluate.mdx to show Dataset | DatasetVersion parameter type - Add TypeScript version selection example to manage_datasets.mdx Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
🌿 Preview your docs: https://opik-preview-dde1d2c4-eb50-434c-9309-18ee795f28ed.docs.buildwithfern.com/docs/opik No broken links found 📌 Results for commit 948046c |
The backend's resolveVersionId method looks up versions by hash or tag, not by versionName. Changed to pass versionHash instead of versionName to match Python SDK behavior and fix E2E test failures. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add scoringKeyMapping to map 'expected' to 'expected_output' field in the dataset items, matching the pattern used in other evaluation tests. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…on parity Adds the lastRetrievedId parameter to DatasetVersion.getItems() to match the Dataset.getItems() API. This allows manual pagination for datasets with more than 2000 items. Co-Authored-By: Claude Opus 4.5 <[email protected]>
This adds automatic pagination support for retrieving large datasets: - Dataset.getItemsAsDataclasses() now fetches all items automatically - DatasetVersion.getItemsAsDataclasses() uses the same pagination pattern - Both use cursor-based pagination with lastRetrievedId - Maximum batch size of 2000 items per request (API limit) - Pagination continues until all requested items are retrieved This provides parity with the Python SDK's auto-pagination behavior. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Return empty array immediately when nbSamples === 0 to avoid API call with invalid steamLimit = 0 (API requires steamLimit >= 1). Co-Authored-By: Claude Opus 4.5 <[email protected]>
Simplify streamLimit calculation using nullish coalescing operator. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add await to createExperiment API call to ensure experiment exists before evaluation completes. This fixes the 404 error when nbSamples=0. Co-Authored-By: Claude Opus 4.5 <[email protected]>
petrotiurin
left a comment
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.
Great change, thanks for putting it together so quickly!
apps/opik-documentation/documentation/fern/docs/evaluation/manage_datasets.mdx
Show resolved
Hide resolved
…IK-4149-dataset-versions-ts-sdk
petrotiurin
left a comment
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.
Apart from this, looks good!
apps/opik-documentation/documentation/fern/docs/evaluation/manage_datasets.mdx
Show resolved
Hide resolved
Remove the shorter duplicate "Working with dataset versions programmatically" section and add a TypeScript tab to the remaining detailed section. Co-Authored-By: Claude Opus 4.6 <[email protected]>
| const streamResponse = await opik.api.datasets.streamDatasetItems({ | ||
| datasetName, | ||
| lastRetrievedId: currentLastId, | ||
| steamLimit: streamLimit, | ||
| datasetVersion, | ||
| }); |
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.
streamDatasetItems is called with steamLimit instead of streamLimit, so the server never sees the requested batch size and ignores nbSamples/remaining adjustments; can we send the correctly spelled streamLimit key so limits actually work?
| const streamResponse = await opik.api.datasets.streamDatasetItems({ | |
| datasetName, | |
| lastRetrievedId: currentLastId, | |
| steamLimit: streamLimit, | |
| datasetVersion, | |
| }); | |
| const streamResponse = await opik.api.datasets.streamDatasetItems({ | |
| datasetName, | |
| lastRetrievedId: currentLastId, | |
| streamLimit: streamLimit, | |
| datasetVersion, | |
| }); |
Finding type: Design extensible API interfaces
* [OPIK-4149] [SDK] Add DatasetVersion support to TypeScript SDK Add dataset versioning capabilities allowing users to work with specific snapshots of datasets. This enables reproducible evaluations by pinning to a specific version. Changes: - Add DatasetVersion class for read-only version views - Add Dataset.getVersionView(), getCurrentVersionName(), getVersionInfo() - Support DatasetVersion in evaluate() with version tracking - Add DatasetVersionNotFoundError for version lookup failures - Export Dataset, DatasetVersion, DatasetVersionNotFoundError from SDK - Add comprehensive unit tests (32 tests) and integration tests (3 tests) * Address PR review comments - Remove redundant if wrapper in toJson keysMapping loop - Export DatasetVersionPublic type from SDK public API - Update test imports to use public SDK exports Co-Authored-By: Claude Opus 4.5 <[email protected]> * Add DatasetVersion documentation to TypeScript SDK - Add "Working with Dataset Versions" section to datasets.mdx with examples for getVersionView, getCurrentVersionName, and getVersionInfo methods - Document DatasetVersion class properties and methods in API reference - Update evaluate.mdx to show Dataset | DatasetVersion parameter type - Add TypeScript version selection example to manage_datasets.mdx Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix DatasetVersion to use versionHash for item streaming The backend's resolveVersionId method looks up versions by hash or tag, not by versionName. Changed to pass versionHash instead of versionName to match Python SDK behavior and fix E2E test failures. Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix E2E test for DatasetVersion evaluation Add scoringKeyMapping to map 'expected' to 'expected_output' field in the dataset items, matching the pattern used in other evaluation tests. Co-Authored-By: Claude Opus 4.5 <[email protected]> * Add lastRetrievedId parameter to DatasetVersion.getItems for pagination parity Adds the lastRetrievedId parameter to DatasetVersion.getItems() to match the Dataset.getItems() API. This allows manual pagination for datasets with more than 2000 items. Co-Authored-By: Claude Opus 4.5 <[email protected]> * Add auto-pagination to Dataset and DatasetVersion getItems methods This adds automatic pagination support for retrieving large datasets: - Dataset.getItemsAsDataclasses() now fetches all items automatically - DatasetVersion.getItemsAsDataclasses() uses the same pagination pattern - Both use cursor-based pagination with lastRetrievedId - Maximum batch size of 2000 items per request (API limit) - Pagination continues until all requested items are retrieved This provides parity with the Python SDK's auto-pagination behavior. Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix nbSamples=0 edge case in Dataset and DatasetVersion getItems Return empty array immediately when nbSamples === 0 to avoid API call with invalid steamLimit = 0 (API requires steamLimit >= 1). Co-Authored-By: Claude Opus 4.5 <[email protected]> * Apply conciseness improvements from code review Simplify streamLimit calculation using nullish coalescing operator. Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix race condition in experiment creation Add await to createExperiment API call to ensure experiment exists before evaluation completes. This fixes the 404 error when nbSamples=0. Co-Authored-By: Claude Opus 4.5 <[email protected]> * OPIK-4149 refactor * OPIK-4149 Merge duplicate dataset versions docs sections Remove the shorter duplicate "Working with dataset versions programmatically" section and add a TypeScript tab to the remaining detailed section. Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
Details
Add dataset versioning capabilities allowing users to work with specific snapshots of datasets. This enables reproducible evaluations by pinning to a specific version.
Changes:
The
DatasetVersionclass provides a read-only view of dataset items at a specific version. It exposes all version metadata (versionId, versionHash, tags, itemsTotal, etc.) and supports fetching items viagetItems()and serialization viatoJson().Key implementation details:
DatasetVersionfollows the same HTTP access pattern asDatasetandExperimentfor read operations (direct API calls)getVersionView()uses pagination to find versions by nameevaluate()now acceptsDatasetVersionand links experiments to the specific version viadatasetVersionIdDatasetVersionPublictype is exported from the SDK for public useChange checklist
Issues
Documentation
Testing