Skip to main content

No project description provided

Project description

Entropica Labs Loom API Client

A frontend API for generating QEC Loom Experiments. Use of this client requires a valid API token and API URL.

If you would like access to the Loom APIs, get in touch with us at Entropica Labs.

Creating a Client

To create a client to interact with the Loom APIs, you can use the LoomClient class. This class reads the configuration required to establish successful connections from (in order of precedence): inline constructor arguments, environment variables, the configuration file located in the user's home folder at ~/.loom/config.json. There are no default values for the configuration options, so you must provide them in one of the ways described below.

Using a Configuration File [RECOMMENDED] (search path: ~/.loom/config.json)

{
    "api_url": "https://api.example.com",
    "api_token": "**********"
}
from el_loom_api_client import LoomClient

# Create client (will read from configuration file, if it exists)
client = LoomClient()

Using Environment Variables

export LOOM_API_URL="https://api.example.com"
export LOOM_API_TOKEN="**********"
from el_loom_api_client import LoomClient

# Create client (will use environment variables)
client = LoomClient()

Using the constructor directly [NOT RECOMMENDED]

Alternatively you can pass the configuration options directly to the client (this will override any environment variables or configuration file):

from el_loom_api_client import LoomClient

# Create client with explicit configuration. (WARNING: This is NOT RECOMMENDED for code that must be committed to a repository or shared, as this will expose your API token)
client = LoomClient(api_url="https://api.example.com", api_token="**********")

Using the Client

In order to use the client, you should have already obtained a valid API token and the API URL. These instructions assume you have already done so.

Create the client configuration file

You can create the configuration file in your user's home folder with the following content:

MacOS/Linux:

mkdir -p ~/.loom && echo '{"api_url": "https://api.example.com", "api_token": "**********"}' > ~/.loom/config.json

Windows:

New-Item -Path "$HOME\.loom" -ItemType Directory -Force
Set-Content -Path "$HOME\.loom\config.json" -Value '{"api_url": "https://api.example.com", "api_token": "**********"}'

Build a QEC experiment

Using the provided Models and the client, you can build a QEC experiment. The following example shows how to create a simple QEC memory experiment using the MemoryExperiment model and submit it to the Loom API.

from el_loom_api_client import LoomClient
from el_loom_api_client.models import QECExperiment, Qubit, ErrorCorrectionCode

# Create client
client = LoomClient()

# Build the experiment model
experiment = MemoryExperiment(
    qec_code=Code("rotatedsurfacecode"),
    distance=3,
    num_rounds=[3, 5, 7],
    memory_type="Z",
    decoder=Decoder("Pymatching"),
    noise_parameters=[NoiseParameters(
        depolarizing=0.01, measurement=0.01, reset=0.01
    ), NoiseParameters(
        depolarizing=0.05, measurement=0.05, reset=0.05
    )],
    gate_durations={"x": 3e-8, "cx": 2e-7},
)

# Submit the experiment to the Loom API
run_id = client.experiment_run(experiment)

# Wait for the experiment result (asynchronous)
result = await client.get_result_async(run_id)

# Or wait for the experiment result (blocking)
result = client.get_result_sync(run_id)

# Print the result
print(result)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

el_loom_api_client-0.1.2.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

el_loom_api_client-0.1.2-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file el_loom_api_client-0.1.2.tar.gz.

File metadata

  • Download URL: el_loom_api_client-0.1.2.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.14

File hashes

Hashes for el_loom_api_client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 059a538285260d80129cf2fda3191118537076c6f5a39448ead5be5f4d2e6e5d
MD5 1fddf4a08bf8461922829ffb8983da40
BLAKE2b-256 b893a31d3be2989f110d8f4f965bfc09c858a5b88f9e135ccdce8c2a591fa0b8

See more details on using hashes here.

File details

Details for the file el_loom_api_client-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for el_loom_api_client-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7bc6716e3288913ca025d78c7910827aa8affabad378c4d3cdc7e42354e83da0
MD5 8c2784cf9e9a13ab499bd005e73c7eee
BLAKE2b-256 54905a0d5e37fa01111856f2c8d68219991c53e9326767bb7b2a75cf8a071f3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page