forked from HumanSignal/label-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: DEV-2589: Move calculate_stats_all_orgs to rq_workers, swap migr…
…ation (HumanSignal#2569)
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
41 changes: 41 additions & 0 deletions
41
label_studio/tasks/migrations/0024_manual_migrate_counters_again.py
This file contains 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,41 @@ | ||
import sys | ||
import logging | ||
|
||
from django.db import migrations | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def forwards(apps, schema_editor): | ||
from tasks.functions import calculate_stats_all_orgs | ||
from django.conf import settings | ||
|
||
if settings.VERSION_EDITION == 'Community': | ||
run_command = 'label-studio calculate_stats_all_orgs' | ||
else: | ||
run_command = 'cd /label-studio-enterprise/label_studio_enterprise && ' \ | ||
'python3 manage.py calculate_stats_all_orgs' | ||
|
||
if '--skip-long-migrations' in sys.argv: | ||
logger.error( | ||
f"You used --skip-long-migrations, so you should run the migration manually as a separate process " | ||
f"to recalculate task counters, please use Django command `{run_command}`" | ||
) | ||
return | ||
|
||
logger.debug('=> Starting calculate_stats_all_orgs for task counters again') | ||
calculate_stats_all_orgs(from_scratch=False, redis=True) | ||
|
||
|
||
def backwards(apps, schema_editor): | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
atomic = False | ||
|
||
dependencies = [('tasks', '0023_auto_20220620_1007'), ('core', '0001_initial')] | ||
|
||
operations = [ | ||
migrations.RunPython(forwards, backwards), | ||
] |