Skip to content

Refactor edge names - #38

Merged
loichuder merged 1 commit into
import-error-linksfrom
refactor-edge-names
Oct 8, 2026
Merged

loichuder merged 1 commit into
import-error-linksfrom
refactor-edge-names

Conversation

@loichuder

@loichuder loichuder commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

PR summary

Fix #35 (comment)

I extract the edge naming into util functions, removing the implicit coupling between the creation of ports and of edges.

I also add util functions at the same place to extract the task_id as mentioned in my previous comment. The coupling is still implicit but at least creation and extraction live at the same place.

I didn't go further since I think the refactoring of the layouting will bring opportunities for more elegant refactoring.

AI Disclosure

  • No AI used

@loichuder
loichuder added this pull request to stack #36 September 15, 2026 07:56
ports: list[ElkPort] = []

for index, position in enumerate(positions):
for index, position in enumerate(input_positions):

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.

For this refactoring, it was easier to _convert_positions_to_elk_ports to remove the need for a id_prefix.

Personally, I don't mind the added duplication since I find the code more readable like this. But I can refactor further if you wish.

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.

I'm also in favor of the duplication. Makes the input/target and output/source semantic explicit.

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Feel free to merge after considering comment about the string split.

ports: list[ElkPort] = []

for index, position in enumerate(positions):
for index, position in enumerate(input_positions):

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.

I'm also in favor of the duplication. Makes the input/target and output/source semantic explicit.

Comment thread src/ewoksdraw/utils.py Outdated


def get_task_id_from_target_id(target_id: str) -> str:
return target_id.split(".input.")[0]

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 for a funky reason we have a task ID named : "pipeline.output.normalize" we build:
"pipeline.output.normalize.output.result".
get_task_id_from_source_id will return the wrong task id : "pipeline".

Maybe better to perform right split :

def get_task_id_from_source_id(source_id: str) -> str:
    return source_id.rsplit(".output.", 1)[0]

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.

Good call!

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.

Actually, you have the same problem if the input is named something like input.value or similar.

I'll implement the suggestion but I think we should rethink this part later.

@loichuder
loichuder force-pushed the refactor-edge-names branch 3 times, most recently from bda8756 to 80bed6b Compare September 28, 2026 09:10
@loichuder
loichuder force-pushed the refactor-edge-names branch from 80bed6b to 862b389 Compare October 8, 2026 06:39
@loichuder
loichuder merged commit cabcdc7 into main Oct 8, 2026
5 checks passed
@loichuder
loichuder deleted the refactor-edge-names 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