Skip to main content

XCC is a Python API and CLI for the Xanadu Cloud.

Project description

XCC

The Xanadu Cloud Client (XCC) is a Python API and CLI for the Xanadu Cloud.

Features

  • Simple. Easy to setup, explore, and use.

  • Efficient. Lazy fetching and caching by default.

  • Structured. Parse Xanadu Cloud responses into JSON or Python objects.

Installation

The XCC requires Python version 3.7 or above. Installation of the XCC, as well as all dependencies, can be done using pip:

pip install xanadu-cloud-client

Setup

To use the XCC, a Xanadu Cloud API key (or equivalent JWT refresh token) is required. There are several ways to register your API key with the XCC:

  1. Save your API key to the XCC configuration file using the CLI:

    xcc config set REFRESH_TOKEN "Xanadu Cloud API key goes here"
  2. Set the XANADU_CLOUD_REFRESH_TOKEN environment variable:

    export XANADU_CLOUD_REFRESH_TOKEN="Xanadu Cloud API key goes here"
  3. Save your API key to the XCC configuration file using the Python API:

    import xcc
    
    settings = xcc.Settings(REFRESH_TOKEN="Xanadu Cloud API key goes here")
    settings.save()

Afterwards, you can verify that your API key was set correctly using either:

  1. The CLI:

    $ xcc ping
    Successfully connected to the Xanadu Cloud.
  2. The Python API:

    import xcc
    
    connection = xcc.commands.load_connection()
    assert connection.ping().ok

Tutorial

The following tutorial illustrates a workflow for submitting a job to the Xanadu Cloud using the CLI. For more detailed usage instructions, use --help or refer to the Python API documentation.

  1. Before submitting a job, it is a good idea to check which devices are currently accepting jobs on the Xanadu Cloud:

    $ xcc device list --status online
    [
        {
            "target": "simulon_gaussian",
            "status": "online"
        },
        {
            "target": "X8_01",
            "status": "online"
        }
    ]
  2. Suppose that the simulon_gaussian device is of interest. The capabilities, operating conditions, and other properties of a device can be queried by supplying the appropriate flag to the xcc device get command:

    $ xcc device get simulon_gaussian --availability
    {
        "monday": [
            "00:00:00+00:00",
            "23:59:59+00:00"
        ],
        "tuesday": [
            "00:00:00+00:00",
            "23:59:59+00:00"
        ],
        "wednesday": [
            "00:00:00+00:00",
            "23:59:59+00:00"
        ],
        "thursday": [
            "00:00:00+00:00",
            "23:59:59+00:00"
        ],
        "friday": [
            "00:00:00+00:00",
            "23:59:59+00:00"
        ],
        "saturday": [
            "00:00:00+00:00",
            "23:59:59+00:00"
        ],
        "sunday": [
            "00:00:00+00:00",
            "23:59:59+00:00"
        ]
    }

    Note: Given that simulon_gaussian is a simulator, it does not have any scheduled downtime for maintenance.

  3. Now, consider a Blackbird script stored in a local file named circuit.xbb:

    $ cat circuit.xbb
    name example
    version 1.0
    target simulon_gaussian (shots=4)
    
    MeasureFock() | [0, 1, 2]

    This circuit can be submitted to the simulon_gaussian device using the xcc job submit command:

    $ xcc job submit --name example \
        --target simulon_gaussian \
        --language "blackbird:1.0" \
        --circuit "$(cat circuit.xbb)"
    {
        "id": "4c043f6d-54c7-4915-bbb8-eb1b99c4d88e",
        "name": "example",
        "status": "open",
        "target": "simulon_gaussian",
        "created_at": "2021-09-24 17:52:00.532938+00:00",
        "finished_at": null,
        "running_time": null
    }

    Note: Replace cat foo.xbb with Get-Content foo.xbb -Raw on Windows PowerShell.

  4. The ID of a job can be used to retrieve additional information about that job, including its status and running time. Specifically, the ID can be supplied to the xcc job get command along with an optional flag:

    $ xcc job get 4c043f6d-54c7-4915-bbb8-eb1b99c4d88e --status
    complete

    The result of a job can be accessed in a similar way:

    $ xcc job get 4c043f6d-54c7-4915-bbb8-eb1b99c4d88e --result
    {
        "output": [
            "[[0 0 0]\n[0 0 0]\n[0 0 0]\n[0 0 0]]"
        ]
    }

Contributions

We welcome contributions - simply fork the XCC repository and make a pull request containing your contribution. All contributors to the XCC will be listed as authors on the releases. See our changelog for more details.

We also encourage bug reports, suggestions for new features and enhancements, and even links to cool projects or applications built on top of the XCC. Visit the contributions page to learn more about sharing your ideas with the XCC team.

Support

If you are having issues, please let us know by posting the issue on our GitHub issue tracker.

Authors

The XCC is the work of many contributors.

License

The XCC is free and open source, released under the Apache License, Version 2.0.

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

xanadu-cloud-client-0.1.2.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

xanadu_cloud_client-0.1.2-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file xanadu-cloud-client-0.1.2.tar.gz.

File metadata

  • Download URL: xanadu-cloud-client-0.1.2.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for xanadu-cloud-client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d86665c2922e3c66b8c002ea0d44beb20f590eb3f3a0f2d3e2ca6892f202b0b7
MD5 e0671e51f38d1a9365d0e52fcf425926
BLAKE2b-256 f61ce2b296a2b7fcdb4f3b7bbe59414108036596d33c73837e39559cb69d1ba0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xanadu_cloud_client-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for xanadu_cloud_client-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 125da2607507da66501b2f81dcbe8c64f99eca402ee760dcf978cdeabaf51c99
MD5 e0abc81e17173d0b80513b12a7f52ada
BLAKE2b-256 ce5f34da3daf93ae088738313c288b3ef66e64e3fd3d4f1924ea551264af368d

See more details on using hashes here.

Supported by

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