Skip to main content

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.

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.

[!NOTE] This library assumes the config file to follow some basic rules. For example, references by name are assumed to exist. If the config file passes the preCICE-built-in checks (precice-tools check) without errors, then it is also read correctly by this library. If precice-tools check does 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

  1. Clone this repository:
git clone https://github.com/precice-forschungsprojekt/config-graph
cd config-graph
  1. Create a new Python Virtual Environment (optional, but recommended):
python -m venv venv
source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  1. 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
│   └── 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 not yet published to any package registry. Nonetheless, it can still be imported into your pyproject.toml like so:

# …
dependencies = [
    "precice_config_graph @ git+https://github.com/precice-forschungsprojekt/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

precice_config_graph-1.0.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

precice_config_graph-1.0.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file precice_config_graph-1.0.0.tar.gz.

File metadata

  • Download URL: precice_config_graph-1.0.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for precice_config_graph-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9c50887083e602c2a6cbfae06bcd71e45f96217bf84d29e310f911500f688638
MD5 8de95c4e526fc826df7f65762bc17d40
BLAKE2b-256 c40dfd4953da3f32e17dd1ca74c815e86d24acbdd45707dee7556b5675d8f5b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for precice_config_graph-1.0.0.tar.gz:

Publisher: release.yml on precice/config-graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file precice_config_graph-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for precice_config_graph-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05a71d5cfba8add628f5fee8d3b91e6b63ad545a169d3aa053fb1874ca5fbd38
MD5 a0e3d2c225c031d958f7693ca310f018
BLAKE2b-256 48f6c7f9971bf7198be830388555eb3dd65b123996b71b94c4f5bd108ae3d279

See more details on using hashes here.

Provenance

The following attestation bundles were made for precice_config_graph-1.0.0-py3-none-any.whl:

Publisher: release.yml on precice/config-graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page