-
Notifications
You must be signed in to change notification settings - Fork 26
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
Move to modules instead of classes for home page and common interface #717
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Interface for the data explorer app.""" | ||
|
||
import os | ||
|
||
import streamlit as st | ||
from interfaces.utils import get_index_from_state | ||
|
||
|
||
def render_common_interface(): | ||
cols = st.columns(2) | ||
with cols[0]: | ||
_select_pipeline() | ||
with cols[1]: | ||
_select_run() | ||
|
||
|
||
def _select_pipeline(): | ||
"""Selects a pipeline from available pipelines.""" | ||
available_pipelines = [ | ||
os.path.basename(item) | ||
for item in st.session_state.file_system.ls(st.session_state.base_path) | ||
] | ||
|
||
selected_pipeline = st.selectbox( | ||
"Pipeline", | ||
options=available_pipelines, | ||
index=get_index_from_state("pipeline", available_pipelines), | ||
) | ||
st.session_state.pipeline = selected_pipeline | ||
st.session_state.pipeline_path = st.session_state.base_path / selected_pipeline | ||
|
||
|
||
def _select_run(): | ||
"""Selects a run from available runs within the chosen pipeline.""" | ||
pipeline_path = st.session_state.base_path / st.session_state.pipeline | ||
|
||
def has_manifest_file(path): | ||
return any("manifest.json" in files for _, _, files in os.walk(path)) | ||
|
||
available_runs = [] | ||
for run in os.listdir(pipeline_path): | ||
run_path = pipeline_path / run | ||
if run_path.is_dir() and run != "cache" and has_manifest_file(run_path): | ||
available_runs.append(os.path.basename(run)) | ||
|
||
available_runs.sort(reverse=True) | ||
|
||
selected_run = st.selectbox( | ||
"Run", | ||
options=available_runs, | ||
index=get_index_from_state("run", available_runs), | ||
) | ||
st.session_state.run = selected_run | ||
st.session_state.run_path = st.session_state.pipeline_path / selected_run | ||
st.session_state.available_runs = available_runs |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file was split into |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import streamlit as st | ||
from streamlit_extras.app_logo import add_logo | ||
|
||
|
||
def render_sidebar(): | ||
add_logo("content/fondant_logo.png") | ||
|
||
with st.sidebar: | ||
# Increase the width of the sidebar to accommodate logo | ||
st.markdown( | ||
""" | ||
<style> | ||
section[data-testid="stSidebar"] { | ||
width: 350px !important; | ||
} | ||
</style> | ||
""", | ||
unsafe_allow_html=True, | ||
) | ||
|
||
with st.expander("## General Configuration"): | ||
st.markdown(f"### Base path: \n {st.session_state.base_path}") |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a fix for an issue raised by @Hakimovich99, where you cannot switch pipelines because the run selection would error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should aim to get rid of these completely.
This is currently used to initialize all session state variables at the start of the application, to prevent errors when accessing non-initialized values. But this brings us in broken states anyway. We should make sure the flow is set up so values are only accessed after initialization, or non-initialization is handled in the accessing code.