[DE-XXXX] Expose dataset_item_id on exported items, annotations and predictions - #473
Draft
luke-e-schaefer wants to merge 1 commit into
Draft
[DE-XXXX] Expose dataset_item_id on exported items, annotations and predictions#473luke-e-schaefer wants to merge 1 commit into
luke-e-schaefer wants to merge 1 commit into
Conversation
…ctions Batch exports only ever returned reference_id, so keying an exported prediction back to a Nucleus dataset item meant a second lookup. The single-item endpoints (/loc, /refloc, /iloc) already return dataset_item_id, and the public batch-export docs already document it — the batch export was the odd one out. Adds the field everywhere reference_id already appears: - DatasetItem gains dataset_item_id, wired through from_json (the single deserialization entry point, so every SDK path that returns an item picks it up). - Every Annotation/Prediction subclass gains it, stamped down from the item by convert_export_payload exactly as reference_id already is. - Scene/video exports carry it on each track frame. It is server-assigned and read-only, mirroring DatasetItem.phash: populated by from_json, None on locally-constructed objects, excluded from __eq__ so a local object still compares equal to its round-tripped self, and absent from to_payload so uploads are unchanged. A backend that does not return it leaves the field None. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch exports only ever returned
reference_idon the exported item, so keying an exported prediction back to a Nucleus dataset item meant a second lookup.This is an inconsistency fix, not a new field: the single-item endpoints (
/dataset/:id/loc,/refloc,/iloc) already returndataset_item_id, and the public API docs (ApiDocsPage/slices/batch-export.md) already document it in the batch-export response. The batch export was the odd one out.Pairs with scaleapi PR:
luke/nucleus-export-dataset-item-id.What changed
dataset_item_idnow appears everywherereference_idalready does:DatasetItemgains the field, wired throughfrom_json— the single deserialization entry point, so every SDK path that returns an item picks it up, not just exports.Annotation/Predictionsubclass gains it (box,line,polygon,keypoints,cuboid,category,multicategory,segmentation).convert_export_payloadstamps it down from the item exactly as it already does forreference_id.Read-only semantics
The field is server-assigned, and mirrors how
DatasetItem.phashwas done:from_jsonNone__eq__compare=False)to_payloadThe
__eq__exclusion matters: without it, every existing test that compares a locally-built annotation against its round-tripped twin would start failing.Exports from a backend that doesn't return the field leave it
Nonerather than throwing, so this SDK version is safe against an un-upgraded backend.Verification
The test suite requires live API keys (
conftest.pyhard-asserts onNUCLEUS_PYTEST_API_KEY), so it could not be run locally. Verified offline instead by drivingconvert_export_payloaddirectly:to_payloadoutput is unchangeddataset_item_idyieldsNoneeverywhere and does not raiseFormatted with the repo-pinned black 23.12.1 (a newer local black introduced unrelated reformatting, which was reverted).
🤖 Generated with Claude Code