Skip to content

StepMutator bug in attaching decorators affecting 2.19.33 #3258

Description

@saikonen

With the changes to _process_late_attached_decorator in #3238 some card attaching custom decorators have stopped working due to duplicate inits with logs like

[@card WARNING] Multiple `@card` decorator have been annotated with duplicate ids : test_card. `current.card['test_card']` will not work
[@card WARNING] `current.card['test_card']` is not present. Please set the `id` argument in @card to 'test_card' to access `current.card['test_card']`. `current.card['test_card']` will return an empty `list` which is not referenced to `current.card` object.

Example flow for repro:

from metaflow import FlowSpec, step, card, current, conda_base
from metaflow.user_decorators.user_step_decorator import StepMutator


class AddTestCard(StepMutator):
    def mutate(self, mutable_step):
        from metaflow import card as card_deco

        mutable_step.add_decorator(card_deco, deco_kwargs={"id": "test_card"})

@conda_base
class ReproFlow(FlowSpec):
    @card
    @AddTestCard()
    @step
    def start(self):
        print(type(current.card["test_card"]))
        self.next(self.end)

    @step
    def end(self):
        pass


if __name__ == "__main__":
    ReproFlow()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions