Skip to content

Commit

Permalink
feat: instantiate platform without parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Dec 17, 2024
1 parent 701093d commit 9780347
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/qibolab/_core/platform/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def locate_platform(name: str, paths: Optional[list[Path]] = None) -> Path:
return _search(name, paths)


def create_platform(name: str, params: Optional[dict] = None) -> Platform:
def create_platform(name: str, parameters: Optional[Parameters] = None) -> Platform:
"""A platform for executing quantum algorithms.
It consists of a quantum processor QPU and a set of controlling instruments.
Expand All @@ -83,10 +83,10 @@ def create_platform(name: str, params: Optional[dict] = None) -> Platform:
if isinstance(hardware, Platform):
return hardware

if params is None:
if parameters is None:
return Platform.load(path, **hardware)

return Platform(**hardware, parameters=Parameters(**params))
return Platform(**hardware, parameters=parameters)


def available_platforms() -> list[str]:
Expand Down
15 changes: 8 additions & 7 deletions src/qibolab/_core/platform/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
InstrumentMap,
NativeGates,
Parameters,
ParametersBuilder,
QubitMap,
Settings,
Update,
Expand Down Expand Up @@ -310,13 +311,13 @@ def load(
if couplers is None:
couplers = {}

return cls(
name=name,
parameters=Parameters.model_validate_json((path / PARAMETERS).read_text()),
instruments=instruments,
qubits=qubits,
couplers=couplers,
)
hardware = {"instruments": instruments, "qubits": qubits, "couplers": couplers}
try:
parameters = Parameters.model_validate_json((path / PARAMETERS).read_text())
except FileNotFoundError:
parameters = ParametersBuilder(hardware=hardware).build()

return cls(name=name, parameters=parameters, **hardware)

def dump(self, path: Path):
"""Dump platform."""
Expand Down

0 comments on commit 9780347

Please sign in to comment.