-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
347 additions
and
31 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""Module for the celery app.""" | ||
|
||
from .parallel import * # noqa: F403 | ||
from .serial import * # noqa: F403 | ||
from .get_max_article import * # noqa: F403 | ||
from .get_back_process import * # noqa: F403 |
File renamed without changes.
197 changes: 197 additions & 0 deletions
197
examples/redis_queue_gathering_serial_task/tasks/get_max_article.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,197 @@ | ||
"""Example of usage retsu with a celery app.""" | ||
|
||
import logging | ||
from datetime import datetime | ||
from typing import Any, Optional | ||
|
||
import celery | ||
|
||
from celery_app import app # type: ignore | ||
|
||
from retsu.celery import SerialCeleryTask, ParallelCeleryTask | ||
|
||
from .libs.collectors.arxiv import ArXivCollector | ||
|
||
|
||
from .libs.collectors.biorxiv import BiorXivCollector | ||
from .libs.collectors.embase import EmbaseRISCollector | ||
from .libs.collectors.medrxiv import MedrXivCollector | ||
from .libs.collectors.pubmed import PubMedCollector | ||
from .libs.collectors.pmc import PMCCollector | ||
from .libs.collectors.wos import WoSRISCollector | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@app.task # type: ignore | ||
def task_arxiv_get_max_articles( | ||
search: str, begin: datetime.date, end: datetime.date, task_id: str | ||
) -> int: | ||
"""Define the task for getting the max number of articles.""" | ||
collector = ArXivCollector() | ||
return collector.get_max_articles(search, begin, end) | ||
|
||
@app.task # type: ignore | ||
def task_biorxiv_get_max_articles( | ||
search: str, begin: datetime.date, end: datetime.date, task_id: str | ||
) -> int: | ||
"""Define the task for getting the max number of articles.""" | ||
collector = BiorXivCollector() | ||
return collector.get_max_articles(search, begin, end) | ||
|
||
@app.task # type: ignore | ||
def task_embase_get_max_articles( | ||
search: str, begin: datetime.date, end: datetime.date, task_id: str | ||
) -> int: | ||
"""Define the task for getting the max number of articles.""" | ||
collector = EmbaseRISCollector() | ||
return collector.get_max_articles(search, begin, end) | ||
|
||
@app.task # type: ignore | ||
def task_medrxiv_get_max_articles( | ||
search: str, begin: datetime.date, end: datetime.date, task_id: str | ||
) -> int: | ||
"""Define the task for getting the max number of articles.""" | ||
collector = MedrXivCollector() | ||
return collector.get_max_articles(search, begin, end) | ||
|
||
@app.task # type: ignore | ||
def task_pubmed_get_max_articles( | ||
search: str, begin: datetime.date, end: datetime.date, task_id: str | ||
) -> int: | ||
"""Define the task for getting the max number of articles.""" | ||
collector = PubMedCollector() | ||
return collector.get_max_articles(search, begin, end) | ||
|
||
@app.task # type: ignore | ||
def task_pmc_get_max_articles( | ||
search: str, begin: datetime.date, end: datetime.date, task_id: str | ||
) -> int: | ||
"""Define the task for getting the max number of articles.""" | ||
collector = PMCCollector() | ||
return collector.get_max_articles(search, begin, end) | ||
|
||
@app.task # type: ignore | ||
def task_wos_get_max_articles( | ||
search: str, begin: datetime.date, end: datetime.date, task_id: str | ||
) -> int: | ||
"""Define the task for getting the max number of articles.""" | ||
collector = WoSRISCollector() | ||
return collector.get_max_articles(search, begin, end) | ||
|
||
|
||
class WebOfScienceGetMaxArticlesTask(SerialCeleryTask): | ||
"""Task for the test.""" | ||
|
||
def get_group_tasks( # type: ignore | ||
self, *args, **kwargs | ||
) -> list[celery.Signature]: | ||
"""Define the list of tasks for celery chord.""" | ||
search = kwargs.get("search") | ||
dt_begin = kwargs.get("begin") | ||
dt_end = kwargs.get("end") | ||
task_id = kwargs.get("task_id") | ||
return [task_wos_get_max_articles.s(search, dt_begin, dt_end, task_id)] | ||
|
||
|
||
class PubMedCentralGetMaxArticlesTask(SerialCeleryTask): | ||
"""Task for the test.""" | ||
|
||
def get_group_tasks( # type: ignore | ||
self, *args, **kwargs | ||
) -> list[celery.Signature]: | ||
"""Define the list of tasks for celery chord.""" | ||
search = kwargs.get("search") | ||
dt_begin = kwargs.get("begin") | ||
dt_end = kwargs.get("end") | ||
task_id = kwargs.get("task_id") | ||
return [task_pmc_get_max_articles.s(search, dt_begin, dt_end, task_id)] | ||
|
||
|
||
class PubMedGetMaxArticlesTask(SerialCeleryTask): | ||
"""Task for the test.""" | ||
|
||
def get_group_tasks( # type: ignore | ||
self, *args, **kwargs | ||
) -> list[celery.Signature]: | ||
"""Define the list of tasks for celery chord.""" | ||
search = kwargs.get("search") | ||
dt_begin = kwargs.get("begin") | ||
dt_end = kwargs.get("end") | ||
task_id = kwargs.get("task_id") | ||
return [ | ||
task_pubmed_get_max_articles.s( | ||
search, dt_begin, dt_end, task_id | ||
) | ||
] | ||
|
||
|
||
class MedrXivGetMaxArticlesTask(SerialCeleryTask): | ||
"""Task for the test.""" | ||
|
||
def get_group_tasks( # type: ignore | ||
self, *args, **kwargs | ||
) -> list[celery.Signature]: | ||
"""Define the list of tasks for celery chord.""" | ||
search = kwargs.get("search") | ||
dt_begin = kwargs.get("begin") | ||
dt_end = kwargs.get("end") | ||
task_id = kwargs.get("task_id") | ||
return [ | ||
task_medrxiv_get_max_articles.s( | ||
search, dt_begin, dt_end, task_id | ||
) | ||
] | ||
|
||
|
||
class EmbaseGetMaxArticlesTask(SerialCeleryTask): | ||
"""Task for the test.""" | ||
|
||
def get_group_tasks( # type: ignore | ||
self, *args, **kwargs | ||
) -> list[celery.Signature]: | ||
"""Define the list of tasks for celery chord.""" | ||
search = kwargs.get("search") | ||
dt_begin = kwargs.get("begin") | ||
dt_end = kwargs.get("end") | ||
task_id = kwargs.get("task_id") | ||
return [ | ||
task_embase_get_max_articles.s( | ||
search, dt_begin, dt_end, task_id | ||
) | ||
] | ||
|
||
|
||
class BiorXivGetMaxArticlesTask(SerialCeleryTask): | ||
"""Task for the test.""" | ||
|
||
def get_group_tasks( # type: ignore | ||
self, *args, **kwargs | ||
) -> list[celery.Signature]: | ||
"""Define the list of tasks for celery chord.""" | ||
search = kwargs.get("search") | ||
dt_begin = kwargs.get("begin") | ||
dt_end = kwargs.get("end") | ||
task_id = kwargs.get("task_id") | ||
return [ | ||
task_biorxiv_get_max_articles.s( | ||
search, dt_begin, dt_end, task_id | ||
) | ||
] | ||
|
||
|
||
class ArXivGetMaxArticlesTask(SerialCeleryTask): | ||
"""Task to handle articles processing.""" | ||
|
||
def get_group_tasks( | ||
self, *args, **kwargs | ||
) -> list[celery.Signature]: | ||
"""Define the list of tasks for celery chord.""" | ||
search = kwargs.get("search") | ||
dt_begin = kwargs.get("begin") | ||
dt_end = kwargs.get("end") | ||
task_id = kwargs.get("task_id") | ||
|
||
return [task_arxiv_get_max_articles.s(search, dt_begin, dt_end, task_id)] | ||
|
9 changes: 5 additions & 4 deletions
9
examples/redis_queue_gathering_serial_task/tasks/libs/collectors/arxiv.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,10 +1,11 @@ | ||
from typing import Any | ||
from datetime import datetime | ||
|
||
|
||
class ArXivCollector: | ||
|
||
"""ArXivCollector.""" | ||
|
||
def get_max_articles(self, search: str, begin: datetime.date, end: datetime.date) -> int: | ||
def get_max_articles( | ||
self, search: str, begin: datetime.date, end: datetime.date | ||
) -> int: | ||
"""Get max number of articles.""" | ||
return 400 | ||
return 750 |
14 changes: 14 additions & 0 deletions
14
examples/redis_queue_gathering_serial_task/tasks/libs/collectors/biorxiv.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,14 @@ | ||
from datetime import datetime | ||
|
||
|
||
class BiorXivCollector: | ||
|
||
def __init__(self) -> None: | ||
"""Initialize EmBaseCollector.""" | ||
pass | ||
|
||
def get_max_articles( | ||
self, search: str, begin: datetime.date, end: datetime.date | ||
) -> int: | ||
"""Get the max number of articles.""" | ||
return 1000 |
16 changes: 16 additions & 0 deletions
16
examples/redis_queue_gathering_serial_task/tasks/libs/collectors/embase.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,16 @@ | ||
from typing import Any | ||
import datetime | ||
|
||
|
||
class EmbaseRISCollector: | ||
"""EmbaseRISCollector.""" | ||
|
||
def __init__(self) -> None: | ||
"""Initialize EmBaseCollector.""" | ||
pass | ||
|
||
def get_max_articles( | ||
self, search: str, begin: datetime.date, end: datetime.date | ||
) -> int: | ||
"""Get the max number of articles.""" | ||
return 250 |
Oops, something went wrong.