Skip to content

exit_hook list inheritance de-duplicates duplicate lines #101

Description

@colonesej

Summary:

When exit_hook is passed as a list of strings across inherited nodes (Suite to Family), duplicate lines are removed.
This strips user-provided hook content that may intentionally repeat commands.

I don't see why we need to avoid duplication. Maybe @jinmannwong had some use case in mind?

This raise some unintended consequences with scripts passed as lists where boilerplate lines like fi (the markup of the end of a if-else block) gets removed.

Example

from pyflow import Suite, Family, Task

parent_line = "echo duplicate_line"
child_lines = ["echo duplicate_line", "echo post_cleanup"]

with Suite("S", exit_hook=parent_lines):
    with Family("f", exit_hook=child_lines) as f:
        t1 = Task("t1")

expected = [
    "echo pre_cleanup",
    "echo duplicate_line",
    "echo duplicate_line",
    "echo post_cleanup",
]

print("Expected:", expected)
# > Expected: ['echo pre_cleanup', 'echo duplicate_line', 'echo duplicate_line', 'echo post_cleanup']
print("Actual family:", f._exit_hook)
# > Actual family: ['echo duplicate_line', 'echo post_cleanup']
print("Actual task:", t1._exit_hook)
# > Actual task: ['echo duplicate_line', 'echo post_cleanup']

# Fails today because duplicate_line is deduplicated
assert f._exit_hook == expected
assert t1._exit_hook == expected

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions