Skip to main content

A light-weight framework for defining and running dependent tasks.

Project description

codep

A light-weight framework for defining and running dependent tasks. By building a dependency graph between tasks, the runner makes sure that tasks that are required by multiple dependants are only run once and reuses the results.

Usage

In the example below the calculate_circumference and calculate_volume tasks both depend on the acquire_radius and calculate_pi tasks. The runner will infer that from the dependency graph and run them before.

import codep
import immutables


@codep.make_partial()
def acquire_radius(state: immutables.Map) -> immutables.Map:
    return state.set("radius", 6_371)


@codep.make_partial()
def calculate_pi(state: immutables.Map) -> immutables.Map:
    return state.set("pi", 3.14)


@codep.make_partial(depends=(calculate_pi, acquire_radius))
def calculate_circumference(state: immutables.Map) -> immutables.Map:
    return state.set("circumference", 2 * state["pi"] * state["radius"])


@codep.make_partial(depends=(acquire_radius, calculate_pi))
def calculate_volume(state: immutables.Map) -> immutables.Map:
    return state.set("volume", (4/3) * state["pi"] * state["radius"] ** 3)


if __name__ == '__main__':
    r1, r2 = codep.run(calculate_circumference, calculate_volume)
    circumference = r1.state["circumference"]
    volume = r2.state["volume"]
    print(
        f"The circumference of earth is {circumference} km and its volume is " 
        f"{volume} km^3"
    )

Todo

  • Make Partial a Generic, and make tasks only able to return a value. Partial.apply should instead assign the result to the state which becomes a mapping Type[Partial] -> Any.
  • Remove print(), use logging
  • Concurrent task execution

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

codep-0.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codep-0.0.1-py2.py3-none-any.whl (2.6 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: codep-0.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for codep-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9f44e5e692f3eae203ed971c1ff3400c9388dc6ae1751292f3f811aaec32623b
MD5 874086648924f7154824596bcdff182b
BLAKE2b-256 1944d6b10f4f8a3e59fc54ba51830a6b3c1bf062b4b2885598b71203a50d1a3e

See more details on using hashes here.

File details

Details for the file codep-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: codep-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for codep-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7ee21d163962c3c769746e2749b2e3a83e54063b2eef0c8bc6cd7483de7481e0
MD5 097459e78cc90972b823a39b7b227c41
BLAKE2b-256 3de2be0644e1e0461708940989f801ef3617c56aa5cdbb0a2e5d32c7b6aeb045

See more details on using hashes here.

Supported by

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