COP_TEST / app.py
Iris314's picture
Update app.py
5f234f4 verified
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)