diff --git a/python/cudaq_bridge.py b/python/cudaq_bridge.py index 354a303..13f9c1e 100644 --- a/python/cudaq_bridge.py +++ b/python/cudaq_bridge.py @@ -18,11 +18,11 @@ try: import cudaq from cudaq import spin CUDAQ_AVAILABLE = True - logger.info("CUDA Quantum successfully imported") + print("INFO - CUDA Quantum successfully imported", flush=True) except ImportError as e: CUDAQ_AVAILABLE = False - logger.warning(f"CUDA Quantum not available: {e}") - logger.warning("Running in mock mode - install CUDA Quantum for full functionality: pip install cudaq") + print(f"WARNING - CUDA Quantum not available: {e}", flush=True) + print("WARNING - Running in mock mode - install CUDA Quantum for full functionality: pip install cudaq", flush=True) class QuantumKernelManager: diff --git a/src/bridge/python-bridge.ts b/src/bridge/python-bridge.ts index 779a0ce..2609897 100644 --- a/src/bridge/python-bridge.ts +++ b/src/bridge/python-bridge.ts @@ -81,9 +81,16 @@ export class PythonBridge extends EventEmitter { const output = data.toString(); this.logger.debug('Python stdout:', output); - if (!initialized && (output.includes('CUDA Quantum Python Bridge') || output.includes('Ready'))) { - initialized = true; - resolve(); + // Check for initialization messages + if (!initialized) { + if (output.includes('CUDA Quantum Python Bridge') || output.includes('Ready')) { + initialized = true; + resolve(); + } else if (output.includes('INFO - CUDA Quantum successfully imported')) { + this.logger.info('CUDA Quantum initialized successfully'); + } else if (output.includes('WARNING - CUDA Quantum not available')) { + this.logger.warn('CUDA Quantum not available, running in mock mode'); + } } // Handle JSON responses @@ -93,17 +100,14 @@ export class PythonBridge extends EventEmitter { this.pythonProcess.stderr?.on('data', (data: Buffer) => { const error = data.toString(); - // Check if it's just a warning about CUDA Quantum not being available - if (error.includes('WARNING') && error.includes('CUDA Quantum not available')) { - this.logger.warn('Python warning:', error); - // Don't treat this as a fatal error - continue with initialization - if (!initialized) { - initialized = true; - resolve(); - } - } else { + // Log stderr messages but don't treat them as fatal errors during initialization + // Most Python logging goes to stderr even for non-errors + if (error.includes('WARNING') || error.includes('INFO') || error.includes('DEBUG')) { + this.logger.debug('Python log message:', error); + } else if (error.trim()) { this.logger.error('Python stderr:', error); - if (!initialized) { + // Only reject during initialization if it's a real error (not a log message) + if (!initialized && !error.includes('INFO') && !error.includes('WARNING') && !error.includes('DEBUG')) { reject(new Error(`Python process error: ${error}`)); } }