SDK best practices
In order to get the best experience from the SDK, we recommend the following:
-
Always use bulk operations
-
Unless you are testing or working on small datasets use bulk operations for faster and more reliable performance.
-
create_data_rows
instead ofcreate_data_row
-
project.export_labels()
instead ofproject.labels()
-
Label.bulk_delete(labels)
instead of[label.delete() for label in labels]
-
-
Use
next
to get elements of a paginated collection instead oflist
-
list(dataset.data_rows())[0]
is going to query for every singledata_row
in your dataset. -
Instead use
next(dataset.data_rows())
. This will request much less information and should be faster -
If you don't want
next
to raiseStopIteration
on an empty result, you can usenext( dataset.data_rows(), "default_value")
.
-
-
Make sure to use the latest version of the SDK
- Labelbox is a rapidly evolving company and we are constantly adding new features and optimizations.
Updated 22 days ago