analytical-viz: force-reload our modules on Streamlit rerun
Streamlit's hot-reload re-executes app.py on every interaction, but sub-modules imported from app.py stay cached in sys.modules across reruns. When we edit auto_explore.py or auto_hardware.py while Streamlit is alive, the app keeps using the pre-edit version until a full Ctrl+C + restart — leading to confusing "unexpected keyword argument" errors after a signature change. Force importlib.reload() on our own modules at the top of app.py so future signature changes land without a full restart. Only reloads if the module is already in sys.modules (first run just imports normally). Applied to: - tests.analytical_visualization.auto_explore - tests.analytical_visualization.auto_hardware - tests.analytical_visualization.autosuggest - tests.analytical_visualization.stage_latencies - tests.analytical_visualization.memory_layout Third-party modules (streamlit, matplotlib, pandas, numpy) NOT reloaded — unnecessary and slow. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,10 +6,30 @@ Run:
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
import streamlit as st
|
||||
|
||||
# Streamlit's hot-reload only re-runs THIS script; imported sub-modules stay
|
||||
# cached in sys.modules across reruns. When we edit auto_explore.py or
|
||||
# auto_hardware.py while the Streamlit process is alive, the app would
|
||||
# keep using the pre-edit versions until a full Ctrl+C + restart. Force
|
||||
# a reload of our own modules on every rerun so signature changes land
|
||||
# without a full restart.
|
||||
for _mod_name in (
|
||||
"tests.analytical_visualization.auto_explore",
|
||||
"tests.analytical_visualization.auto_hardware",
|
||||
"tests.analytical_visualization.autosuggest",
|
||||
"tests.analytical_visualization.stage_latencies",
|
||||
"tests.analytical_visualization.memory_layout",
|
||||
):
|
||||
_m = sys.modules.get(_mod_name)
|
||||
if _m is not None:
|
||||
importlib.reload(_m)
|
||||
|
||||
from tests.analytical_visualization.model_config import (
|
||||
FullConfig, ModelConfig, TopologyConfig, MachineParams,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user