Skip to content

Conversation

valayDave
Copy link
Collaborator

@valayDave valayDave commented Jul 22, 2025

When doing something like :

from metaflow import project

....

mymutableflow.add_decorator(
project, deco_kwargs={"name":"abc"})

Metaflow breaks with the error :

 File ".../metaflow/flowspec.py", line 312, in _process_config_decorators
    deco.pre_mutate(mutable_flow)
  File "mydeco.py", line 67, in pre_mutate
    mutable_flow.add_decorator(
  File ".../metaflow/user_decorators/mutable_flow.py", line 409, in add_decorator
    _add_flow_decorator(
  File ".../metaflow/user_decorators/mutable_flow.py", line 353, in _add_flow_decorator
      d for d in self._flow_cls._flow_decorators if d.name == flow_deco.name
                                                  ^^^^^^
AttributeError: 'str' object has no attribute 'name'

This is because we dont handle the _flow_cls._flow_decorators in the right way (as a dict instead of list)

When doing something like :
```
from metaflow import project

....

mymutableflow.add_decorator(
project, deco_kwargs={"name":"abc"})
```

Metaflow breaks with the error :

```
 File ".../metaflow/flowspec.py", line 312, in _process_config_decorators
    deco.pre_mutate(mutable_flow)
  File "mydeco.py", line 67, in pre_mutate
    mutable_flow.add_decorator(
  File ".../metaflow/user_decorators/mutable_flow.py", line 409, in add_decorator
    _add_flow_decorator(
  File ".../metaflow/user_decorators/mutable_flow.py", line 353, in _add_flow_decorator
      d for d in self._flow_cls._flow_decorators if d.name == flow_deco.name
                                                  ^^^^^^
AttributeError: 'str' object has no attribute 'name'
```

This is because we dont parse the _flow_cls._flow_decorators in the right way (as a dict instead of list)
@valayDave valayDave changed the title [bug fix] fix subtle bug from netflix/metaflow#2463 (#2498) [bug fix] fix subtle bug from netflix/metaflow#2463 Jul 22, 2025
@valayDave valayDave requested a review from romain-intel July 22, 2025 01:02
Copy link
Contributor

@romain-intel romain-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks for catching that.

@romain-intel romain-intel merged commit 9facfe6 into Netflix:master Jul 22, 2025
29 checks passed
valayDave added a commit to valayDave/metaflow that referenced this pull request Aug 11, 2025
savingoyal pushed a commit that referenced this pull request Aug 11, 2025
- Same flavor of bug fix as #2513

Reproduce by doing something like : 

```python
from metaflow import project

....

mymutableflow.add_decorator(
project, deco_kwargs={"name":"abc"}, duplicates=3)
```
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.

3 participants