コード例 #1
0
def query_device(device_name) -> dict:
    """
    Try to query the device from QCS. Return the lattice dict if it exists, or
    or None otherwise.
    """
    lattices = list_lattices()
    if device_name in list(lattices.keys()):
        return lattices[device_name]
    return None
コード例 #2
0
def main():
    now = str(datetime.datetime.today())
    for device in list_devices():
        os.makedirs(os.path.join(device, now), exist_ok=True)

        for lattice in map(get_lattice, list_lattices(device_name=device)):
            print(lattice.name, file=sys.stderr)
            with open(qpu_dir.format(device, now, lattice.name), 'w') as f:
                json.dump(device_to_chipspec(lattice, timestamp=now),
                          f,
                          indent=2)

    try:
        os.unlink(f"{device}/latest")
    except FileNotFoundError:
        pass

    os.symlink(f"{now}", f"{device}/latest")
コード例 #3
0
def list_quantum_computers(connection: ForestConnection = None,
                           qpus: bool = True,
                           qvms: bool = True) -> List[str]:
    """
    List the names of available quantum computers

    :param connection: An optional :py:class:ForestConnection` object. If not specified,
        the default values for URL endpoints will be used, and your API key
        will be read from ~/.pyquil_config. If you deign to change any
        of these parameters, pass your own :py:class:`ForestConnection` object.
    :param qpus: Whether to include QPU's in the list.
    :param qvms: Whether to include QVM's in the list.
    """
    if connection is None:
        connection = ForestConnection()

    qc_names: List[str] = []
    if qpus:
        qc_names += list(list_lattices(connection=connection).keys())

    if qvms:
        qc_names += ['9q-square-qvm', '9q-square-noisy-qvm']

    return qc_names