(
self: Task,
stream: bytes,
args: dict,
)
| 37 | |
| 38 | @celery_app.task(bind=True) |
| 39 | def translate_task( |
| 40 | self: Task, |
| 41 | stream: bytes, |
| 42 | args: dict, |
| 43 | ): |
| 44 | def progress_bar(t: tqdm.tqdm): |
| 45 | self.update_state(state="PROGRESS", meta={"n": t.n, "total": t.total}) # noqa |
| 46 | print(f"Translating {t.n} / {t.total} pages") |
| 47 | |
| 48 | doc_mono, doc_dual = translate_stream( |
| 49 | stream, |
| 50 | callback=progress_bar, |
| 51 | model=ModelInstance.value, |
| 52 | **args, |
| 53 | ) |
| 54 | return doc_mono, doc_dual |
| 55 | |
| 56 | |
| 57 | @flask_app.route("/v1/translate", methods=["POST"]) |
nothing calls this directly
no test coverage detected