Skip to main content

A simple Pipeline creator

Project description

DemPipe

Installation

A simple pip install will do :

python -m pip install DemPipe

Use

from DemPipe import PipeExecutor, Action

with PipeExecutor() as pipe:
    actions = [Action(lambda x: x**2, 2),  # returns 4
               Action(lambda x: x+3, ctx_in='last_value', ctx_out='my_result_name'),  # returns 4+3
               Action(lambda x: x*2, ctx_in='my_result_name')  # returns 2*7
              ]
    result = pipe.execute(actions)
    print('result:', result)  # 14
    print('result (from context):', pipe.context['last_value'])  # 14
    print('my_result_name:', pipe.context['my_result_name'])  # 7

You can also use a Trigger Action for conditional Actions in the pipeline !

from DemPipe import PipeExecutor, Action, Trigger

with PipeExecutor() as pipe:
    actions = [Action(lambda x: x**2, 2),  # returns 4
               Trigger(lambda x: x==3,   # returns False -> executes the second action
                       Action(lambda x: x+3, ctx_in='last_value'),  # ignored
                       Action(lambda x: x+7, ctx_in='last_value'),  # returns 11
                       ctx_in='last_value')
              ]
    result = pipe.execute(actions)
    print('result:', result)  # 11

Error Handling

In case an error occurs, you can configure an automatic e-mail to be sent with the traceback and the error message :

  • Create a config file containing your credentials :
{
  "mail": {
    "mail_server": "smtp.gmail.com",
	"mail_port": 587,
	"mail_user": "${os_environ[user]}",
	"mail_password": "${os_environ[password]}",
	"mail_use_tls": true,
	"mail_default_receiver": "${os_environ[receiver]}"
  },
  "pipe_name": "My Pipe"
}
  • Specify config_file to the PipeExecutor
from DemPipe import PipeExecutor, Action

with PipeExecutor(config_file='ConfigsFolder.MyConfig') as pipe:
    pipe.execute(Action(lambda x: x/0, 2))  # raises ZeroDivisionException

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

DemPipe-0.0.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

DemPipe-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file DemPipe-0.0.1.tar.gz.

File metadata

  • Download URL: DemPipe-0.0.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for DemPipe-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2213c565a609949791f69a0b79adae32127fab752d1876dc10b9a5c971ecb770
MD5 dda3bb76a8d5fa65cd45a7038d1c93e5
BLAKE2b-256 61fa74d87d7254e6dd6579bd3584ad8f24dd0600892cb183add4bae786a5d6ae

See more details on using hashes here.

File details

Details for the file DemPipe-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: DemPipe-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for DemPipe-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd3f92ad9466f1127503a71f5409ddb03e152ee4de2011f638e154fb48b669c1
MD5 9d8f6925c533114f4327a4ce19c24fd1
BLAKE2b-256 5b1b24a1657f66fe5cde1761a4ee7396b3733f959fb388fbee72b3c016750cd9

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