Skip to content

Commit

Permalink
fix: LSDV-4974: Add storage status and debug: fix migration (HumanSig…
Browse files Browse the repository at this point in the history
…nal#4198)

* fix: LSDV-4974: Add storage status and debug: fix migration

* Fix
  • Loading branch information
makseq authored May 17, 2023
1 parent a775c49 commit 35797f6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions label_studio/io_storages/migrations/0014_init_statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@

def update_storage(storage):
logger.info(f'=> Migration for {storage._meta.label} statuses started')

storage.objects.update(status='initialized')
instances = list(storage.objects.all().only('id', 'meta', 'status', 'last_sync_count'))

for instance in instances:
prefix = f'Project ID={instance.project.id} {instance}'

# import source storages
if 'import' in storage._meta.label_lower:
instance.meta['tasks_existed'] = instance.links.count()
count = instance.links.count() - instance.last_sync_count if instance.last_sync_count else 0
instance.meta['tasks_existed'] = count if count > 0 else 0
if instance.meta['tasks_existed'] and instance.meta['tasks_existed'] > 0:
instance.status = 'completed'
logger.info(f'{prefix} tasks_existed = {instance.meta["tasks_existed"]}')

# target export storages
else:
instance.meta['total_annotations'] = instance.last_sync_count
if instance.last_sync_count and instance.last_sync_count > 0:
Expand Down

0 comments on commit 35797f6

Please sign in to comment.