Model Run Creation via SDK Not Working

We are trying to create model run’s for a project programmtically via the Python SDK, following Create a model run

model_name = "My Test Model"
model = client.create_model(name=model_name, ontology_id=project.ontology().uid)
model_run = model.create_model_run('Test Run')
model_run.upsert_labels(sampled_batch_uids)

We are using metadata & DB to query specific data rows within that project to pass their UIDs as sampled_batch_uids in the model_run.upsert_labels call.

The code runs successfully & the Model Run is created in Labelbox, however, it has no ground truth data rows included.
Is this because we used a subset of the projected labels, not all?

Hey @ceubel, thanks for asking!

You can add data rows alone, to a model run, using model_run.upsert_data_rows()

Or, you can upload data rows AND labels, to a model run, using model_run.upsert_labels()

In your case, is sampled_batch_uids a list of label ids?
It sounds like it’s UIDs (data row ids) and not label ids?

You can use project.export_labels() to get the label ids.

Let me know if that helps, if you’re stuck, and if you have ideas about how to make this process simpler and more elegant!!

Thank you @mvoisin ! Yes, I made a mistake by trying to use data row IDs with .upsert_labels() instead of the label UIDs.
Using label UIDs worked perfectly, thank you!