|
1 | | -from .aer_sampler_adapter import AerSamplerAdapter |
2 | | -from .aer_simulator_adapter import AerSimulatorAdapter |
3 | | -from .backend_adapter import BackendAdapter |
4 | | -from .ibm_sampler_adapter import IBMSamplerAdapter |
5 | | -from .ionq_backend_adapter import IonQBackendAdapter |
6 | | - |
7 | | -__all__ = [ |
8 | | - "BackendAdapter", |
9 | | - "AerSamplerAdapter", |
10 | | - "IonQBackendAdapter", |
11 | | - "AerSimulatorAdapter", |
12 | | - "IBMSamplerAdapter", |
13 | | -] |
| 1 | +# Todos los imports con manejo de errores |
| 2 | +_adapters = {} |
| 3 | + |
| 4 | +try: |
| 5 | + from .aer_sampler_adapter import AerSamplerAdapter |
| 6 | + _adapters["AerSamplerAdapter"] = AerSamplerAdapter |
| 7 | +except ImportError as e: |
| 8 | + AerSamplerAdapter = None |
| 9 | + print(f"⚠️ AerSamplerAdapter no disponible: {e}") |
| 10 | + |
| 11 | +try: |
| 12 | + from .aer_simulator_adapter import AerSimulatorAdapter |
| 13 | + _adapters["AerSimulatorAdapter"] = AerSimulatorAdapter |
| 14 | +except ImportError as e: |
| 15 | + AerSimulatorAdapter = None |
| 16 | + print(f"⚠️ AerSimulatorAdapter no disponible: {e}") |
| 17 | + |
| 18 | +try: |
| 19 | + from .ibm_sampler_adapter import IBMSamplerAdapter |
| 20 | + _adapters["IBMSamplerAdapter"] = IBMSamplerAdapter |
| 21 | +except ImportError as e: |
| 22 | + IBMSamplerAdapter = None |
| 23 | + print(f"⚠️ IBMSamplerAdapter no disponible: {e}") |
| 24 | + |
| 25 | +try: |
| 26 | + from .ionq_backend_adapter import IonQBackendAdapter |
| 27 | + _adapters["IonQBackendAdapter"] = IonQBackendAdapter |
| 28 | +except ImportError as e: |
| 29 | + IonQBackendAdapter = None |
| 30 | + print(f"⚠️ IonQBackendAdapter no disponible: {e}") |
| 31 | + |
| 32 | +try: |
| 33 | + from .quafu_backend_adapter import QuafuBackendAdapter |
| 34 | + _adapters["QuafuBackendAdapter"] = QuafuBackendAdapter |
| 35 | +except ImportError as e: |
| 36 | + QuafuBackendAdapter = None |
| 37 | + print(f"⚠️ QuafuBackendAdapter no disponible: {e}") |
| 38 | + |
| 39 | +# BackendAdapter es esencial - si falla, hay un problema grave |
| 40 | +try: |
| 41 | + from .backend_adapter import BackendAdapter |
| 42 | + _adapters["BackendAdapter"] = BackendAdapter |
| 43 | +except ImportError as e: |
| 44 | + raise ImportError(f"❌ BackendAdapter esencial no disponible: {e}") |
| 45 | + |
| 46 | +# Hacer disponibles todos en el namespace |
| 47 | +globals().update(_adapters) |
| 48 | + |
| 49 | +# Solo exportar los que se importaron correctamente |
| 50 | +__all__ = list(_adapters.keys()) |
| 51 | + |
| 52 | +# Información de disponibilidad |
| 53 | +available_adapters = {name: adapter is not None for name, adapter in _adapters.items()} |
| 54 | +__all__.append("available_adapters") |
| 55 | + |
| 56 | +print(f"✅ Adapters cargados: {len(_adapters)}/{len(__all__)-1}") |
0 commit comments