Skip to main content

Calculation framework

Project description

Mona

build coverage python pypi commits since last commit license code style

Mona is a calculation framework that provides persistent memoization and turns the Python call stack into a task dependency graph. The graph contains three types of edges: a task input depending on outputs of other tasks, a task creating new tasks, and a task output referencing outputs of other tasks.

Installing

Install and update using Pip.

pip install -U mona

A simple example

from mona import Mona, Rule

app = Mona()

@Rule
async def total(xs):
    return sum(xs)

@app.entry('fib', int)
@Rule
async def fib(n):
    if n <= 2:
        return 1
    return total([fib(n - 1), fib(n - 2)])
$ export MONA_APP=fib:app
$ mona init
Initializing an empty repository in /home/mona/fib/.mona.
$ mona run fib 5
7c3947: fib(5): will run
0383f6: fib(3): will run
b0287d: fib(4): will run
f47d51: fib(1): will run
9fd61c: fib(2): will run
45c92d: total([fib(2), fib(1)]): will run
2c136c: total([fib(3), fib(2)]): will run
521a8b: total([fib(4), fib(3)]): will run
Finished
$ mona graph
from fib import app, fib

with app.create_session() as sess:
    assert sess.eval(fib(5)) == sum(sess.eval([fib(4), fib(3)]))

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mona, version 0.2.6
Filename, size File type Python version Upload date Hashes
Filename, size mona-0.2.6-py3-none-any.whl (181.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size mona-0.2.6.tar.gz (51.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page