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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for el_loom_api_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f80150fcce0b38c98795625634a0e3f79d790df4717ba7e5feb2ed9a796981d5
MD5 87da1de50732ed2df5398ad88362629e
BLAKE2b-256 63f1a3a19cd947846a04511c80dda8fbcb257d64bc6d6415031c963af4e2d9f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for el_loom_api_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebe3720463ca87b8d54ee682892fb8a4059709c956fa2e4c5cb5e2ef8561dfa2
MD5 7d4305c2f712967b5625fa435a123019
BLAKE2b-256 00de621037b024875d5a5a9a08fb2fc1b625b25aa310c20bd661efb19419b08b

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