import gradio as gr import importlib def test_all_libraries(): """Check all library versions and import status""" libraries = [ 'OCP', 'gradio', 'gmsh', 'numpy', 'pandas', 'sklearn', 'torch', 'matplotlib', 'joblib' ] results = [] results.append("=" * 70) results.append("Library Import Test Report") results.append("=" * 70) results.append("") for lib_name in libraries: try: # Handle special module names if lib_name == 'OCP': module = importlib.import_module('OCP.STEPControl') display_name = 'OCP (pythonocc-core)' elif lib_name == 'sklearn': module = importlib.import_module('sklearn') display_name = 'scikit-learn' else: module = importlib.import_module(lib_name) display_name = lib_name # Get version if hasattr(module, '__version__'): version = module.__version__ else: # For OCP, get top-level version try: ocp_module = importlib.import_module('OCP') version = getattr(ocp_module, '__version__', 'N/A') except: version = 'N/A' results.append(f"✅ {display_name:<28} | Version: {version}") except ImportError as e: results.append(f"❌ {lib_name:<28} | Import Error: {str(e)}") except Exception as e: results.append(f"⚠️ {lib_name:<28} | Error: {str(e)}") results.append("") results.append("=" * 70) results.append("📋 Summary & Instructions for GUI Team") results.append("=" * 70) results.append("") results.append("✅ All core libraries are successfully installed!") results.append("") results.append("Key Libraries:") results.append(" • OCP (pythonocc-core): For STEP file parsing & 3D geometry") results.append(" • gmsh: For mesh generation and manipulation") results.append(" • numpy/pandas: For numerical and data processing") results.append(" • torch: For deep learning models") results.append(" • scikit-learn: For machine learning preprocessing") results.append(" • matplotlib: For visualization and plotting") results.append(" • gradio: For web UI interface") results.append("") results.append("Next Steps:") results.append(" 1. Import OCP modules: from OCP.STEPControl import STEPControl_Reader") results.append(" 2. Use gmsh for mesh operations: import gmsh") results.append(" 3. Build your Gradio interface with these libraries") results.append("") results.append("=" * 70) return "\n".join(results) interface = gr.Interface( fn=test_all_libraries, inputs=None, outputs="text", title="OCP Environment Test Space", description="Verify all library versions and import status for deployment", allow_flagging="never" ) if __name__ == "__main__": interface.launch(server_name="0.0.0.0", server_port=7860, share=False)