Skip to content

Fill in missing task input/output names from edge data mappings - #32

Merged
loichuder merged 3 commits into
mainfrom
add-missing-ports
Oct 8, 2026
Merged

loichuder merged 3 commits into
mainfrom
add-missing-ports

Conversation

@loichuder

@loichuder loichuder commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

PR summary

See #29 (comment)

When a task cannot be imported, it cannot generate the ports to which links point. In this PR, I add some code before the SvgTask generation: its aim is to gather all source outputs/target inputs from the edges of the graph.

Then, when building SvgTask class of a node, the target inputs are added to the input names and similarly, the source outputs are added to the output names.

Then,

Same for sources and output names.

Now, there is still the case where the input names could be imported and the targets are not included. This is allowed by Ewoks but we should probably show something in this case. Again, for another PR.

Effect for workflow 1

Before After
workflow1 json workflow1 json

AI Disclosure

  • Claude code used to commit the code, generate the commit message and deduplication of warnings

@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread src/ewoksdraw/utils.py
from .models import DataMapping


def get_valid_data_mappings(ewoks_graph: TaskGraph) -> list[DataMapping]:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

New util to go through data mappings in the new get_edge_sources_and_targets function

Comment thread src/ewoksdraw/graph_to_svg.py Outdated
Comment on lines +29 to +32
inputs = set(node_input.name for node_input in signature.inputs)
# Add eventual missing target inputs
inputs |= set(target_inputs_per_node[node_id])
outputs = set(node_output.name for node_output in signature.outputs)

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.

If I remember correctly: set(x for x in y) generate ordering based on the hash seed.
https://docs.python.org/3/reference/datamodel.html#object.__hash__
If I'm correct, I'd rather have a deterministic rendering of the figures.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure.

We can use a dict instead. It will be ordered according to insertion order and will still remove duplicates.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See 4b1732e

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.

Looks good to me

Comment thread src/ewoksdraw/utils.py
Comment on lines +43 to +53
def get_edge_sources_and_targets(
graph: TaskGraph,
) -> tuple[dict[str, list[str]], dict[str, list[str]]]:
data_mappings = get_valid_data_mappings(graph)
sources: dict[str, list[str]] = defaultdict(list[str])
targets: dict[str, list[str]] = defaultdict(list[str])
for mapping in data_mappings:
sources[mapping.source].append(mapping.source_output)
targets[mapping.target].append(mapping.target_input)

return sources, targets

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.

If you want to avoid the double warning.
You can instead pass the data_mapping as a parameter and make the helper function a pure transformation.

def get_edge_sources_and_targets(
    data_mappings: list[DataMapping],
) -> tuple[dict[str, list[str]], dict[str, list[str]]]:

Let build_svg_task_group() / convert_ewoks_to_elk_graph() receive the mappings
And finnaly called in once in graph_to_svg():

def graph_to_svg(graph: TaskGraph, output_path: str | Path) -> None:
    data_mappings = get_valid_data_mappings(graph)

    task_group = build_svg_task_group(
        graph,
        data_mappings,
    )

    elk_graph_before_layout = convert_ewoks_to_elk_graph(
        graph,
        task_group.extract_task_sizes(),
        task_group.extract_input_positions(),
        task_group.extract_output_positions(),
        data_mappings,
    )

Having the warning twice might be better :). You're the judge on that one.

@loichuder loichuder Sep 28, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you mean this would be an alternative to b3d0dec ?

Or that there is still a duplication of warnings even with b3d0dec?

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.

you are right I got lost in PR. It's fine with b3d0dec

@loichuder
loichuder requested a review from LudoBroche October 7, 2026 15:05

@LudoBroche LudoBroche 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.

Perfect

@loichuder
loichuder merged commit cabcdc7 into main Oct 8, 2026
6 checks passed
@loichuder
loichuder deleted the add-missing-ports branch October 8, 2026 06:39
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.

2 participants