Files
Atomizer/apply_config_migration.py
Anto01 91fb929f6a refactor: Centralize NX and environment configuration in config.py
MAJOR IMPROVEMENT: Single source of truth for all system paths

Now to change NX version or Python environment, edit ONE file (config.py):
  NX_VERSION = "2412"           # Change this for NX updates
  PYTHON_ENV_NAME = "atomizer"  # Change this for env updates

All code automatically uses new paths - no manual file hunting!

New Central Configuration (config.py):
- NX_VERSION: Automatically updates all NX paths
- NX_INSTALLATION_DIR: Derived from version
- NX_RUN_JOURNAL: Path to run_journal.exe
- NX_MATERIAL_LIBRARY: Path to physicalmateriallibrary.xml
- NX_PYTHON_STUBS: Path to Python stubs for intellisense
- PYTHON_ENV_NAME: Python environment name
- PROJECT_ROOT: Auto-detected project root
- Helper functions: get_nx_journal_command(), validate_config(), print_config()

Updated Files to Use Config:
- optimization_engine/nx_updater.py: Uses NX_RUN_JOURNAL from config
- dashboard/api/app.py: Uses NX_RUN_JOURNAL from config
- Both have fallbacks if config unavailable

Benefits:
1. Change NX version in 1 place, not 10+ files
2. Automatic validation of paths on import
3. Helper functions for common operations
4. Clear error messages if paths missing
5. Easy to add new Simcenter versions

Future NX Update Process:
1. Edit config.py: NX_VERSION = "2506"
2. Run: python config.py (verify paths)
3. Done! All code uses NX 2506

Migration Scripts Included:
- migrate_to_config.py: Full migration with documentation
- apply_config_migration.py: Applied to update dashboard

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 14:31:33 -05:00

25 lines
896 B
Python

from pathlib import Path
# Update dashboard/api/app.py
file_path = Path("dashboard/api/app.py")
content = file_path.read_text()
old_line = ' nx_executable = r"C:\\Program Files\\Siemens\\NX2412\\NXBIN\\run_journal.exe"'
new_lines = ''' # Import centralized NX paths
try:
import sys
from pathlib import Path as P
sys.path.insert(0, str(P(__file__).parent.parent.parent))
from config import NX_RUN_JOURNAL
nx_executable = str(NX_RUN_JOURNAL)
except ImportError:
# Fallback if config not available
nx_executable = r"C:\\Program Files\\Siemens\\NX2412\\NXBIN\\run_journal.exe"'''
content = content.replace(old_line, new_lines)
file_path.write_text(content)
print("Updated dashboard/api/app.py")
print()
print("Configuration migration complete!")
print("Test with: python config.py")