Migrating to v0.25.0: QRMI QuantumResources can now be created from a configuration map#

Up through v0.24.x, every QuantumResource implementation could only be constructed one way: by reading a fixed set of process environment variables with the new() constructor.

This release adds a second, purely additive construction path: building a resource directly from an explicit, in-memory config map instead of the environment variables. Every existing constructor in the bindings (new() / qrmi_resource_new() / QuantumResource(resource_id, resource_type) / qrmi.new()) is completely unaffected, no existing code needs to change.

What’s new#

Language

What’s new

Rust

T::from_config(resource_id: &str, config: HashMap<String, String>) -> Result<T> on each resource type (e.g. IBMQuantumSystem::from_config, PasqalLocal::from_config, …).

C

New function qrmi_resource_new_from_config(resource_id, resource_type, config: *const QrmiConfigMap) -> *mut QrmiQuantumResource. QrmiConfigMap is a new type alias for the existing QrmiEnvironmentVariables struct, built the same way.

Python

New static method QuantumResource.from_config(resource_id: str, resource_type: ResourceType, config: dict[str, str]).

Lua

New function qrmi.new_from_config(resource_id, resource_type, config), taking a plain Lua table of string keys/values.

Keys by resource type#

Each resource type’s from_config accepts the same keys as its new()’s environment variables, minus only the eventual {backend_name}_ prefix. Every key also accepts its fully-lowercased form as a fallback (e.g. qrmi_ibm_qs_endpoint works alongside QRMI_IBM_QS_ENDPOINT).

See each type’s new()/from_config() rustdoc for the authoritative, per-resource key list: qrmi::ibm::IBMQuantumSystem, qrmi::ibm::IBMQiskitRuntimeService, qrmi::ibm::IBMQuantumComputeService, qrmi::pasqal::PasqalCloud, qrmi::pasqal::PasqalLocal, qrmi::alice_bob::AliceBobFelis, qrmi::iqm::IQMServer.

How to migrate#

No migration is required for existing code. This release only adds a new way to construct a resource, it doesn’t change or deprecate the old one. To start using it:

  1. Rust — Call T::from_config(resource_id, config) instead of T::new(resource_id):

    use qrmi::ibm::IBMQuantumComputeService;
    use std::collections::HashMap;
    
    let config = HashMap::from([
        ("QRMI_IBM_QCS_ENDPOINT".to_string(), "...".to_string()),
        ("QRMI_IBM_QCS_IAM_ENDPOINT".to_string(), "...".to_string()),
        ("QRMI_IBM_QCS_IAM_APIKEY".to_string(), "...".to_string()),
        ("QRMI_IBM_QCS_SERVICE_CRN".to_string(), "...".to_string()),
    ]);
    let qrmi = IBMQuantumComputeService::from_config("ibm_kingston", config)?;
    
  2. C — Call the new qrmi_resource_new_from_config() instead of qrmi_resource_new(), building a QrmiConfigMap the same way you’d build any other QrmiEnvironmentVariables-shaped value:

    QrmiKeyValue variables[] = {
        {(char *)"QRMI_WARDEN_URL", (char *)"http://localhost:8006"},
        {(char *)"QRMI_JOB_ID",     (char *)"1"},
        {(char *)"QRMI_JOB_UID",    (char *)"1000"},
    };
    QrmiConfigMap config = { .variables = variables, .length = 3 };
    
    QrmiQuantumResource *qrmi = qrmi_resource_new_from_config(
        "PASQAL_LOCAL", QRMI_RESOURCE_TYPE_PASQAL_LOCAL, &config);
    

    As with qrmi_resource_new(), the returned handle must be released with qrmi_resource_free() once it’s no longer needed.

  3. Python — Call the new QuantumResource.from_config() static method instead of the QuantumResource(resource_id, resource_type) constructor:

    from qrmi import QuantumResource, ResourceType
    
    qrmi = QuantumResource.from_config(
        "ibm_kingston",
        ResourceType.IBMQuantumComputeService,
        {
            "QRMI_IBM_QCS_ENDPOINT": "...",
            "QRMI_IBM_QCS_IAM_ENDPOINT": "...",
            "QRMI_IBM_QCS_IAM_APIKEY": "...",
            "QRMI_IBM_QCS_SERVICE_CRN": "...",
        },
    )
    
  4. Lua — Call the new qrmi.new_from_config() instead of qrmi.new(), passing a plain Lua table (string keys/values).

    local resource, err = qrmi.new_from_config("ibm_kingston", "ibm-quantum-compute-service", {
        QRMI_IBM_QCS_ENDPOINT = "...",
        QRMI_IBM_QCS_IAM_ENDPOINT = "...",
        QRMI_IBM_QCS_IAM_APIKEY = "...",
        QRMI_IBM_QCS_SERVICE_CRN = "...",
    })