Skip to content

Commit 94338d6

Browse files
committed
✨ Add ftm-translate service to queues
1 parent a5e8f1f commit 94338d6

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

openaleph_procrastinate/defer.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def transcribe(
310310
) -> None:
311311
"""
312312
Defer a new job for `ftm-transcribe`
313-
It will only deferred if `OPENALEPH_TRANSCRIBE_DEFER=1` (the default)
313+
It will only deferred if `OPENALEPH_TRANSCRIBE_DEFER=1` (the default is not)
314314
315315
Args:
316316
app: The procrastinate app instance
@@ -331,6 +331,32 @@ def transcribe(
331331
job.defer(app, priority)
332332

333333

334+
def translate(
335+
app: App, dataset: str, entities: Iterable[EntityProxy], **context: Any
336+
) -> None:
337+
"""
338+
Defer a new job for `ftm-translate`
339+
It will only deferred if `OPENALEPH_TRANSLATE_DEFER=1` (the default is not)
340+
341+
Args:
342+
app: The procrastinate app instance
343+
dataset: The ftm dataset or collection
344+
entities: The file entities to ingest
345+
context: Additional job context
346+
"""
347+
if tasks.translate.defer:
348+
job = DatasetJob.from_entities(
349+
dataset=dataset,
350+
queue=tasks.translate.queue,
351+
task=tasks.translate.task,
352+
entities=entities,
353+
dehydrate=True,
354+
**context,
355+
)
356+
priority = get_priority(context, tasks.translate.get_priority())
357+
job.defer(app, priority)
358+
359+
334360
def geocode(
335361
app: App, dataset: str, entities: Iterable[EntityProxy], **context: Any
336362
) -> None:

openaleph_procrastinate/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ class DeferSettings(BaseSettings):
8585
)
8686
"""ftm-transcribe"""
8787

88+
translate: ServiceSettings = ServiceSettings(
89+
queue="translate", task="ftm_translate.tasks.translate", defer=False
90+
)
91+
"""ftm-translate"""
92+
8893
geocode: ServiceSettings = ServiceSettings(
8994
queue="geocode", task="ftm_geocode.tasks.geocode", defer=False
9095
)

0 commit comments

Comments
 (0)