Surajv commited on
Commit
f3aa8aa
·
1 Parent(s): 11a087f

refined header and data loader

Browse files
src/backend/data_loader.py CHANGED
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
11
 
12
  REPO_ID = 'Angione-Lab/spMetaTME-Atlas'
13
 
14
- @st.cache_resource
15
  def get_metadata():
16
  """Fetch and cache metadata from Hugging Face."""
17
  try:
@@ -25,6 +25,7 @@ def get_metadata():
25
  logger.error(f"Error loading metadata: {e}")
26
  return pd.DataFrame()
27
 
 
28
  def get_organ_stats(meta_df: pd.DataFrame):
29
  """Calculate summary statistics for organs from metadata."""
30
  if meta_df.empty:
@@ -54,7 +55,7 @@ def get_organ_stats(meta_df: pd.DataFrame):
54
  stats = stats.sort_values('sample_count', ascending=False)
55
  return stats
56
 
57
- @st.cache_data
58
  def load_metabolic_flux_from_hf(filename: str):
59
  """
60
  Load spatial metabolic flux data from Hugging Face Hub with caching.
 
11
 
12
  REPO_ID = 'Angione-Lab/spMetaTME-Atlas'
13
 
14
+ @st.cache_data(show_spinner=False)
15
  def get_metadata():
16
  """Fetch and cache metadata from Hugging Face."""
17
  try:
 
25
  logger.error(f"Error loading metadata: {e}")
26
  return pd.DataFrame()
27
 
28
+ @st.cache_data(show_spinner=False)
29
  def get_organ_stats(meta_df: pd.DataFrame):
30
  """Calculate summary statistics for organs from metadata."""
31
  if meta_df.empty:
 
55
  stats = stats.sort_values('sample_count', ascending=False)
56
  return stats
57
 
58
+ @st.cache_data(show_spinner=False)
59
  def load_metabolic_flux_from_hf(filename: str):
60
  """
61
  Load spatial metabolic flux data from Hugging Face Hub with caching.
src/ui/components/header.py CHANGED
@@ -52,15 +52,22 @@ def render_header():
52
  </div>
53
  """, unsafe_allow_html=True)
54
 
 
55
  def load_css():
56
- """Load custom CSS."""
 
57
  css_path = "assets/style.css"
 
58
  if os.path.exists(css_path):
59
  with open(css_path) as f:
60
- st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
61
 
62
- # Also load external assets
63
  st.markdown("""
64
  <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
65
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
66
  """, unsafe_allow_html=True)
 
 
 
 
 
52
  </div>
53
  """, unsafe_allow_html=True)
54
 
55
+ @st.cache_resource(show_spinner=False)
56
  def load_css():
57
+ """Load and apply CSS - cached to prevent reloading on every rerun."""
58
+ # Load custom CSS file
59
  css_path = "assets/style.css"
60
+ css_content = ""
61
  if os.path.exists(css_path):
62
  with open(css_path) as f:
63
+ css_content = f.read()
64
 
65
+ # Load external assets
66
  st.markdown("""
67
  <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
68
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
69
  """, unsafe_allow_html=True)
70
+
71
+ # Apply custom CSS
72
+ if css_content:
73
+ st.markdown(f"<style>{css_content}</style>", unsafe_allow_html=True)