Skip to main content

urban-workflow

English · Français

Workflow engine driven by a domain-specific language (DSL) — a Python port of Black-Beard-Sdk/Workflow (.NET), whose JSON output normalization system is replaced by urban-json (a JSLT engine): the messages produced by the engine are described by declarative .jslt templates that can be changed without redeploying.

A workflow in a few lines

NAME ValidationAchat VERSION 1
MATCHING (Type = 'achat')

DEFINE EVENT  DemandeSoumise 'une demande est déposée';
DEFINE RULE   MontantInferieur (DECIMAL seuil) 'montant sous le seuil';
DEFINE ACTION NotifierValideur (TEXT dossier)  'demande d''approbation';
DEFINE CONST  seuil_auto 500 'approbation automatique sous ce montant';

INITIALIZE WORKFLOW
    ON EVENT DemandeSoumise RECURSIVE SWITCH Tri

DEFINE STATE Tri 'aiguillage'
    ON EVENT DemandeSoumise
        WHEN MontantInferieur(seuil = seuil_auto)
            SWITCH Approuvee
        EXECUTE NotifierValideur(dossier = @Workflow.ExternalId)
            SWITCH EnValidation
;
DEFINE STATE Approuvee    'approbation automatique' ;
DEFINE STATE EnValidation 'en attente d''un valideur'
    EXPIRE AFTER 3 DAY SWITCH Expiree
;
DEFINE STATE Expiree      'sans réponse' ;
from urban_workflow import (
    FunctionRegistry, MemoryStorage, Workflow,
    WorkflowEngine, WorkflowFactory, WorkflowProcessor, WorkflowsConfig,
)
from urban_workflow.dsl import parse_config
from urban_workflow.outputs import default_memory_output

rules = FunctionRegistry("rule")
rules.add("MontantInferieur", lambda ctx, seuil: float(
    ctx.incoming_event.extended_datas.get("Montant", 0)) < seuil)

storage = MemoryStorage()
configs = WorkflowsConfig().add_document(parse_config(SCRIPT, rules=rules))
processor = WorkflowProcessor(configs, WorkflowFactory())
processor.load_existing_workflows_by_external_id = (
    lambda key: storage.get_by(Workflow, key, "external_id"))
processor.output_actions = default_memory_output(storage)
engine = WorkflowEngine(processor)

engine.evaluate_event({"Name": "DemandeSoumise", "ExternalId": "DA-42",
                       "Type": "achat", "Montant": 120})

Documentation

Guide Contents
docs/en/dsl-guide.md Writing a workflow: complete language reference — instance creation, SWITCH transitions, WHEN conditions, actions, expiration, fragments
docs/en/rules-guide.md Rules and scripts: DEFINE RULE … AS @script, multi-language ScriptRegistry, the expression language (operators, functions, NULL semantics), checks
docs/en/artifacts-guide.md JSON artifacts: DEFINE ARTIFACT … AS @schema USING @script, jslt scripts (urban-json), @artifact.Name in actions, schema validation
docs/en/integration-guide.md Using it in code: business rules, engine assembly, JSLT templates, output chain, technical events
docs/en/testing-guide.md Testing it: pure rules, configuration, templates, end-to-end scenarios
docs/analyse-portage.md (French) Analysis of the source project and the key design choices of the port

Playground

Standalone web components (editor with intellisense, diagram, schemas, scripts, simulation on the real engine…) that an application mounts as needed, and a page that assembles them — a separate distribution, urban-workflow-playground:

pip install urban-workflow-playground
urban-workflow-playground     # http://127.0.0.1:8777

Installation and development

pip install -e .[dev]
python3 -m pytest -q

Single core dependency: urban-json (which brings the ANTLR runtime used by the DSL parser). Python ≥ 3.10.

Porting status

Foundation, DSL (ANTLR grammars taken from the source), engine, urban-json templating and SQL persistence ([sql] extra, SQLAlchemy Core) are functional and tested (end-to-end scenarios DSL script → events → states → messages, lifecycle persisted in SQL), with GitHub Actions CI (Python 3.10 → 3.13 tests, ruff lint). Known bugs of the source engine are not reproduced — each one is covered by a dedicated test.

License

See LICENSE.

Metadata

Release files for urban-workflow 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for urban-workflow 0.2.1
File Size Uploaded Provenance Actions
urban_workflow-0.2.1.tar.gz 143.8 kB With provenance Details for urban_workflow-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for urban-workflow 0.2.1
File Interpreter ABI Platform Actions
urban_workflow-0.2.1-py3-none-any.whl Python 3 none any Details for urban_workflow-0.2.1-py3-none-any.whl

Total release size: 256.3 kB

Release files / urban_workflow-0.2.1.tar.gz

Download URL urban_workflow-0.2.1.tar.gz
Size 143.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8ab6209736817f8ec1223e2569d4e51f8731d2d328a3f85735903532dffe116d
BLAKE2b-256 checksum
How to use checksums
d167a227b61f520845ee0fd9483d1309dfbd6e241ff28f891d991ca7b25460d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / urban_workflow-0.2.1-py3-none-any.whl

Download URL urban_workflow-0.2.1-py3-none-any.whl
Size 112.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a32e0083bf169eaafcef3ee035d5bf840f825e16bbb7446e5e9b2cba13dd8022
BLAKE2b-256 checksum
How to use checksums
133c683d7a5688f9ebdbd69c19db34780eb3d524012523ee04fc4c64742c5bc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for urban-workflow 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for urban_workflow-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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