-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1520 from AlexsLemonade/dev
[HOTFIX] Deploy old salmon version rerunning! (and others)
- Loading branch information
Showing
25 changed files
with
635 additions
and
244 deletions.
There are no files selected for viewing
Empty file.
Empty file.
31 changes: 31 additions & 0 deletions
31
api/data_refinery_api/management/commands/update_es_index.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,31 @@ | ||
import datetime | ||
|
||
from django.core.management.base import BaseCommand | ||
from django_elasticsearch_dsl.registries import registry | ||
from django.utils import timezone | ||
|
||
|
||
# We'll update for the past 30 minutes every 20 minutes. | ||
UPDATE_WINDOW = datetime.timedelta(minutes=30) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Manage elasticsearch index.' | ||
|
||
def handle(self, *args, **options): | ||
"""This command is based off of the 'populate' command of Django ES DSL: | ||
https://github.com/sabricot/django-elasticsearch-dsl/blob/f6b2e0694e4ed69826c824196ccec5863874c856/django_elasticsearch_dsl/management/commands/search_index.py#L86 | ||
We have updated it so that it will do incremental updates | ||
rather than looping over the full queryset every time. | ||
""" | ||
models = set(registry.get_models()) | ||
|
||
for doc in registry.get_documents(models): | ||
start_time = timezone.now() - UPDATE_WINDOW | ||
qs = doc().get_queryset().filter(last_modified__gt=start_time).order_by('id') | ||
self.stdout.write("Indexing {} '{}' objects".format( | ||
qs.count(), qs.model.__name__) | ||
) | ||
doc().update(qs) |
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
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
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
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
7 changes: 2 additions & 5 deletions
7
...efinery_workers/downloaders/test_utils.py → ...ta_refinery_common/test_job_management.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 |
---|---|---|
@@ -1,18 +1,15 @@ | ||
import os | ||
import psutil | ||
|
||
from django.test import TestCase, tag | ||
from typing import List | ||
from unittest.mock import patch, call | ||
from urllib.error import URLError | ||
|
||
from data_refinery_workers.downloaders import utils | ||
from data_refinery_common.job_management import create_processor_job_for_original_files | ||
|
||
|
||
class UtilsTestCase(TestCase): | ||
@tag('downloaders') | ||
def test_no_jobs_to_create(self): | ||
"""Make sure this function doesn't raise an exception with no files.""" | ||
utils.create_processor_job_for_original_files([]) | ||
create_processor_job_for_original_files([]) | ||
|
||
self.assertTrue(True) |
Oops, something went wrong.