Skip to content

[Feature]: Flat Converter from ewoks execution graph to ELK layout graph #17 - #18

Merged
LudoBroche merged 14 commits into
mainfrom
17-feature-flat-converter-from-ewoks-execution-graph-to-elk-layout-graph
Aug 5, 2026
Merged

[Feature]: Flat Converter from ewoks execution graph to ELK layout graph #17#18
LudoBroche merged 14 commits into
mainfrom
17-feature-flat-converter-from-ewoks-execution-graph-to-elk-layout-graph

Conversation

@LudoBroche

Copy link
Copy Markdown
Member

Tip

Description
Implements convert_ewoks_to_elk_graph, converting a flat ewoks TaskGraph into an ELK JSON layout graph (children with width/height, edges with sources/targets, and layoutOptions sourced from constants.py).

Closes #17

Note

Changes Made

  • layout/elk_converter.py: convert_ewoks_to_elk_graph(ewoks_graph, task_sizes) -> ElkGraph.
  • svg/svg_task_group.py: new SvgTaskGroup(SvgGroup) — SvgClass to group tasks together will allow to perform various operation on all the tasks. For example in this context extract all the tasks sizes.
  • ewoksdraw/__init__.py: added build_svg_task_group(ewoks_graph) -> SvgTaskGroup, hiding the _get_all_node_inputs/_get_all_task_output_names node-to-SvgTask plumbing behind a single call.
  • examples/convert_ewoks_to_elk_graph.py: runnable usage example.
  • tests/test_elk_converter.py: unit tests covering top-level structure, children/task_sizes correspondence, single vs. multi data_mapping edges, empty graphs, counts across all ewokscore example graphs, and the task_sizes mismatch validation.

Warning

Note to Reviewer(s)

  • Scope matches the issue: flat mapping only, no subworkflow expansion, no ELK solver invocation, no SVG rendering of the ELK result.
  • ports were deliberately left out of scope — links are node-to-node, not port-to-port. This converter doesn't need it for layout purposes.
  • task_sizes is a required, caller-supplied input rather than computed internally, so the ELK layout logic stays independent of the svg package.

@LudoBroche LudoBroche self-assigned this Jul 8, 2026
@LudoBroche

Copy link
Copy Markdown
Member Author

Running the example looks like that :

pixi run python examples/convert_ewoks_to_elk_graph.py

Ewoks Graph:

{'task1': {'default_inputs': [{'name': 'a', 'value': 1}],
           'task_identifier': 'ewokscore.tests.examples.tasks.condsumtask.CondSumTask',
           'task_type': 'class'},
 'task2': {'default_inputs': [{'name': 'b', 'value': 1}],
           'task_identifier': 'ewokscore.tests.examples.tasks.condsumtask.CondSumTask',
           'task_type': 'class'},
 'task3': {'default_inputs': [{'name': 'b', 'value': 1}],
           'task_identifier': 'ewokscore.tests.examples.tasks.condsumtask.CondSumTask',
           'task_type': 'class'}}
[('task1',
  'task2',
  {'conditions': [{'source_output': 'too_small', 'value': True}],
   'data_mapping': [{'source_output': 'result', 'target_input': 'a'}]}),
 ('task2',
  'task3',
  {'conditions': [{'source_output': 'too_small', 'value': True}],
   'data_mapping': [{'source_output': 'result', 'target_input': 'a'}]}),
 ('task3',
  'task1',
  {'conditions': [{'source_output': 'too_small', 'value': True}],
   'data_mapping': [{'source_output': 'result', 'target_input': 'a'}]})]

TaskSizes data structure:

{'task1': (54.232, 63.0), 'task2': (54.232, 63.0), 'task3': (54.232, 63.0)}

ELK Graph:

{'children': [{'height': 63.0, 'id': 'task1', 'width': 54.232},
              {'height': 63.0, 'id': 'task2', 'width': 54.232},
              {'height': 63.0, 'id': 'task3', 'width': 54.232}],
 'edges': [{'id': 'edge_task1_task2_0',
            'sources': ['task1'],
            'targets': ['task2']},
           {'id': 'edge_task2_task3_0',
            'sources': ['task2'],
            'targets': ['task3']},
           {'id': 'edge_task3_task1_0',
            'sources': ['task3'],
            'targets': ['task1']}],
 'id': 'root',
 'layoutOptions': {'elk.layered.edgeRouting.splines.mode': 'CONSERVATIVE_SOFT',
                   'org.eclipse.elk.algorithm': 'layered',
                   'org.eclipse.elk.direction': 'RIGHT',
                   'org.eclipse.elk.edgeRouting': 'SPLINES',
                   'org.eclipse.elk.layered.spacing.nodeNodeBetweenLayers': 80,
                   'org.eclipse.elk.spacing.edgeEdge': 20,
                   'org.eclipse.elk.spacing.nodeNode': 60}}

@LudoBroche LudoBroche changed the title Issue #17 - Added elk_converter helper and svg_task_group [Feature]: Flat Converter from ewoks execution graph to ELK layout graph #17 Jul 8, 2026
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.64706% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/ewoksdraw/svg/svg_task_group.py 96.66% 1 Missing ⚠️
src/ewoksdraw/svg/svg_task_io.py 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@LudoBroche
LudoBroche requested a review from a team July 8, 2026 17:44
@LudoBroche
LudoBroche marked this pull request as ready for review July 9, 2026 07:39

@loichuder loichuder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First review round.

I don't understand how the introduction of SvgTaskGroup fits in the PR. Is it needed for the Elk layouting?

Comment thread src/ewoksdraw/config/constants.py Outdated
Comment thread src/ewoksdraw/layout/__init__.py Outdated
Comment thread src/ewoksdraw/layout/elk_converter.py Outdated
Comment thread src/ewoksdraw/layout/elk_converter.py Outdated
Comment thread src/ewoksdraw/svg/svg_task_group.py Outdated
@LudoBroche

LudoBroche commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

First review round.

I don't understand how the introduction of SvgTaskGroup fits in the PR. Is it needed for the Elk layouting?

Yes, for the routing with ELK, I need to have the sizes of each task's box [{task_id:sizes},...].
I thought the best API would be to do it from a tasks group class helper function.
Knowing also that in the future we will have to do more (i.e., position all the tasks correctly).

@LudoBroche
LudoBroche force-pushed the 17-feature-flat-converter-from-ewoks-execution-graph-to-elk-layout-graph branch from 9ff13f8 to cba93fa Compare July 24, 2026 08:39
@LudoBroche
LudoBroche requested a review from loichuder July 24, 2026 08:55
Comment thread CHANGELOG.md Outdated
Comment thread .gitignore
Comment thread src/ewoksdraw/svg/svg_task_group.py Outdated
Comment thread src/ewoksdraw/svg/svg_task_group.py
Comment thread src/ewoksdraw/layout/elk_converter.py Outdated
Comment thread src/ewoksdraw/layout/elk_converter.py Outdated
Comment thread src/ewoksdraw/tests/test_graph_to_svg.py Outdated
@LudoBroche
LudoBroche force-pushed the 17-feature-flat-converter-from-ewoks-execution-graph-to-elk-layout-graph branch from 10f060f to 9794bca Compare July 29, 2026 12:02
@LudoBroche LudoBroche added this to the ewoksdraw 1.0 release milestone Jul 29, 2026
@LudoBroche
LudoBroche requested a review from loichuder July 29, 2026 12:19
@LudoBroche

Copy link
Copy Markdown
Member Author

@loichuder please have a look at the latest changes:

What change:

  1. Added pixi support in pyproject.toml with a couple of useful tasks + ultra minimal read-me to keep track of the main pixi commands
  2. mypy was complaining about the SvgGroup being too generic.
  3. Added type arguments example:
group: SvgGroup[SvgLinkCubicBezier] = SvgGroup()
group.add_elements([link])
class SvgTaskGroup(SvgGroup[SvgTask]):
  1. Rewrote the CHANGELOG.md

Comment thread src/ewoksdraw/config/constants.py Outdated
Comment thread src/ewoksdraw/svg/svg_group.py
Comment thread README.md Outdated
Comment thread CHANGELOG.md Outdated
Comment thread .gitignore Outdated
Comment thread src/ewoksdraw/__init__.py
Comment thread src/ewoksdraw/tests/test_graph_to_svg.py Outdated
Comment thread src/ewoksdraw/layout/elk_converter.py
LudoBroche and others added 4 commits July 31, 2026 08:47
Co-authored-by: Loïc Huder <42204205+loichuder@users.noreply.github.com>
Co-authored-by: Loïc Huder <42204205+loichuder@users.noreply.github.com>
Co-authored-by: Loïc Huder <42204205+loichuder@users.noreply.github.com>
@LudoBroche
LudoBroche requested a review from loichuder August 5, 2026 07:29
@LudoBroche
LudoBroche merged commit 006049b into main Aug 5, 2026
6 checks passed
@LudoBroche
LudoBroche deleted the 17-feature-flat-converter-from-ewoks-execution-graph-to-elk-layout-graph branch August 5, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Flat Converter from ewoks execution graph to ELK layout graph

2 participants