Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some graph rendering broken after 11.0 #75

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
if: steps.cache-ref-coverage.outputs.cache-hit != 'true'
run: |
cd ref
pytest --cov=dagrunner --cov-report=term --cov-report=html | tee coverage_output.txt; test ${PIPESTATUS[0]} -eq 0
pytest --maxfail=0 --continue-on-collection-errors --cov=dagrunner --cov-report=term --cov-report=html | tee coverage_output.txt || true

# TESTS (compare coverage)
############################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
</div>

<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
// pin mermaid version to 11.0: https://github.com/MetOffice/dagrunner/pull/75
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.0/dist/mermaid.esm.min.mjs';
mermaid.initialize({
startOnLoad: true,
flowchart: { useMaxWidth: false, htmlLabels: true, curve: 'basis' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
</div>

<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
// pin mermaid version to 11.0: https://github.com/MetOffice/dagrunner/pull/75
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.0/dist/mermaid.esm.min.mjs';
mermaid.initialize({
startOnLoad: true,
flowchart: { useMaxWidth: false, htmlLabels: true, curve: 'basis' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
</div>

<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
// pin mermaid version to 11.0: https://github.com/MetOffice/dagrunner/pull/75
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.0/dist/mermaid.esm.min.mjs';
mermaid.initialize({
startOnLoad: true,
flowchart: { useMaxWidth: false, htmlLabels: true, curve: 'basis' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
</div>

<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
// pin mermaid version to 11.0: https://github.com/MetOffice/dagrunner/pull/75
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.0/dist/mermaid.esm.min.mjs';
mermaid.initialize({
startOnLoad: true,
flowchart: { useMaxWidth: false, htmlLabels: true, curve: 'basis' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
</div>

<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
// pin mermaid version to 11.0: https://github.com/MetOffice/dagrunner/pull/75
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.0/dist/mermaid.esm.min.mjs';
mermaid.initialize({
startOnLoad: true,
flowchart: { useMaxWidth: false, htmlLabels: true, curve: 'basis' },
Expand Down
3 changes: 2 additions & 1 deletion dagrunner/utils/visualisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ class MermaidHTML:
</div>

<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
// pin mermaid version to 11.0: https://github.com/MetOffice/dagrunner/pull/75
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.0/dist/mermaid.esm.min.mjs';
mermaid.initialize({{
startOnLoad: true,
flowchart: {{ useMaxWidth: false, htmlLabels: true, curve: 'basis' }},
Expand Down
20 changes: 12 additions & 8 deletions docs/dagrunner.utils.networkx.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ see [function: dagrunner.utils.subset_equality](dagrunner.utils.md#function-subs
### Call Signature:

```python
get_subset_with_dependencies(graph: networkx.classes.digraph.DiGraph, filter_list: Iterable)
get_subset_with_dependencies(graph: networkx.classes.digraph.DiGraph, filter_list: Union[dict, Iterable[dict]])
```

Helper function to easily filter networkx graphs.
Expand All @@ -37,12 +37,12 @@ Args:

## function: `visualise_graph`

[Source](../dagrunner/utils/networkx.py#L320)
[Source](../dagrunner/utils/networkx.py#L325)

### Call Signature:

```python
visualise_graph(graph: networkx.classes.digraph.DiGraph, backend='mermaid', collapse_properties: Iterable = None, title=None, output_filepath=None, **kwargs)
visualise_graph(graph: networkx.classes.digraph.DiGraph, backend: str = 'mermaid', collapse_properties: Union[str, Iterable[str]] = None, title: str = None, output_filepath: str = None, **kwargs)
```

Visualise a networkx graph.
Expand All @@ -56,14 +56,15 @@ Args:
- `graph`: The graph to visualise.
- `backend`: The backend to use for visualisation. Supported values include
'mermaid' (javascript, default) and 'matplotlib'.
- `collapse_properties`: A list of properties to collapse nodes on. Only
See [visualise_graph_mermaid](#function-visualise_graph_mermaid).
- `collapse_properties`: One or more properties to collapse nodes on. Only
supported for nodes represented by dataclasses right now.
- `title`: The title of the visualisation.
- `output_filepath`: The output filepath to save the visualisation to.

## function: `visualise_graph_matplotlib`

[Source](../dagrunner/utils/networkx.py#L116)
[Source](../dagrunner/utils/networkx.py#L117)

### Call Signature:

Expand All @@ -84,19 +85,22 @@ Args:

## function: `visualise_graph_mermaid`

[Source](../dagrunner/utils/networkx.py#L214)
[Source](../dagrunner/utils/networkx.py#L215)

### Call Signature:

```python
visualise_graph_mermaid(graph: networkx.classes.digraph.DiGraph, node_info_lookup: dict = None, title: str = None, output_filepath: str = None, group_by: str = None, label_by: Iterable = None)
visualise_graph_mermaid(graph: networkx.classes.digraph.DiGraph, node_info_lookup: dict = None, title: str = None, output_filepath: str = None, group_by: Union[str, Iterable[str]] = None, label_by: Union[str, Iterable[str]] = None)
```

Visualise a networkx graph using matplotlib.
Visualise a networkx graph using mermaid.

Args:
- `graph`: The graph to visualise.
- `node_info_lookup`: A dictionary mapping nodes to their information.
- `title`: The title of the visualisation.
- `output_filepath`: The output filepath to save the visualisation to.
- `group_by`: One or more property to group nodes by (i.e.
[subgraph](https://mermaid-js.github.io/mermaid/#/subgraph)).
- `label_by`: One or more property to label visualisation nodes by.

6 changes: 3 additions & 3 deletions docs/dagrunner.utils.visualisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ MermaidHTML(mermaid, table=None)

### function: `__init__`

[Source](../dagrunner/utils/visualisation.py#L321)
[Source](../dagrunner/utils/visualisation.py#L322)

#### Call Signature:

Expand All @@ -146,7 +146,7 @@ Initialize self. See help(type(self)) for accurate signature.

### function: `__str__`

[Source](../dagrunner/utils/visualisation.py#L324)
[Source](../dagrunner/utils/visualisation.py#L325)

#### Call Signature:

Expand All @@ -158,7 +158,7 @@ Return str(self).

### function: `save`

[Source](../dagrunner/utils/visualisation.py#L329)
[Source](../dagrunner/utils/visualisation.py#L330)

#### Call Signature:

Expand Down