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>
This commit is contained in:
@@ -23,6 +23,11 @@ import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
import sys
|
||||
|
||||
# Import centralized configuration
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
from config import NX_RUN_JOURNAL
|
||||
|
||||
|
||||
class NXParameterUpdater:
|
||||
@@ -63,7 +68,7 @@ class NXParameterUpdater:
|
||||
|
||||
# Default NX run_journal.exe path
|
||||
if nx_run_journal_path is None:
|
||||
self.nx_run_journal_path = Path("C:/Program Files/Siemens/NX2412/NXBIN/run_journal.exe")
|
||||
self.nx_run_journal_path = NX_RUN_JOURNAL
|
||||
else:
|
||||
self.nx_run_journal_path = Path(nx_run_journal_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user