Skip to content
Iskandar Sitdikov edited this page May 19, 2023 · 2 revisions

Welcome to the PurpleCaffeine wiki!

Design doc / requirements

Objects, classes and functions

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 Trials

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.

Widget design proposal

235362061-95215eb2-cf9a-4197-ba8c-901a326e0e04

Api server

API description

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": [...],
    ...
}
Clone this wiki locally