Repository navigation
Fill in missing task input/output names from edge data mappings - #32
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| from .models import DataMapping | ||
|
|
||
|
|
||
| def get_valid_data_mappings(ewoks_graph: TaskGraph) -> list[DataMapping]: |
There was a problem hiding this comment.
New util to go through data mappings in the new get_edge_sources_and_targets function
| 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Sure.
We can use a dict instead. It will be ordered according to insertion order and will still remove duplicates.
| 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
you are right I got lost in PR. It's fine with b3d0dec
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4511c87 to
b3d0dec
Compare
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
SvgTaskgeneration: its aim is to gather all source outputs/target inputs from the edges of the graph.Then, when building
SvgTaskclass 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
AI Disclosure