Spaces:
No application file
No application file
File size: 1,801 Bytes
91994bf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | from abc import ABC, abstractmethod
from typing import Dict, Any
class BaseLab(ABC):
"""
Abstract base class for all laboratories in QuLabInfinite.
This class defines the common interface that all specialized labs
(e.g., MaterialsLab, ChemistryLaboratory, QuantumLabSimulator) must implement.
This ensures a consistent API for initialization, configuration,
and execution of simulations across the platform.
"""
def __init__(self, config: Dict[str, Any] = None):
"""
Initialize the laboratory with a given configuration.
Args:
config: A dictionary of configuration parameters.
"""
self.config = config or {}
print(f"[info] Initializing {self.__class__.__name__}...")
@abstractmethod
def run_experiment(self, experiment_spec: Dict[str, Any]) -> Dict[str, Any]:
"""
Run a specific experiment based on the provided specification.
Args:
experiment_spec: A dictionary defining the experiment to be run,
including parameters and desired outputs.
Returns:
A dictionary containing the results of the experiment.
"""
pass
@abstractmethod
def get_status(self) -> Dict[str, Any]:
"""
Get the current status of the laboratory.
Returns:
A dictionary containing status information, such as backend state,
loaded data, and available capabilities.
"""
pass
def get_capabilities(self) -> Dict[str, Any]:
"""
Get the capabilities of the laboratory.
Returns:
A dictionary describing the capabilities of the lab.
"""
return {"name": self.__class__.__name__, "capabilities": "N/A"}
|