Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing cards across multiple steps #2251

Open
pacidic opened this issue Feb 7, 2025 · 0 comments
Open

Sharing cards across multiple steps #2251

pacidic opened this issue Feb 7, 2025 · 0 comments

Comments

@pacidic
Copy link

pacidic commented Feb 7, 2025

I would like to create a "dashboard-style" card that summarizes information from multiple steps. For instance, when running parallel processes via a foreach step, I would like to update a common progress bar, rather than having one card for each step as in the example below. Is this currently possible?

from metaflow import FlowSpec, step, card, current, resources
from metaflow.cards import ProgressBar

import time

class ForeachFlow(FlowSpec):

    @step
    def start(self):
        self.values = [list(range(100)) for _ in range(3)]
        self.next(self.a, foreach='values')

    @resources(cpu=10)
    @card(type="blank")
    @step
    def a(self):

        pb = ProgressBar(max=len(self.input), label=current.step_name)
        current.card.append(pb)
        for n, val in enumerate(self.input, 1):
            pb.update(n)
            current.card.refresh()
            time.sleep(0.1)

        self.next(self.join)

    @step
    def join(self, inputs):
        self.merge_artifacts(inputs)
        self.next(self.end)

    @step
    def end(self):
        pass

if __name__ == '__main__':
    ForeachFlow()
@pacidic pacidic changed the title Share card between multiple steps Sharing cards across multiple steps Feb 7, 2025
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

No branches or pull requests

1 participant