Skip to main content

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 pool is used.
  • Bind task bind=True and use self.update_state to manually update platform's progress bar.
  • Tasks can return results or raise Exception.

License

See License.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datagrok_celery_task-0.1.4.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datagrok_celery_task-0.1.4-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file datagrok_celery_task-0.1.4.tar.gz.

File metadata

  • Download URL: datagrok_celery_task-0.1.4.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

Hashes for datagrok_celery_task-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0a30c2eb1b9abd974b4e6683fefa953a71125eeefa3aab87a2fd84a3e51b930e
MD5 3601b3bea14e56fe44f87371cb165163
BLAKE2b-256 4f2230ea46e77a1d101d8217cc6e1dfcf5b2bf0e6efe5be42410aeeeef4d0aa2

See more details on using hashes here.

File details

Details for the file datagrok_celery_task-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for datagrok_celery_task-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8e2d61d4e185873d8f57c506c3e0fa0a3b4a865f918dab41fdcd303ced7e9bb6
MD5 dc43681e9fb905406c0d82eaacb27c41
BLAKE2b-256 5e72aab2e05780d252d5d531a5a1ee883e819d7e2b43108c09b339a5aa37e8d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page