Fix incorrect OR operand order when initializing Metaflow instance#3021
Fix incorrect OR operand order when initializing Metaflow instance#3021anurag99sai-alt wants to merge 2 commits intoNetflix:masterfrom
Conversation
Greptile SummaryThis PR fixes a longstanding bug in The PR also removes the Python 2 Key changes:
Minor observations:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["MetaflowObject.__init__ called"] --> B{"_metaflow\nprovided?"}
B -- "Yes (truthy Metaflow instance)" --> C["self._metaflow = _metaflow\n(reuse existing instance)"]
B -- "No (None / falsy)" --> D["self._metaflow = Metaflow(_current_metadata)\n(create new instance)"]
C --> E["Proceed with init\n(set _parent, _attempt, namespace…)"]
D --> E
style C fill:#22bb44,color:#fff
style D fill:#2288cc,color:#fff
Last reviewed commit: 6e3ea73 |
The current implementation initializes the Metaflow instance as:
self._metaflow = Metaflow(_current_metadata) or _metaflow
Since Metaflow(_current_metadata) always returns a truthy object,
the
_metaflowoperand is never evaluated. This prevents reuse ofan existing Metaflow instance.
Swapping the operands ensures that an existing
_metaflowinstanceis reused when available:
self._metaflow = _metaflow or Metaflow(_current_metadata)