A Library that builds a graph from a preCICE configuration file for validation and visualization purposes
Project description
preCICE Config Graph
A Python library that builds a graph from a preCICE configuration file for validation and visualization purposes and enables to recreate a precice-config.xml from it.
How does this differ from the preCICE Config-Visualizer? The graph built by this library is not (directly) meant to be displayed. The focus is on building a graph that represents the structure of a preCICE configuration in a way that is useful in checking for logical errors. This logic can also be used to generate a precice-config.xml from a given set of nodes.
[!NOTE] This library assumes the config file to adhere to preCICE conguration-file syntax. For example, references by name are assumed to exist. If the config file passes the preCICE-built-in checks (
precice-tools checkbefore preCICE version 3.3.0;precice-config-validateafter preCICE version 3.3.0) without errors, then it is also read correctly by this library. Ifprecice-config-validatedoes not succeed, the behavior of this library is undefined (it will probably crash).
Requirements
- Python 3.10+
- Pip
- Git for cloning the repository
- PyQt6
Installation
- Clone this repository:
git clone https://github.com/precice/config-graph
cd config-graph
- Create a new Python Virtual Environment (optional, but recommended):
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
- Install required dependencies:
pip install .
Project Structure
config-graph
├── .github, .idea, etc…
│
├── docs # Useful information for understanding how this library works
│ └── …
│
├── debugging # Utility for debugging graph generation. See section in this README on the topic.
│ └── cli.py # Call this script to visualize a provided config
│
├── precice_config_graph # Main library files
│ ├── edges.py # Definition of edge types
│ ├── graph.py # Main logic for building the graph from parsed XML
│ ├── nodes.py # Definition of node types
│ ├── enums.py # Definition enums used for node-creation
│ └── xml_processing.py # preCICE-specific utilities for reading XML files correctly
│
├── test # All files for automated testing
│ └── example-configs # Contains sample configurations that are then tested one by one
│ └── <case-name>
│ ├── precice-config.xml
│ └── test.py # File that tests the graph that is produced from precice-config.xml for validity
│
├── .gitignore, LICENSE, README.md
│
├── pyproject.toml # Project configuration (dependencies etc.)
└── shell.nix # Dependencies for anyone using NixOS / the nix-package manager. Should be replaced by a flake in the future.
Using in your project
This library is published to PyPi as precice-config-graph.
It can be installed via
pip install precice-config-graph
Otherwise, it can also be imported into your pyproject.toml like so:
# …
dependencies = [
"precice_config_graph @ git+https://github.com/precice/config-graph.git",
# …
]
# …
Then, run pip install . in your project. To build a graph, use the following code snippet:
from precice_config_graph import graph, xml_processing
path = "./some/path/to/your/precice-config.xml"
root = xml_processing.parse_file(path)
G = graph.get_graph(root)
# use, traverse inspect the graph
# to view the graph
graph.print_graph(G)
Debugging graph generation
This module includes a small utility that helps with debugging the output graph. You can pass a custom
precice-config.xml and it displays the graph it built in a pop-up window.
To get started, run
python debugging/cli.py "./path-to-your/precice-config.xml"
Graph structure
The types of nodes and edges are documented under docs/Nodes-and-Edges.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file precice_config_graph-2.0.5.tar.gz.
File metadata
- Download URL: precice_config_graph-2.0.5.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
616a1d0a2ab7b37bb156536f78d28c89595dd90bdc5ce802fa23d36cf323d5ee
|
|
| MD5 |
18486b00d571ff9da9578c6d9ac8bf48
|
|
| BLAKE2b-256 |
8ba9c0fb849a86c2645ba471633d6045b3e7858c3a07f8d5a9c22276f6af090e
|
Provenance
The following attestation bundles were made for precice_config_graph-2.0.5.tar.gz:
Publisher:
release.yml on precice/config-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
precice_config_graph-2.0.5.tar.gz -
Subject digest:
616a1d0a2ab7b37bb156536f78d28c89595dd90bdc5ce802fa23d36cf323d5ee - Sigstore transparency entry: 831858157
- Sigstore integration time:
-
Permalink:
precice/config-graph@0e025405e2a7e92cb1c388b4ce8148a60ae9f30e -
Branch / Tag:
refs/tags/v2.0.5 - Owner: https://github.com/precice
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0e025405e2a7e92cb1c388b4ce8148a60ae9f30e -
Trigger Event:
push
-
Statement type:
File details
Details for the file precice_config_graph-2.0.5-py3-none-any.whl.
File metadata
- Download URL: precice_config_graph-2.0.5-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eef9913d5ef8ad40debf4362eec6c65a4de3f08a4f2a218c66ff5cb1d00411c
|
|
| MD5 |
25aa533a6c0a863d0be41805d7920998
|
|
| BLAKE2b-256 |
cdcb6c575cb3165a3c8d4577b55334885f6d043316923624ffae5d0d3e534088
|
Provenance
The following attestation bundles were made for precice_config_graph-2.0.5-py3-none-any.whl:
Publisher:
release.yml on precice/config-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
precice_config_graph-2.0.5-py3-none-any.whl -
Subject digest:
6eef9913d5ef8ad40debf4362eec6c65a4de3f08a4f2a218c66ff5cb1d00411c - Sigstore transparency entry: 831858171
- Sigstore integration time:
-
Permalink:
precice/config-graph@0e025405e2a7e92cb1c388b4ce8148a60ae9f30e -
Branch / Tag:
refs/tags/v2.0.5 - Owner: https://github.com/precice
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0e025405e2a7e92cb1c388b4ce8148a60ae9f30e -
Trigger Event:
push
-
Statement type: