Dataset-less model runs: create_model_run + add_predictions - #476
Open
luke-e-schaefer wants to merge 2 commits into
Open
Dataset-less model runs: create_model_run + add_predictions#476luke-e-schaefer wants to merge 2 commits into
luke-e-schaefer wants to merge 2 commits into
Conversation
Add a create-run-then-add-predictions flow that does not require threading
a dataset. A run can be created with no founding dataset; predictions then
carry their own target (dataset_item_id, or dataset_id + reference_id) and
the server groups by dataset and widens the run's dataset set.
- Model.create_run_without_dataset(name, metadata=None, reference_id=None)
-> POST model/{id}/modelRun/create, returns a ModelRun with no datasets.
- ModelRun.add_predictions(...) -> POST modelRun/{id}/uploadPredictions.
- Predictions emit item_id (from dataset_item_id) and/or dataset_id when set.
- PredictionUploader: bare model_run_id routes to the dataset-less endpoint.
Requires the matching scaleapi backend routes; async upload is not yet
supported on this path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
luke-e-schaefer
marked this pull request as ready for review
August 20, 2026 00:04
Making dataset_id Optional[str] for dataset-less runs broke mypy on the deprecated predict() async path, which passes self.dataset_id straight to serialize_and_write_to_presigned_url (expects str). Async predict is inherently per-dataset, so raise a clear ValueError when dataset_id is None (dataset-less runs must use add_predictions) — this both fixes the type error and prevents a confusing runtime failure. Fixes the build_test MyPy failure. Co-Authored-By: Claude Opus 4.8 <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.
Summary
Adds a create-run-then-add-predictions API that does not require threading a dataset. You create a run with no founding dataset, then upload predictions that each name their own target — by
dataset_item_id(preferred) ordataset_id+reference_id. The server groups by dataset and widens the run's dataset set.This is the SDK half. Backend counterpart (required): scaleapi
lukeschaefer/dataset-less-model-run-predictions. Live calls 404 until that deploys; the tests here are mock-based and pass regardless.API
Changes
Model.create_run_without_dataset(name, metadata=None, reference_id=None)→POST model/{id}/modelRun/create, returns aModelRunwith no datasets (unreadable until first upload, by design).ModelRun.add_predictions(...)→POST modelRun/{id}/uploadPredictions.item_id(sourced from the existing read-onlydataset_item_idfield) and/ordataset_idinto_payload()when set.PredictionUploader: a baremodel_run_id(nodataset_id, no explicitroute) now routes tomodelRun/{id}/uploadPredictions. All other routing branches are unchanged; the previously-raising "model_run_id without dataset_id" case is now valid (one existing test intest_multi_dataset_model_runs.pyupdated accordingly).Not covered / follow-ups
NotImplementedError— the presigned-URL path is dataset-scoped and has no founding dataset here. Matches the backend, which 400s on?async=1. Needs a model-run-scoped signed-URL route to support async.Tests
tests/test_dataset_less_model_runs.py(new) + updatedtest_multi_dataset_model_runs.py: 24 passed (mock/spy, no live API).🤖 Generated with Claude Code
Greptile Summary
The PR adds dataset-less model-run creation and model-run-scoped prediction uploads, allowing each prediction to identify its target dataset item.
Model.create_run_without_datasetandModelRun.add_predictions.item_idanddataset_idtarget fields.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
ModelRunfrom the returned run ID.Sequence Diagram
sequenceDiagram participant U as SDK caller participant M as Model participant R as ModelRun participant P as PredictionUploader participant A as Nucleus API U->>M: create_run_without_dataset(name) M->>A: "POST model/{model_id}/modelRun/create" A-->>M: model_run_id M-->>U: "ModelRun(dataset_id=None)" U->>R: add_predictions(predictions) R->>P: Upload using model_run_id P->>A: "POST modelRun/{run_id}/uploadPredictions" Note over P,A: Each payload identifies its target via item_id or dataset_id + reference_id A-->>U: Aggregate upload resultReviews (2): Last reviewed commit: "fix(model-runs): guard async predict() a..." | Re-trigger Greptile
Context used (3)