Spaces:
Sleeping
Sleeping
| """ | |
| DR MURPHY — ODE Reformulation Dashboard (HuggingFace Spaces) | |
| Engines: | |
| - njit_10var: @njit Euler loop, H2 only, ~1s per cycle | |
| - ode_v2: scipy ODE + Numba/CoolProp, H2+N2, ~25s per cycle | |
| - fast: production hand-rolled engine, ~3s per cycle | |
| """ | |
| import os | |
| import sys | |
| import threading | |
| # Defer Numba JIT to background thread so Gradio starts immediately | |
| # (HF Spaces has a startup timeout — Numba compilation can take 2-3 min on free tier) | |
| def _warmup_numba(): | |
| try: | |
| from break_coolprop import h2_props | |
| ps_lut = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'h2_ps_lut.npz') | |
| if os.path.exists(ps_lut): | |
| h2_props.init(ps_lut) | |
| print(" Numba H2 EOS ready.") | |
| else: | |
| print(f" Warning: h2_ps_lut.npz not found.") | |
| except Exception as e: | |
| print(f" Numba warmup failed: {e}") | |
| print("Starting Numba JIT warmup in background...") | |
| _warmup_thread = threading.Thread(target=_warmup_numba, daemon=True) | |
| _warmup_thread.start() | |
| from scenario_gui import build_app | |
| # Module-level demo object (required by HF Spaces) | |
| demo = build_app() | |
| if __name__ == "__main__": | |
| import argparse | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--port', type=int, default=7860) | |
| args = parser.parse_args() | |
| print(f"\nLaunching on port {args.port}...") | |
| demo.launch(server_name="0.0.0.0", server_port=args.port, share=False) | |