Skip to content

Commit f5c2fec

Browse files
committed
2 parents 15a2cda + def47a2 commit f5c2fec

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

label_studio/io_storages/base_models.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,15 +791,21 @@ def save_annotations(self, annotations: models.QuerySet[Annotation]):
791791
self.info_set_in_progress()
792792
self.cached_user = self.project.organization.created_by
793793

794+
# Calculate optimal batch size based on project data and worker count
795+
project_batch_size = self.project.get_task_batch_size()
796+
chunk_size = max(1, project_batch_size // self.max_workers)
797+
logger.info(
798+
f'Export storage {self.id}: using chunk_size={chunk_size} '
799+
f'(project_batch_size={project_batch_size}, max_workers={self.max_workers})'
800+
)
801+
794802
with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
795803
# Batch annotations so that we update progress before having to submit every future.
796804
# Updating progress in thread requires coordinating on count and db writes, so just
797805
# batching to keep it simpler.
798806
for annotation_batch in _batched(
799-
Annotation.objects.filter(project=self.project).iterator(
800-
chunk_size=settings.STORAGE_EXPORT_CHUNK_SIZE
801-
),
802-
settings.STORAGE_EXPORT_CHUNK_SIZE,
807+
Annotation.objects.filter(project=self.project).iterator(chunk_size=chunk_size),
808+
chunk_size,
803809
):
804810
futures = []
805811
for annotation in annotation_batch:

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ dependencies = [
7373
"djangorestframework-simplejwt[crypto] (>=5.4.0,<6.0.0)",
7474
"tldextract (>=5.1.3)",
7575
## HumanSignal repo dependencies :start
76-
"label-studio-sdk @ https://github.com/HumanSignal/label-studio-sdk/archive/a0a9c4c642a4bf13e10ded0d2ba105caf39349bb.zip",
76+
"label-studio-sdk @ https://github.com/HumanSignal/label-studio-sdk/archive/a80479402d230f5e097a3052f4fe39647e05250a.zip",
7777
## HumanSignal repo dependencies :end
7878
]
7979

0 commit comments

Comments
 (0)