Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@awkoy
Copy link
Contributor

@awkoy awkoy commented Feb 4, 2026

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:

  • 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)

The DatasetVersion class 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 via getItems() and serialization via toJson().

Key implementation details:

  • DatasetVersion follows the same HTTP access pattern as Dataset and Experiment for read operations (direct API calls)
  • getVersionView() uses pagination to find versions by name
  • evaluate() now accepts DatasetVersion and links experiments to the specific version via datasetVersionId
  • DatasetVersionPublic type is exported from the SDK for public use

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-4149

Documentation

Testing

  • 32 unit tests covering DatasetVersion properties, getItems, toJson, and Dataset version methods
  • 5 integration tests covering evaluate with DatasetVersion
  • All tests passing

@awkoy awkoy requested a review from a team as a code owner February 4, 2026 16:36
@github-actions github-actions bot added tests Including test files, or tests related like configuration. typescript *.ts *.tsx TypeScript SDK labels Feb 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

📋 PR Linter Failed

Incomplete Details Section. The ## Details section cannot be empty.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

📋 PR Linter Failed

Incomplete Details Section. The ## Details section cannot be empty.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

📋 PR Linter Failed

Missing Section. The description is missing the ## Documentation section.

2 similar comments
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

📋 PR Linter Failed

Missing Section. The description is missing the ## Documentation section.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

📋 PR Linter Failed

Missing Section. The description is missing the ## Documentation section.

awkoy and others added 2 commits February 5, 2026 12:34
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]>
@awkoy awkoy force-pushed the awkoy/OPIK-4149-dataset-versions-ts-sdk branch from 4a177a7 to b4eff96 Compare February 5, 2026 11:34
- 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]>
@awkoy awkoy requested a review from a team as a code owner February 5, 2026 11:52
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

🌿 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]>
awkoy and others added 2 commits February 5, 2026 14:36
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]>
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Feb 5, 2026
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]>
awkoy and others added 2 commits February 5, 2026 17:58
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]>
Copy link
Contributor

@petrotiurin petrotiurin left a 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!

Copy link
Contributor

@petrotiurin petrotiurin left a 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!

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]>
@awkoy awkoy merged commit 0cdca8c into main Feb 9, 2026
17 checks passed
@awkoy awkoy deleted the awkoy/OPIK-4149-dataset-versions-ts-sdk branch February 9, 2026 15:04
Comment on lines +37 to +42
const streamResponse = await opik.api.datasets.streamDatasetItems({
datasetName,
lastRetrievedId: currentLastId,
steamLimit: streamLimit,
datasetVersion,
});
Copy link
Contributor

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?

Suggested change
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

miguelgrc pushed a commit that referenced this pull request Feb 12, 2026
* [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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests Including test files, or tests related like configuration. TypeScript SDK typescript *.ts *.tsx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants