Package: selinon
An advanced task flow management on top ofCelery.Is this project helpful?Send me a simple warm
message!CrossroadPyPIDocumentationDevelopers
documentationTravis CILast stable release:Selinon 1.3.0TLDR;An advanced flow management above Celery (an asynchronous distributed
task queue) written in Python3, that allows you to:Dynamically schedule tasks based on results of previous tasksGroup tasks into flows in simple YAML configuration filesSchedule flows from other flows (even recursively)Store results of tasks in your storages and databases transparently,
validate results against defined JSON schemasDo redeployment respecting changes in the YAML configuration files
without purging queues (migrations)Track flow progress via the build-in tracing mechanismComplex per-task or per-flow failure handling with fallback tasks or
fallback flowsNo DAG limitation in your flowsSelectively pick tasks in your flow graphs that should be executed
respecting task dependenciesMake your deployment easy to orchestrate using orchestration tools
such asKubernetesHighly scalable Turing complete solution for big data processing pipelinesAnd (of course) much more… checkdocsYouTube VideoLet’s explain Selinon using aYouTube video (click to redirect to YouTube).AboutThis tool is an implementation above Celery that enables you to define
flows and dependencies in flows, schedule tasks based on results of
Celery workers, their success or any external events. If you are not
familiar with Celery, check out its homepagewww.celeryproject.orgorthis nice
tutorial.Selinon was originally designed to take care of advanced flows in one of
Red Hat products, where it already served thousands of flows and tasks.
Its main aim is to simplify specifying group of tasks, grouping tasks
into flows, handle data and execution dependencies between tasks and
flows, easily reuse tasks and flows, model advanced execution units in
YAML configuration files and make the whole system easy to model, easy
to maintain and easy to debug.By placing declarative configuration of the whole system into YAML files
you can keep tasks as simple as needed. Storing results of tasks in
databases, modeling dependencies or executing fallback tasks/flows on
failures are separated from task logic. This gives you a power to
dynamically change task and flow dependencies on demand, optimize data
retrieval and data storage from databases per task bases or even track
progress based on events traced in the system.Selinon was designed to serve millions of tasks in clusters or data
centers orchestrated byKubernetes,OpenShiftor any other orchestration tool,
but can simplify even small systems. Moreover, Selinon can make them
easily scalable in the future and make developer’s life much easier.A Quick First OverviewSelinon is serving recipes in a distributed environment, so let’s make a
dinner!If we want to make a dinner, we need to buy ingredients. These
ingredients are bought inbuyIngredientsFlow. This flow consists of
multiple tasks, but let’s focus on our main flow. Once all ingredients
are bought, we can start preparing our dinner inprepareFlow. Again,
this flow consists of some additional steps that need to be done in
order to accomplish our future needs. As you can see, if anything goes
wrong in mentioned flows (see red arrows), we make a fallback to pizza
with beer which we order. To make beer cool, we place it to ourFridgestorage. If we successfully finishedprepareFlowafter
successful shopping, we can proceed toserveDinnerFlow.Just to point out - grey nodes represent flows (which can be made of
other flows or tasks) and white (rounded) nodes are tasks. Conditions
are represented in hexagons (see bellow). Black arrows represent time or
data dependencies between our nodes, grey arrows pinpoint where results
of tasks are stored.For our dinner we need eggs, flour and some additional ingredients.
Moreover, we conditionally buy a flower based on our condition. Our taskBuyFlowerTaskwill not be scheduled (or executed) if our condition
isFalse. Conditions are made of predicates and these predicates can
be grouped as desired with logical operators. You can define your own
predicates if you want (default are available inselinon.predicates). Everything that is bought is stored inBasketstorage transparently.Let’s visualise ourbuyIngredientsFlow:As stated in our main flow after buying ingredients, we proceed to
dinner preparation but first we need to check our recipe that is hosted
athttp://recipes.lan/how-to-bake-pie.html. Any ingredients we
bought are transparently retrieved from defined storage as defined in
our YAML configuration file. We warm up our oven to expected temperature
and once the temperature is reached and we have finished with dough, we
can proceed to baking.Based on the description above, ourprepareFlowwill look like the
following graph:Once everything is done we serve plates. As we want to serve plates for
all guests we need to make sure we schedule N tasks of typeServePlateTask. Each time we run our whole dinner flow, number of
guests may vary so make sure no guest stays hungry. OurserveDinnerFlowwould look like the following graph:This example demonstrates very simple flows. The whole configuration can
be foundhere. Just check it out how you can
easily define your flows! You can find a script that visualises graphs
based on the YAML configuration inthis repoas well.More infoThe example was intentionally simplified. You can also parametrize your
flows, schedule N tasks (where N is a run-time evaluated variable), do
result caching, placing tasks on separate queues in order to be capable
of doing fluent system updates, throttle execution of certain tasks in
time, propagate results of tasks to sub-flows etc. Just checkdocumentationfor more info.Live DemoA live demo with few examples can be foundhere. Feel free to check it out.Installation$ pip3 install selinonAvailable extras:celery - needed if you use Celerymongodb - needed for MongoDBstorage adapterpostgresql - needed for PostgreSQLstorage adapterredis - needed for Redisstorage adapters3 - needed for S3storage adaptersentry - needed forSentry supportExtras can be installed via:$ pip3 install selinon[celery,mongodb,postgresql,redis,s3,sentry]Feel free to select only needed extras for your setup.