Bundle
This class allows to perform operations in bundles to improve performance by reducing number of network calls. It is not supposed to be instantiated directly by a user. Use the encord.project.Project.create_bundle() method to initiate bundled operations.
To execute batch you can either call execute() directly, or use a Context Manager.
# Code example of performing batched label initialisation
project = ... # assuming you already have instantiated this Project object
label_rows = project.list_label_rows_v2()
bundle = project.create_bundle()
for label_row in label_rows:
label_row.initialise_labels(bundle=bundle)
# no real network operations happened at this point
# now, trigger the actual network interaction
bundle.execute()
# all labels are initialised at this point
And this is the same flow with the Context Manager approach:
# Code example of performing batched label initialisation
project = ... # assuming you already have instantiated this Project object
label_rows = project.list_label_rows_v2()
with project.create_bundle() as bundle:
for label_row in label_rows:
label_row.initialise_labels(bundle=bundle)
# no real network operations happened at this point
# At this point all labels will be initialised
execute
bundle.execute()
Executes all scheduled operations in bundles and populates results.
Return type:
None