-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: FIT-750: Update Agreement Selected UI #8575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yyassi-heartex
wants to merge
22
commits into
develop
Choose a base branch
from
fb-fit-750/updated-ui
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6fcc853
feat: FIT-750: Update Agreement Selected UI
yyassi-heartex 28a5f80
linting
yyassi-heartex 5e3bb31
updating to the new agreement_selected structure
yyassi-heartex eec9be0
Merge remote-tracking branch 'origin/develop' into fb-fit-750/updated-ui
yyassi-heartex 8a316d8
linting
yyassi-heartex 3569ff8
Merge remote-tracking branch 'origin/develop' into fb-fit-750/updated-ui
yyassi-heartex 6a2e408
resolving an issue with reopening the popover after closing requiring…
yyassi-heartex f574210
updating default value
yyassi-heartex 7853ff6
we now have a min width on agreement selected
yyassi-heartex 55b6d2f
lint
yyassi-heartex 9d4c561
update migration
de88f2d
use service queue for migration
9388ffe
Merge remote-tracking branch 'origin/develop' into fb-fit-750/updated-ui
yyassi-heartex c524adf
we now fire an event with the invoke ok action is completed
yyassi-heartex f2334a2
Merge remote-tracking branch 'origin/develop' into fb-fit-750/updated-ui
yyassi-heartex 1b80f78
Sync Follow Merge dependencies
AndrejOros b9d761c
Merge branch 'develop' into 'fb-fit-750/updated-ui'
AndrejOros f88f790
Merge branch 'develop' into fb-fit-750/updated-ui
yyassi-heartex 15e64e3
fixed tooltip button visuals
yyassi-heartex 628a939
Merge remote-tracking branch 'origin/develop' into fb-fit-750/updated-ui
yyassi-heartex 5f5868b
Merge remote-tracking branch 'origin/develop' into fb-fit-750/updated-ui
yyassi-heartex 96a2d3c
lint
yyassi-heartex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
label_studio/data_manager/migrations/0017_update_agreement_selected_to_nested_structure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from django.db import migrations, connection | ||
from copy import deepcopy | ||
from django.apps import apps as django_apps | ||
from django.conf import settings | ||
from core.models import AsyncMigrationStatus | ||
from core.redis import start_job_async_or_sync | ||
from core.utils.iterators import iterate_queryset | ||
import logging | ||
|
||
migration_name = '0017_update_agreement_selected_to_nested_structure' | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def forward_migration(): | ||
""" | ||
Migrates views that have agreement_selected populated to the new structure | ||
|
||
Old structure: | ||
'agreement_selected': { | ||
'annotators': List[int] | ||
'models': List[str] | ||
'ground_truth': bool | ||
} | ||
|
||
New structure: | ||
'agreement_selected': { | ||
'annotators': { | ||
'all': bool | ||
'ids': List[int] | ||
}, | ||
'models': { | ||
'all': bool | ||
'ids': List[str] | ||
}, | ||
'ground_truth': bool | ||
} | ||
""" | ||
migration, created = AsyncMigrationStatus.objects.get_or_create( | ||
name=migration_name, | ||
defaults={'status': AsyncMigrationStatus.STATUS_STARTED} | ||
) | ||
if not created: | ||
return # already in progress or done | ||
|
||
# Look up models at runtime inside the worker process | ||
View = django_apps.get_model('data_manager', 'View') | ||
|
||
# Iterate using values() to avoid loading full model instances | ||
# Fetch only the fields we need, filtering to views that have 'agreement_selected' in data | ||
qs = ( | ||
View.objects | ||
.filter(data__has_key='agreement_selected') | ||
.filter(data__agreement_selected__isnull=False) | ||
.values('id', 'data') | ||
) | ||
|
||
updated = 0 | ||
for row in qs: | ||
view_id = row['id'] | ||
data = row.get('data') or {} | ||
|
||
new_data = deepcopy(data) | ||
# Always use the new nested structure | ||
new_data['agreement_selected'] = { | ||
'annotators': {'all': True, 'ids': []}, | ||
'models': {'all': True, 'ids': []}, | ||
'ground_truth': False | ||
} | ||
|
||
# Update only the JSON field via update(); do not load model instance or call save() | ||
View.objects.filter(id=view_id).update(data=new_data) | ||
logger.info(f'Updated View {view_id} agreement selected to default all annotators + all models') | ||
updated += 1 | ||
|
||
if updated: | ||
logger.info(f'{migration_name} Updated {updated} View rows') | ||
|
||
migration.status = AsyncMigrationStatus.STATUS_FINISHED | ||
migration.save(update_fields=['status']) | ||
|
||
def forwards(apps, schema_editor): | ||
start_job_async_or_sync(forward_migration, queue_name=settings.SERVICE_QUEUE_NAME) | ||
|
||
|
||
def backwards(apps, schema_editor): | ||
# Irreversible: we cannot reconstruct the previous annotator lists safely | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
atomic = False | ||
|
||
dependencies = [ | ||
('data_manager', '0016_migrate_agreement_selected_annotators_to_unique') | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forwards, backwards), | ||
] | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.