Skip to main content

dagapp

Making apps from DAGs by just snapping your fingers

To install: pip install dagapp

What's a DAG?

What's an app?

This is a beautiful example of a DAG app woven into to an article: rent-or-buy article+app The app serves as an illustration of the article and the article as the documentation of the app. (Note: It was a lot more "beautiful" in 2014, but they changed the graphic now! Boo!)

Here's another example of interactive calculators.

What dagapp wants to become is a framework to generate such effective communication, effortlessly.

Enough theory. Here's how it works...

A simple example

First make a DAG

from meshed.dag import DAG


def b(a):
    return 2**a


def d(c):
    return 10 - (5**c)


def result(b, d):
    return b * d


dag = DAG((b, d, result))

Then make an app

from dagapp.base import dag_app
from functools import partial

dags = [dag]

if __name__ == "__main__":
    app = partial(dag_app, dags=dags)
    app()

Then run the app

>>> streamlit run example.py

... and this is what you get

png

A more complicated example

Let's say we want to create two different DAGs and view them on the same streamlit page, keep all the non-root nodes static and represent the number inputs for one of the DAGs as sliders. We will use functions defined in configs_example.py for this example.

Define the DAGs

To start we can create our DAGs just like in the previous example.

profit_dag = DAG((user_clicks, rev, cost, profit))
revenue_dag = DAG((partners, clicks, revenue))

dags = [profit_dag, revnue_dag]

Define the configs

Next we can define some configs for these DAGs. These configs should be a list of dictionaries, with each dictionary representing the configs for each DAG. Each config must contain a dictionary arg_types that matches each of the root nodes in the DAG to an input type (currently the options are: num, slider, text, list, dict). If arg_types is not explicitly defined, then it will try to infer from type annotations in the function definitions, and then default to num. If slider is defined as the arg_type for any of the root nodes, then another dictionary ranges must be defined that matches each of the nodes designated to be slider with a min and max value for that slider. The configs for this example can be seen below.

configs = [
    dict(
        arg_types=dict(
            a="num",
            b="num",
            cost_per_click="num",
            revenue_per_click="num",
        ),
    ),
    dict(
        arg_types=dict(
            max_partners="slider",
            cost_per_click="slider",
            price_elasticity="slider",
            partners="slider",
            clicks_per_partner="slider",
        ),
        ranges=dict(
            max_partners=[0, 2000],
            cost_per_click=[0.0, 1.0],
            price_elasticity=[0, 200],
            partners=[0, 1500],
            clicks_per_partner=[0.0, 10.0],
        ),
    ),
]

Make the app

We can now make our app in a similar manner as the previous example, this time defining our configs, as well as defining StaticPageFunc as our page factory to keep all non-root nodes static.

from dagapp.page_funcs import StaticPageFunc

if __name__ == "__main__":
    app = partial(dag_app, dags=dags, page_factory=StaticPageFunc, configs=configs)
    app()

Run the app

>>> streamlit run configs_example.py

... and this is what you get

png png

Download files

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

Source Distribution

dagapp-0.1.22.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

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

dagapp-0.1.22-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file dagapp-0.1.22.tar.gz.

File metadata

  • Download URL: dagapp-0.1.22.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dagapp-0.1.22.tar.gz
Algorithm Hash digest
SHA256 b535d39f46dfea0bb7b09663853abd360b7bf405518e28cbc651ef9c591eeb4e
MD5 4553c5ffa15d3967a83eb6e8ee70914d
BLAKE2b-256 9d2fb33d8588def4a7d3ad1fbf0a747e5aade2203a640d89df71203f39cc200d

See more details on using hashes here.

File details

Details for the file dagapp-0.1.22-py3-none-any.whl.

File metadata

  • Download URL: dagapp-0.1.22-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dagapp-0.1.22-py3-none-any.whl
Algorithm Hash digest
SHA256 26964ce254e77bb0b98dd07ca694d7b0a2d75bdc4114476c1388f4c588e6a8f3
MD5 401d8c20283722f320acae1d3894dd81
BLAKE2b-256 22011c902305efa1c1d0d40b6136c3e77b960b97eef8613360f42f8745d49273

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.22 This release

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

1 file

0.1.18

1 file

0.1.17

1 file

0.1.16

1 file

0.1.15

1 file

0.1.14

1 file

0.1.13

1 file

0.1.12

1 file

0.1.11

1 file

0.1.10

1 file

0.1.9

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

0.0.3

2 files

0.0.2

2 files

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