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.1.tar.gz (9.4 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.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: el_loom_api_client-0.1.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for el_loom_api_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a4b317595a66272c37c9ada04ada8f9cd170669044d0a7cdbdef1468be29330d
MD5 dd9323387d2cfab7ec8043dd93001c9d
BLAKE2b-256 d75c3c57df9c359282f2570f2f07648afc6621dd235cf1b607d118e262f30e89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for el_loom_api_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80a651c6f65c9d36a739d31cf8b462ea15046eb1cec5a78d5776bc0b72f7f6d1
MD5 20feb9e535b3d8c64e854d538bc70e30
BLAKE2b-256 0fa763db89648e8a46b24b7542a08ee59c3daf1196b04af7f5c8b6f3e44c7d33

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