Metadata-Version: 2.1
Name: django-celery-growthmonitor
Version: 1.1.0
Summary: A Django helper to monitor jobs running Celery tasks
Home-page: https://github.com/mbourqui/django-celery-growthmonitor/
Author: Marc Bourqui
Author-email: pypi.kemar@bourqui.org
License: GNU GPLv3
Download-URL: https://github.com/mbourqui/django-celery-growthmonitor/releases/tag/v1.1.0
Keywords: django utility celery celery-tasks monitoring
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Utilities
License-File: LICENSE

|Python| |Django| |License| |PyPI| |Build Status| |Coverage Status|
|Downloads|

Django-Celery-GrowthMonitor
===========================

A Django helper to monitor jobs running Celery tasks

Features
--------

-  Utilities to track progress of Celery tasks via in-database jobs
-  Designed for jobs with user-uploaded files

Requirements
------------

-  `Python <https://www.python.org/>`__ >= 3.5
-  `Django <https://www.djangoproject.com/>`__ >= 2.2
-  `Celery <http://www.celeryproject.org/>`__ >= 4.0.2
-  `echoices <https://github.com/mbourqui/django-echoices>`__ >= 2.6.0
-  `autoslug <https://github.com/justinmayer/django-autoslug>`__ >=
   1.9.7

Installation
------------

Using PyPI
~~~~~~~~~~

1. Run ``pip install django-celery-growthmonitor``

Using the source code
~~~~~~~~~~~~~~~~~~~~~

1. Make sure `pandoc <http://pandoc.org/index.html>`__ is installed
2. Run ``./pypi_packager.sh``
3. Run
   ``pip install dist/django_celery_growthmonitor-x.y.z-[...].wheel``,
   where ``x.y.z`` must be replaced by the actual version number and
   ``[...]`` depends on your packaging configuration

Usage
-----

.. code:: django

   ('state', echoices.fields.make_echoicefield(default=celery_growthmonitor.models.AJob.EState.CREATED, echoices=celery_growthmonitor.models.AJob.EState, editable=False)),
   ('status', echoices.fields.make_echoicefield(default=celery_growthmonitor.models.AJob.EStatus.ACTIVE, echoices=celery_growthmonitor.models.AJob.EStatus, editable=False)),

.. code:: django

   from .celery import app

   @app.task
   def my_task(holder: JobHolder, *args):
       job = holder.get_job()
       if job.has_failed():
           # Just skip the whole if the previous task failed
           return holder.pre_serialization()
       # Some processing
       ...
       job.save()
       return holder.pre_serialization()

Helpers
~~~~~~~

Automatically set the job failed on task failure using custom base Task
class

.. code:: django

   from celery_growthmonitor.models.task import JobFailedOnFailureTask

   @app.task(base=JobFailedOnFailureTask, bind=True)
   def my_task(self, holder: JobHolder):
       pass

Admin
^^^^^

.. code:: django

   from django.contrib import admin

   from celery_growthmonitor.admin import AJobAdmin

   @admin.register(MyJob)
   class MyJobAdmin(AJobAdmin):
       fields = AJobAdmin.fields + ('my_extra_field',)
       readonly_fields = AJobAdmin.readonly_fields + ('my_extra_field',)

.. |Python| image:: https://img.shields.io/badge/Python-3.5,3.6,3.7,3.8,3.9-blue.svg?style=flat-square
   :target: /
.. |Django| image:: https://img.shields.io/badge/Django-2.2,3.2-blue.svg?style=flat-square
   :target: /
.. |License| image:: https://img.shields.io/badge/License-GPLv3-blue.svg?style=flat-square
   :target: /LICENSE
.. |PyPI| image:: https://img.shields.io/pypi/v/django_celery_growthmonitor.svg?style=flat-square
   :target: https://pypi.org/project/django-celery-growthmonitor
.. |Build Status| image:: https://travis-ci.org/mbourqui/django-celery-growthmonitor.svg?branch=master
   :target: https://travis-ci.org/mbourqui/django-celery-growthmonitor
.. |Coverage Status| image:: https://coveralls.io/repos/github/mbourqui/django-celery-growthmonitor/badge.svg?branch=master
   :target: https://coveralls.io/github/mbourqui/django-celery-growthmonitor?branch=master
.. |Downloads| image:: https://pepy.tech/badge/django-celery-growthmonitor
   :target: https://pepy.tech/project/django-celery-growthmonitor


