You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- cli command to copy cards from other tasks
- Exposing the interface in `current.card` so that cards can be copied over during runtime. This also allows users the flexibility to select which cards to copy during runtime.
- useful for the cases when users need to showcase the model card in downstream steps without having to re-render the card everytime.
- Example flow:
```python
from metaflow import FlowSpec, step, card, current
class CardCopyTestFlow(FlowSpec):
"""
A flow that demonstrates the card copy functionality.
"""
@card(type="blank")
@step
def start(self):
"""
Create a card in the start step.
"""
from metaflow.cards import Markdown
current.card.append(Markdown("# Original Card"))
current.card.append(Markdown("This card was created in the start step."))
self.pathspec = current.pathspec
self.next(self.copy_card)
@card(type="blank")
@step
def copy_card(self):
"""
Copy the card from the start step.
"""
from metaflow.cards import Markdown
# First, create a new card for this step
current.card.append(Markdown("# Destination Card"))
current.card.append(Markdown("This card was created in the copy_card step."))
# Now, copy the card from the start step
# Get the pathspec for the start step
# Copy the card from the start step
success = current.card.copy(self.pathspec)
if success:
current.card.append(Markdown("## Card Copy Success"))
current.card.append(Markdown(f"Successfully copied card from {self.pathspec}"))
else:
current.card.append(Markdown("## Card Copy Failed"))
current.card.append(Markdown(f"Failed to copy card from {self.pathspec}"))
self.next(self.end)
@step
def end(self):
"""
End the flow.
"""
print("Flow completed successfully!")
if __name__ == "__main__":
CardCopyTestFlow()
```
0 commit comments