Skip to content

Hochfrequenz/ebd_toolchain

Repository files navigation

EBD Toolchain

License: GPL Unittests status badge Coverage status badge Linting status badge Black status badge

🇩🇪 Dieses Repository enthält ein Python-Script, welches die beiden Python-Pakete ebdamame 🫛 und rebdhuhn 🐓 kombiniert, um aus .docx-Dateien maschinenlesbare Tabellen zur Modellierung von edi@energy Entscheidungsbäumen (EBD) zu extrahieren und anschließend in Form echter Graphen zu visualisieren. Diese Entscheidungsbäume sind Teil eines regulatorischen Regelwerks für die deutsche Energiewirtschaft und kommen in der Eingangsprüfung der Marktkommunikation zum Einsatz.

🇺🇸 This repository provides a Python script combining the libraries ebdamame and rebdhuhn in order to render edi@energy Entscheidungsbaumdiagramme (EBD) as both machine-readable tables as well as corresponding graphs in .svg and .uml format.

How to use EBD Toolchain

You can either run the toolchain via Python (requires Docker AND Python to be installed on your machine). Or you can run the entire toolchain in a docker container (requires only Docker).

Option A: Via Python + Kroki in a Docker Container

Install both libraries from PiPy:

pip install -r requirements.txt

Further, make sure to have a local instance of kroki up and running via docker (localhost:8125) as described in the rebdhuhn readme. Run the docker-desktop app on your local maschine and start the local kroki container via

docker-compose up -d

Execute the EBD toolchain script:

Run main.py using your IDE or inside a terminal session via

python main.py

Keep following the on-screen prompts given by the terminal and provide

  • the path of the directory containing the .docx edi@energy EBD file
  • the path to the output directory
  • the desired data formats .json, .dot, .svg or .puml.

Alternatively, the script can simply be executed using the single command

main.py -i <path to .doxc location> -o <output directory> -t json -t dot -t svg -t puml

where -i, -o and -t denote the input directory path, the output directory path and the supported data format, respectively.

Option B: Docker only (no Python required)

In this repository:

  1. create an .env file with a structure similar to env.example.
  2. set the environment variables to meaningful values.
  3. Login to GitHub Container Registry (GHCR); Use a Personal Access Token (PAT) to login that has access to this repository and at least read:packages scope
docker login ghcr.io -u YOUR_GITHUB_USERNAME
  1. create a docker-compose.yml that looks like this:

    services:
    kroki:
    image: yuzutech/kroki:0.24.1
    scrape-and-plot:
    build: .
    image: ghcr.io/hochfrequenz/ebd_toolchain:latest
    # If you run into 'manifest unknown' during docker pull, try replacing `:latest` with `:v1.2.3`.
    # where v1.2.3 is the latest version of the GHCR image, which can be found here:
    # https://github.com/Hochfrequenz/ebd_toolchain/pkgs/container/ebd_toolchain
    volumes:
    - ${EBD_DOCX_FILE}:/container/ebd.docx
    - ${OUTPUT_DIR}:/container/output
    # we need to set the KROKI_HOST and KROKI_PORT to the host and port of the kroki service
    # this is configurable here, but it does not need to be changed if the kroki service is named "kroki"
    environment:
    KROKI_PORT: "8000"
    KROKI_HOST: "kroki"
    # the .env file contains the parameter which the user can set
    env_file:
    - path: .env
    required: true # default is true

  2. then run:

docker compose up --abort-on-container-exit

You can find a Github Action with exactly this setup our edi_energy_mirror where it's used to automatically scrape the latest .docx files and pushes the results to machine-readable_entscheidungsbaumdiagramme which is then used by our frontend entscheidungbaumdiagramm.

How to use this Repository on Your Machine (for development)

Please follow the instructions in our Python Template Repository. And for further information, see the Tox Repository.

Contribute

You are very welcome to contribute to this template repository by opening a pull request against the main branch.

Related Tools and Context

This repository is part of the Hochfrequenz Libraries and Tools for a truly digitized market communication.