Skip to main content

An app for create process workflows and schedule tasks on django

Project description

Django Process

Its a reusable app for execute scrits in workflows with dependecies NEW VERSION 4.6 it allows you to use the complete app from the admin site with the graphics and custom actions

Table of Contents

Usage:

  • pip install django-process
  • add 'process' to installed apps
  • makemigrations and migrate them
  • create a Process and Tasks which belong to the process. (The Job is an instance executed of the process, JobTask is an instance executed of the Task you must not create manually any of them !)
  • (optional) you can create dependencies of the tasks for they to run sequentially, if you don't create dependencies the tasks will start all at once
  • execute python manage.py run_jobs

TIPS:

execution of the processes

just as simple as

>>> python manage.py run_jobs

frequency of the process

The process have a crontab-like configuration for set the frequency. Lets take the attribute minute for example. You can:

  • use * for all minutes
  • specify a list of minutes 1,3,5,8,25,59
  • specify a range of minutes 1-30
  • combine list and ranges example 1,3,5,8,4-9 will be expanded to: 1,3,4,5,6,7,8,9
  • for the moment it doesnt accept fractions using the / char

you can use any of those above for the five attributes just like a crontab.

the start job process runs each minute while the tasks manager its always online.

render process or job object as an workflow diagram

in your html code you can render a Process as an image workflow

  • {% load process_diagram %} in your html for use the diagram templatetag
  • {% include "process/dj-process.html" %} in your html for include the CSS and JS
  • {{ object|diagram }} to render the object
{% load process_diagram %}
<!DOCTYPE html>
<html lang="en">
<head>
    {% include "process/dj-process.html" %}
    <meta charset="UTF-8">
    <title>Title</title>
</head>
    <body>
        {{ object|diagram }}
    </body>
</html>

this will return an output like this:


placing a task in an workflow diagram

Task objects have two attributes: level & offset you can place a task in a workflow diagram using those attributes levels are vertical placement while offset are horizontal placements

  • level: the value for level starts on 0 you can create as many levels as you want in workflow diagram
  • offset: its a percentaje 0% will place your task in the middle 25% places to the right while -25% place the task to the left

starting a Job and its tasks on demand

The job needs a Process parent to be instanced:

>>> process = Process.objects.all()[0]
>>> job, tasks = Job.create(process)

this will create the job for the process and also the tasks if the runner is online it will execute immediate all the tasks created sequentially if you have defined dependencies for them or all at once if you have not

reopen task for execution in cascasde

you can reopen a task that has been executed already:

>>> task = JobTask.objects.all()[0]
>>> task.reopen(main=True)

this will reopen the job task for execution again and it will set status awaiting for the childs in CASCADE

access to django builtins

If you want to use django functions or access models and their methods in a task-script

you need first import process.env example:

import process.env
from yourapp.models import CustomModel

objects = CustomModel.objects.all()
for obj in objects:
    print(obj)

if you do not import process.env you will get an error trying to access django

this short tutorial does not covers all the power for the app. I will be adding more examples

if you got doubts or questions don't hesitate send me a mail or create an issue im always online

mail the author

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

django-process-4.8.0.tar.gz (561.0 kB view details)

Uploaded Source

File details

Details for the file django-process-4.8.0.tar.gz.

File metadata

  • Download URL: django-process-4.8.0.tar.gz
  • Upload date:
  • Size: 561.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for django-process-4.8.0.tar.gz
Algorithm Hash digest
SHA256 7b110d0f1a6558d64abce70499be6507e6515b8c97f5299d53f190a9f0e8542a
MD5 cda1a430f775ff5bfc6bfb95601cde94
BLAKE2b-256 0a38a12a1be042fdc51184c1c0816355316aea5b6fd7060862ff391186a0856b

See more details on using hashes here.

Supported by

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