front#

Dispatching python functions as webservices, docker containers, and GUIs.

front is the core library that concrete UI frameworks (e.g. streamlitfront) build on: it compiles a configuration into a specification (SpecMakerBase), builds a tree of UI elements from it (ElementTreeMaker) and assembles the app (AppMaker). Crudifier and prepare_for_crude_dispatch make functions with complex arguments operable through string keys into stores.

Consider these three functions:

>>> def foo(a: int = 0, b: int = 0, c=0):
...     'This is foo. It computes something'
...     return (a * b) + c
>>> def bar(x, greeting='hello'):
...     'bar greets its input'
...     return f'{greeting} {x}'
>>> def confuser(a: int = 0, x: float = 3.14):
...     return (a ** 2) * x

The objective here is to be able to do this:

>>> app = dispatch_funcs([foo, bar, confuser], ...)

getting a deployable app that allows the user to operate with these three wonderful functions. The ellipses (...) are there to indicate that we may want to specify the kind of app we want (web-service, GUI, CLI…) as well as particular configurations for the latter.

Modules

app_maker

The AppMaker orchestrator that turns a configuration into a front app.

base

Base functions for front dispatching: prepare_for_dispatch chains the wrappers a UI needs.

crude

Crudify functions: let complex arguments be specified by string keys into stores.

dag

Crudify the variable nodes of a meshed DAG.

data_binding

Data-binding primitives that connect front element values to a backing state store.

elements

Front UI elements: bases, tree maker, and component implementer helpers.

py2pydantic

Bridge between plain Python functions and pydantic v2 models.

spec_maker_base

Base classes and conventions for building a FrontSpec from a configuration.

state

Stateful storage protocols and Forbidden errors used by front data bindings.

tools

Tools using front, or useful when using front.

types

Type aliases and lightweight dataclasses shared across front modules.

util

Signature and mapping utilities shared by the front modules.