-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure no nodes can depend on themselves even when transcoding is used (
#3812) * Factor out transcoding helpers into a private module Signed-off-by: Ivan Danov <[email protected]> * Ensure node input/output validation doesn't allow transcoded self-loops Signed-off-by: Ivan Danov <[email protected]> * Updated release note to avoid github warning Signed-off-by: Elena Khaustova <[email protected]> --------- Signed-off-by: Ivan Danov <[email protected]> Signed-off-by: Elena Khaustova <[email protected]> Co-authored-by: Elena Khaustova <[email protected]>
- Loading branch information
1 parent
28277a6
commit 2915024
Showing
9 changed files
with
61 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import Tuple | ||
|
||
TRANSCODING_SEPARATOR = "@" | ||
|
||
|
||
def _transcode_split(element: str) -> Tuple[str, str]: | ||
"""Split the name by the transcoding separator. | ||
If the transcoding part is missing, empty string will be put in. | ||
Returns: | ||
Node input/output name before the transcoding separator, if present. | ||
Raises: | ||
ValueError: Raised if more than one transcoding separator | ||
is present in the name. | ||
""" | ||
split_name = element.split(TRANSCODING_SEPARATOR) | ||
|
||
if len(split_name) > 2: # noqa: PLR2004 | ||
raise ValueError( | ||
f"Expected maximum 1 transcoding separator, found {len(split_name) - 1} " | ||
f"instead: '{element}'." | ||
) | ||
if len(split_name) == 1: | ||
split_name.append("") | ||
|
||
return tuple(split_name) # type: ignore | ||
|
||
|
||
def _strip_transcoding(element: str) -> str: | ||
"""Strip out the transcoding separator and anything that follows. | ||
Returns: | ||
Node input/output name before the transcoding separator, if present. | ||
Raises: | ||
ValueError: Raised if more than one transcoding separator | ||
is present in the name. | ||
""" | ||
return _transcode_split(element)[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters