Card component update() raises TypeError instead of warning when not implemented
Summary
Calling .update() on a card component that does not implement it raises TypeError instead of emitting the intended warning.
UserComponent.update builds its warning message with % formatting, but the string has no placeholder:
# metaflow/plugins/cards/card_modules/components.py
def update(self, *args, **kwargs):
cls_name = self.__class__.__name__
msg = (
"MetaflowCardComponent doesn't have an `update` method implemented "
"and is not compatible with realtime updates."
) % cls_name
_warning_with_component(self, msg)cls_name is computed and then never interpolated, so % raises before _warning_with_component is reached.
Reproduction
from metaflow.plugins.cards.card_modules.components import UserComponent
class MyComponent(UserComponent):
def render(self):
return "x"
MyComponent().update("new value")Actual:
TypeError: not all arguments converted during string formattingExpected: the documented warning, naming the component class. This is the documented realtime API (current.card["mycardid"].components["comp123"].update() in component_serializer.py), so a user whose custom component lacks update gets a TypeError from inside Metaflow rather than the "not compatible with realtime updates" message.
A component that does implement update, such as Markdown, is unaffected.
Environment
Reproduced on master (8b500da), Python 3.11.
Source: Netflix/metaflow