-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Iskandar Sitdikov edited this page May 19, 2023
·
2 revisions
Welcome to the PurpleCaffeine wiki!
Trial
. Main class that encapsulates all information about experiment.
class Trial:
def __init__(self, name: str, backend: BaseBackend):
self.backend = backend or LocalBackend()
self.name = name
self.metrics = []
self.parameters = []
self.circuits = []
...
def add_metric(self, name: str, value: float|int):
self.metrics.append((name, value))
def add_parameter(self, name: str, value: str):
self.parameters.append((name, value))
def add_circuit(self, name: str, circuit: QuantumCircuit):
self.circuits.append((name, circuit))
...
BaseBackend
. Parent class for all backend implementation. Acts like a class for CRUD operations on Trial
s
class BaseBackend():
def save_trial(self, trail: Trial):
...
def get(self, trial_id: str):
"""Returns trial by id."""
...
def list(self, **kwargs):
"""Returns list of trials.
Args:
kwargs: list of parameters needed for filtering
"""
LocalBackend
. Local backend implementation of BaseBackend
that stores data on local file system.
ApiBackend
. Backend implementation of backend that stores data on api server.
Save trial
Method: POST
Url: /trial/
Body:
{
"name": "<NAME>",
"metrics": [{
"name": "<METRIC_NAME>",
"value": 42
}, {...}],
"circuits": [{
"name": "<CIRCUIT_NAME>",
"circuit": {
"__type__": "QuantumCircuit", # see https://github.com/Qiskit/qiskit-ibm-runtime/blob/main/qiskit_ibm_runtime/utils/json.py#L225
"__value__": "<VALUE>"
}
}],
...
}
Get list
Method: GET
Url: /trial/
Body:
{
"count": 10,
"results": [{
"name": "...",
"metrics": [...],
...
}, {...}, ...]
}
Get by id
Method: GET
Url: /trial/<ID>
Body:
{
"name": "...",
"metrics": [...],
...
}