import streamlit as st import streamlit.components.v1 as components from metaflow import Flow, Run, namespace from metaflow.cards import get_cards from metaflow.integrations import ArgoEvent CARD_PREFIX = '/p/default/api/flows' RUN_PREFIX = '/dashboard/runs/p/default' def card_url(path): parts = path.split('/') parts[-1] = parts[-1].replace('-', '/').replace('.html', '') return '/'.join([CARD_PREFIX] + parts) namespace(None) run = Flow("ForecastFlow").latest_successful_run st.markdown(f"#### Inspecting run\n[**{run.pathspec}**]({RUN_PREFIX}/{run.pathspec})") deployed = False if 'deployed' in run.tags: st.markdown("✅ Deployed") deployed=True else: st.markdown("Not deployed") path = get_cards(run['end'].task)[0].path components.iframe(card_url(path), height=500) if st.button(label='Deploy', type='primary', icon='🚀', disabled=deployed): # you can call any external system here, e.g. a CI/CD, to start a # deployment, or trigger a Metaflow run through an event like below: event = ArgoEvent('deploy_request').publish({'run': run.pathspec}) run.add_tag("deployed") st.toast(f"Deployment request published: {event}") st.rerun()