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, event schemas, deduplication keys (UNIQUE, DedupKey, automatic fallback), 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.3.0

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.3.0
File Size Uploaded Provenance Actions
urban_workflow-0.3.0.tar.gz 152.8 kB With provenance Details for urban_workflow-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 272.4 kB

Release files / urban_workflow-0.3.0.tar.gz

Download URL urban_workflow-0.3.0.tar.gz
Size 152.8 kB
Tags Source
SHA-256 checksum
How to use checksums
720bae8bcde33f741881886c3da9bef104f05815eadcfee562d775536c12b45a
BLAKE2b-256 checksum
How to use checksums
ca43aa3af68f38531ffa808be338640d4e3f5688e657afc4c53ff1e2844af8ce
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 12, 2026.

Transparency log

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

Download URL urban_workflow-0.3.0-py3-none-any.whl
Size 119.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6d879d661df6ed52c8651d5af329cf7bb4eb210a6bd092332bcd7eca5ee0ec4
BLAKE2b-256 checksum
How to use checksums
d52a9aad4e2794166d033c1858a191afbbfee66cadc7201593618adec93fab05
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 12, 2026.

Transparency log

Security for urban-workflow 0.3.0

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.3.0.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 12, 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