Migrating to v0.25.0: QRMI is_accessible() is now deprecated. Use status() instead#

Up through v0.24.x, the only way to check a QuantumResource was is_accessible(), which returns a single boolean.

This release adds status(), which returns a richer ResourceStatus: a status code (online / offline / paused) plus optional details such as the status reason, health, busy state, slot capacity and pending job count. is_accessible() is now deprecated in every binding. Its behavior is unchanged, so existing code keeps working, but new code should use status().

What’s changed#

Language

Deprecated

Replacement

Rust

QuantumResource::is_accessible() (now #[deprecated])

QuantumResource::status() -> Result<ResourceStatus>

C

qrmi_resource_is_accessible() (now @deprecated)

qrmi_resource_status() and the qrmi_resource_status_*() accessors

Python

QuantumResource.is_accessible() (now emits DeprecationWarning)

QuantumResource.status() -> ResourceStatus

Lua

resource:is_accessible()

resource:status(), returning a plain Lua table

ResourceStatus fields#

Field

Type

Description

status

ResourceStatusCode

One of online, offline or paused. paused means online but not currently accepting or running jobs because of a maintenance-type event, e.g. calibration.

status_reason

string, optional

The vendor-specific status reason.

healthy

bool, optional

Whether the resource is currently healthy.

busy

bool, optional

Whether the resource is currently busy.

capacity

ResourceCapacity, optional

Slot capacity, with available_slots and max_slots.

pending_job_count

integer, optional

The number of jobs pending in the queue.

Optional fields are empty (None / nil) when the resource type doesn’t report them.

How to migrate#

is_accessible() returns true only when quantum workloads can be executed. A resource that is reachable but can’t run workloads, for example during maintenance, is not considered accessible. With status(), that case is reported as paused, so the equivalent of is_accessible() == true is a status of online only.

  1. Rust — Replace is_accessible() with status() and check its status field:

    // Before
    if qrmi.is_accessible().await? {
        // ...
    }
    
    // After
    use qrmi::models::ResourceStatusCode;
    
    let st = qrmi.status().await?;
    if st.status == ResourceStatusCode::Online {
        // ...
    }
    

    If you implement the QuantumResource trait yourself, implement status(). Its default implementation delegates to is_accessible() and reports only Online or Offline, so existing implementations keep working until you do.

  2. C — Replace qrmi_resource_is_accessible() with qrmi_resource_status(), then read the fields through the accessor functions:

    QrmiResourceStatus *st = NULL;
    if (qrmi_resource_status(qrmi, &st) != QRMI_RETURN_CODE_SUCCESS) {
        /* handle error */
    }
    
    QrmiResourceStatusCode code;
    qrmi_resource_status_code(st, &code);
    printf("status: %s\n", qrmi_resource_status_code_to_string(code));
    
    if (code == QRMI_RESOURCE_STATUS_CODE_ONLINE) {
        /* ... */
    }
    
    char *reason = qrmi_resource_status_reason(st);
    if (reason != NULL) {
        printf("reason: %s\n", reason);
        qrmi_string_free(reason);
    }
    
    qrmi_resource_status_free(st);
    

    Keep these rules in mind:

    • Release the handle with qrmi_resource_status_free(), and a capacity handle from qrmi_resource_status_capacity() with qrmi_resource_capacity_free().

    • qrmi_resource_status_reason() may return NULL. Free a non-null result with qrmi_string_free().

    • qrmi_resource_status_healthy(), _busy(), _pending_job_count() and _capacity() return QRMI_RETURN_CODE_UNSUPPORTED_FUNCTION_ERROR when the resource doesn’t report that field.

    • qrmi_resource_status_code_to_string() returns a static string. Don’t free it.

  3. Python — Replace is_accessible() with status():

    from qrmi import ResourceStatusCode
    
    # Before
    if qrmi.is_accessible():
        ...
    
    # After
    st = qrmi.status()
    if st.status == ResourceStatusCode.Online:
        ...
    
    print(st.to_dict())  # JSON-compatible dict
    

    Calling is_accessible() now emits a DeprecationWarning.

  4. Lua — Replace resource:is_accessible() with resource:status():

    -- Before
    local accessible, err = resource:is_accessible()
    
    -- After
    local st, err = resource:status()
    if not st then
      error(err)
    end
    if st.status == "online" then
      -- ...
    end
    

    status() returns a plain Lua table. healthy, busy, pending_job_count and capacity are nil when the resource doesn’t report them.