Celery Task wrapper to integrate Python functions into the Datagrok platform.
Project description
Datagrok Python Celery Task Library
This package provides a Celery task wrapper for integrating Python functions into the Datagrok platform. It enables logging, progress tracking, and seamless communication between Celery workers and Datagrok’s infrastructure.
Refer to the Datagrok Help for more information about the platform.
Installation
Install the package using pip:
pip install datagrok-celery-task
Usage
To define tasks compatible with Datagrok, use the DatagrokTask base class and configure your Celery app with the provided Settings class.
from celery import Celery
from datagrok_celery_task import DatagrokTask, Settings
import logging
# Always create a Settings object. Provide properties manually only if not launched by Datagrok.
settings = Settings(log_level=logging.DEBUG)
# Create a Celery app
app = Celery(settings.celery_name, broker=settings.broker_url)
# Define a simple Datagrok task
@app.task(base=DatagrokTask)
def echo(c, **kwargs):
print("Received USER_API_KEY:", kwargs.get("USER_API_KEY", "empty"))
print("Received data:", c)
# Define a task that reports progress
@app.task(bind=True, base=DatagrokTask)
def progress_task(self: DatagrokTask, a):
self.update_state(meta={"percent": 10, "description": "Starting"})
print(a)
return "Task completed"
Notes
- When Datagrok manages the Celery worker, environment variables will auto-populate Settings.
- Prins will appear in Datagrok log messages of the FuncCall. Please note, that it will work only when Celery
prefork worker poolis used. - Bind task
bind=Trueand useself.update_stateto manually update platform's progress bar. - Tasks can return results or raise Exception.
License
See License.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datagrok_celery_task-0.1.5.tar.gz.
File metadata
- Download URL: datagrok_celery_task-0.1.5.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c42eaff528c087c692d21bee53e1cb27671811ac365bac78d0fedf31e297d76
|
|
| MD5 |
482b4f33a8e911c2358e902e08447de4
|
|
| BLAKE2b-256 |
efff0fb9f358ab799f2a7f41bb2a9622583d047653e9803502cebbd4a8024301
|
File details
Details for the file datagrok_celery_task-0.1.5-py3-none-any.whl.
File metadata
- Download URL: datagrok_celery_task-0.1.5-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b47e51cfe7941b0def289a6b1e4609c5b7d14835c125c9234d0c78a78700744c
|
|
| MD5 |
61ef9206d436b58bd82658dffabc3485
|
|
| BLAKE2b-256 |
14b4c4b77ea0c9b0559a8b7e549e0e2092977ff813de474a2f88b1c4033822c5
|