Skip to main content
Compysition
========

What?
-----
::

A Python application framework to build and manage asynchronous and highly concurrent event-driven data flow

I have created **compysition** to build off the simple way in which Wishbone_ managed message flow across multiple
modules. Compysition expands upon this module registration method to provide abstracted multi-process communication
via 0mq_, as well as the ability for full cyclical communication for in-process request/response behavior in a lightweight,
fast, and fully concurrent manner, using gevent_ greenlets and concurrency patterns to consume and output events

.. _0mq: http://zeromq.org/
.. _Wishbone: https://github.com/smetj/wishbone
.. _gevent: http://www.gevent.org

**Compysition is currently new and in pre-Beta release. It will be undergoing many deep changes in the coming months**
The **compysition** project is built upon the original work of the Wishbone_ project

Variations from the traditional Actor Model
-----

The traditional and strict actor model requires that all actors have exactly one inbox and one outbox. I found that this was
overly constraining for creating and crafting complex data flow models. So compysition inherently supports multiple inboxes
and multiple outboxes on every single actor.

To put it in actor model terms, every actor is also a "funnel" and a "fanout".

The default behavior, unless stated otherwise in the module documentation, is that all modules will send/copy an event to ALL
connected outbox queues

Full Circle WSGI Example
-------

For the example below, we want to execute an XML transformation on a request and send it back to the client in a fast
and concurrent way. All steps and executions are spun up as spawned greenlet on the router

.. code-block:: python

from compysition import Director
from compysition.actors import WSGI, BasicAuth, Transformer

from myproject.actors import SomeRequestExecutor
from myprojectresources import my_xsl_files as xsls

director = Director()
wsgi = director.register_actor(WSGIServer, "wsgi")
auth = director.register_actor(BasicAuth, "auth")
submit_transform = director.register_actor(Transformer, "submit_transform", xsls['submit'])
acknowledge_transform = director.register_actor(Transformer, "acknowledge_transform", my_xsl_files['acknowledge.xsl'])
request_executor = director.register_actor(SomeRequestExecutor, "request_executor")

director.connect_queue(wsgi, auth)
director.connect_queue(auth, submit_transform)
director.connect_queue_error(auth, wsgi) # Redirect auth errors to the wsgi server as a 401 Unaothorized Error
director.connect_queue(submit_transform, request_executor)
director.connect_queue_error(submit_transform, wsgi)
director.connect_queue(request_executor, acknowledge_transform)
director.connect_queue(acknowledge_transform, wsgi)

director.start()

Note how modular each component is. It allows us to configure any steps in between class method executions and add
any additional executions, authorizations, or transformations in between the request and response by simply
adding it into the message execution flow

One-way messaging example
-------

.. code-block:: python

from compysition import Director
from compysition.actors import TestEvent, STDOUT

director = Director()
event_generator = director.register_actor(TestEvent, "event_generator", interval=1)
output_one = director.register_actor(STDOUT, "output_one", prefix="I am number one: ", timestamp=True)
output_two = director.register_actor(STDOUT, "output_two", prefix="I am number two: ", timestamp=True)

director.connect_queue(event_generator, [output_one, output_two])

director.start()

Output:
[2015-02-13 16:56:35.850659] I am number two: test
[2015-02-13 16:56:35.850913] I am number one: test
[2015-02-13 16:56:36.851588] I am number two: test
[2015-02-13 16:56:36.851856] I am number one: test
[2015-02-13 16:56:37.852456] I am number two: test
[2015-02-13 16:56:37.852737] I am number one: test
[2015-02-13 16:56:38.858107] I am number two: test
[2015-02-13 16:56:38.858400] I am number one: test
[2015-02-13 16:56:39.860292] I am number two: test
[2015-02-13 16:56:39.860570] I am number one: test

ZeroMQ MajorDomo Implementation Example
-------
The following example is a single-process example of the multi-process MajorDomo Protocal from ZMQ. The pieces noted
could all be run outside this process in their own compysitionscript, scalable across multiple hosts and cores

.. code-block:: python

from compysition.actors import MDPClient, MDPWorker, MDPBroker, WSGI, MDPBrokerRegistrationService, STDOUT, Data
from compysition import Director

director = Director()

mdp_client = director.register_actor(MDPClient, "mdp_client")
mdp_broker = director.register_actor(MDPBroker, "mdp_broker") # This could be it's own process
mdp_regservice = director.register_actor(MDPBrokerRegistrationService, "mdp_regservice") # This could be it's own process
mdp_worker = director.register_actor(MDPWorker, "mdp_worker", "test_service") # This (These) would be their own processes
stdout = director.register_actor(STDOUT, "stdout")
data = director.register_actor(Data, "data", data="Hello, this has been a test")

wsgi = director.register_actor(WSGI, "wsgi", run_server=True, address="0.0.0.0", port=7000)
director.register_log_actor(STDOUT, "stdoutmodule", timestamp=True)

director.connect_queue(wsgi, mdp_client)
director.connect_queue(mdp_worker, data)
director.connect_queue(data, mdp_worker)
director.connect_queue(mdp_client, wsgi)

director.start()

After running this process, initiating a http request to http://127.0.0.1:7000/test_service would show the dataflow across MDP components

Installing
----------

Through Pypi:

$ pip install compysition

Or the latest development branch from Github:

$ git clone git@github.com:fiebiga/compysition.git
$ cd compysition
$ sudo python setup.py install

Support
-------

You may email myself at fiebig.adam@gmail.com

Metadata

Release files for compysition 1.2.54

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compysition 1.2.54
File Size Uploaded
compysition-1.2.54.tar.gz 58.8 kB Details

Release files / compysition-1.2.54.tar.gz

Download URL compysition-1.2.54.tar.gz
Size 58.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e503113af1f3695395a90471faeddc50f675046379b0fa5927d5f5a60539a754
BLAKE2b-256 checksum
How to use checksums
c65f64a66d0c09af59eb8669d80742a91fed00b3c1424d798b1b3f204671cf86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2.54 This release

1 release file

1.2.53

1 release file

1.2.52

1 release file

1.2.51

1 release file

1.2.50

1 release file

1.2.49

1 release file

1.2.48

1 release file

1.2.47

1 release file

1.2.46

1 release file

1.2.45

1 release file

1.2.44

1 release file

1.2.43

1 release file

1.2.42

1 release file

1.2.41

1 release file

1.2.4

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1.1.42

1 release file

1.1.41

1 release file

1.1.40

1 release file

1.1.39

1 release file

1.1.38

1 release file

1.1.37

1 release file

1.1.36

1 release file

1.1.35

1 release file

1.1.34

1 release file

1.1.33

1 release file

1.1.32

1 release file

1.1.30

1 release file

1.1.29

1 release file

1.1.28

1 release file

1.1.27

1 release file

1.1.26

1 release file

1.1.25

1 release file

1.1.24

1 release file

1.1.23

1.1.22

1 release file

1.1.21

1 release file

1.1.20

1 release file

1.1.19

1 release file

1.1.18

1 release file

1.1.17

1 release file

1.1.16

1 release file

1.1.15

1 release file

1.1.13

1 release file

1.1.11

1 release file

1.1.10

1 release file

1.1.09

1 release file

1.1.08

1 release file

1.1.07

1 release file

1.1.06

1.1.05

1 release file

1.1.04

1 release file

1.1.03

1 release file

1.1.02

1 release file

1.0.66

1 release file

1.0.65

1 release file

1.0.64

1 release file

1.0.63

1 release file

1.0.62

1 release file

1.0.61

1 release file

1.0.58

1 release file

1.0.57

1 release file

1.0.56

1 release file

1.0.55

1 release file

1.0.54

1 release file

1.0.53

1 release file

1.0.52

1 release file

1.0.51

1 release file

1.0.5

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page