xcc.Device¶
- class Device(target: str, connection: xcc.connection.Connection)[source]¶
Bases:
objectRepresents a device on the Xanadu Cloud.
- Parameters
target (str) – target name of the device
connection (Connection) – connection to the Xanadu Cloud
Note
For performance reasons, the properties of a device are lazily fetched and stored in a cache. This cache can be cleared at any time by calling
Device.clear().Warning
The
xcc.Deviceclass transparently contacts the Xanadu Cloud when an uncached device property is accessed. This means that requesting a device property for the first time may take longer than expected.Example:
The following example shows how to use the
Deviceclass to query various properties of theX8_01device on the Xanadu Cloud. First, a connection is established to the Xanadu Cloud:>>> import xcc >>> connection = xcc.Connection.load()
Next, a reference to the
X8_01device is created using the connection.>>> device = xcc.Device(target="X8_01", connection=connection)
Finally, the certificate, specification, status, etc. of the
X8_01device are retrieved by accessing the corresponding property of the device:>>> device.certificate {'device_url': ..., 'laser_wavelength_meters': 1.55270048e-06} >>> device.specification {'gate_parameters': ..., 'target': 'X8_01'} >>> device.status 'online'
Attributes
Returns the certificate of a device.
Returns the expected uptime of a device.
Returns an overview of a device.
Returns the specification of a device.
Returns the status of a device.
Returns the target of a device.
Returns whether a device is accepting jobs.
- certificate¶
Returns the certificate of a device.
A device certificate contains the current operating conditions of a device and is periodically updated while the device is online.
- Returns
certificate of this device
- Return type
Mapping[str, Any]
Warning
The structure of a certificate may vary from device to device.
- expected_uptime¶
Returns the expected uptime of a device.
- Returns
mapping from weekdays to optional time pairs where each pair represents when the device is expected to come online and offline that day
- Return type
Mapping[str, Optional[Tuple[time, time]]]
- overview¶
Returns an overview of a device.
- Returns
mapping from field names to values for this device as determined by the needs of a Xanadu Cloud user.
- Return type
Mapping[str, Any]
- specification¶
Returns the specification of a device.
- Returns
specification of this device
- Return type
Mapping[str, Any]
- status¶
Returns the status of a device.
- Returns
status of this device (“online” or “offline”)
- Return type
str
- target¶
Returns the target of a device.
- up¶
Returns whether a device is accepting jobs.
- Returns
Trueiff the status of this device is “online”- Return type
bool
Methods
clear()Clears the details, certificate, and specification caches of a device.
list(connection[, status])Returns devices on the Xanadu Cloud.
- static list(connection: xcc.connection.Connection, status: Optional[str] = None) Sequence[xcc.device.Device][source]¶
Returns devices on the Xanadu Cloud.
- Parameters
connection (Connection) – connection to the Xanadu Cloud
status (str, optional) – optionally filter devices by status
- Returns
devices on the Xanadu Cloud which match the status filter
- Return type
Sequence[Device]