Created
March 1, 2025 03:08
-
-
Save tuulos/262e96848612c4d002a23fdeb7c370d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment