zhuoranyang commited on
Commit
a9f7122
·
1 Parent(s): 4c9bdd7

Set default modulo to largest available and stream child logs immediately

Browse files
Files changed (1) hide show
  1. hf_app/app.py +6 -4
hf_app/app.py CHANGED
@@ -1017,19 +1017,21 @@ def run_pipeline_for_p_streaming(p):
1017
 
1018
  env = os.environ.copy()
1019
  env["PYTHONPATH"] = PROJECT_ROOT + ":" + env.get("PYTHONPATH", "")
 
 
1020
 
1021
  steps = [
1022
  ("Step 1/3: Training 5 configurations", [
1023
- sys.executable, "precompute/train_all.py",
1024
  "--p", str(p), "--output", TRAINED_MODELS_DIR, "--resume",
1025
  ]),
1026
  ("Step 2/3: Generating model-based plots", [
1027
- sys.executable, "precompute/generate_plots.py",
1028
  "--p", str(p), "--input", TRAINED_MODELS_DIR,
1029
  "--output", RESULTS_DIR,
1030
  ]),
1031
  ("Step 3/3: Generating analytical plots", [
1032
- sys.executable, "precompute/generate_analytical.py",
1033
  "--p", str(p), "--output", RESULTS_DIR,
1034
  ]),
1035
  ]
@@ -1066,7 +1068,7 @@ def run_pipeline_for_p_streaming(p):
1066
  def create_app():
1067
  moduli = get_available_moduli()
1068
  p_choices = [str(p) for p in moduli]
1069
- default_p = p_choices[0] if p_choices else None
1070
 
1071
  with gr.Blocks(
1072
  title="Modular Addition Feature Learning",
 
1017
 
1018
  env = os.environ.copy()
1019
  env["PYTHONPATH"] = PROJECT_ROOT + ":" + env.get("PYTHONPATH", "")
1020
+ # Force unbuffered child Python output so logs appear immediately in Gradio.
1021
+ env["PYTHONUNBUFFERED"] = "1"
1022
 
1023
  steps = [
1024
  ("Step 1/3: Training 5 configurations", [
1025
+ sys.executable, "-u", "precompute/train_all.py",
1026
  "--p", str(p), "--output", TRAINED_MODELS_DIR, "--resume",
1027
  ]),
1028
  ("Step 2/3: Generating model-based plots", [
1029
+ sys.executable, "-u", "precompute/generate_plots.py",
1030
  "--p", str(p), "--input", TRAINED_MODELS_DIR,
1031
  "--output", RESULTS_DIR,
1032
  ]),
1033
  ("Step 3/3: Generating analytical plots", [
1034
+ sys.executable, "-u", "precompute/generate_analytical.py",
1035
  "--p", str(p), "--output", RESULTS_DIR,
1036
  ]),
1037
  ]
 
1068
  def create_app():
1069
  moduli = get_available_moduli()
1070
  p_choices = [str(p) for p in moduli]
1071
+ default_p = str(max(moduli)) if moduli else None
1072
 
1073
  with gr.Blocks(
1074
  title="Modular Addition Feature Learning",