qdk_chemistry.remote.job module
Persistent job handle for QDK/Chemistry.
A Job records algorithm metadata, content hashes, and status for
cached computations. Instances serialise to JSON so that results can
be recovered across sessions.
- class qdk_chemistry.remote.job.Job(*, job_id, backend, backend_config, backend_state, algorithm_info=None, status='submitted', submitted_at=None, file_path=None, run_hash=None, input_hashes=None, output_hashes=None, output_is_tuple=None, owner=None)[source]
Bases:
objectPersistent handle for a cached computation.
Instances serialise to a JSON file on disk, making them the canonical record of a cached algorithm run.
- Parameters:
- job_id
Short unique identifier for this job.
- backend
Registered backend name (e.g.
"local").
- backend_config
Dict of configuration that was passed to the backend constructor (pool, gpus, host, …). Stored so the backend can be re-created from scratch.
- backend_state
Opaque dict written by the backend during submit. Contains whatever the backend needs to poll / cancel / fetch (operation IDs, remote paths, PIDs, …).
- algorithm_info
Dict with
type,name,settingsof the algorithm that was submitted.
- status
Last-known status string.
- submitted_at
ISO-8601 timestamp of submission.
- file_path
Path to the job file on disk (
Noneif not persisted yet).
- run_hash
Deterministic hash of the algorithm, settings, and inputs. Used for cache lookups.
Noneif not computed.
- input_hashes
Per-item content hashes of the submitted inputs, keyed by namespaced argument name (e.g.
"args.arg_0","kwargs.charge").Noneif not recorded.
- output_hashes
Per-item result descriptors. Each entry is a dict with
"hash"and"type"keys. Primitives also carry a"value"key so they can be reconstructed without a cache backend. Populated when results are fetched.Noneuntil results are retrieved.
- output_is_tuple
Whether the retrieved result is a tuple.
Noneuntil results are retrieved.
- owner
Workspace and project permitted to manage the job through MCP.
Nonefor unowned SDK jobs.
- __init__(*, job_id, backend, backend_config, backend_state, algorithm_info=None, status='submitted', submitted_at=None, file_path=None, run_hash=None, input_hashes=None, output_hashes=None, output_is_tuple=None, owner=None)[source]
Initialise a Job from its constituent parts.
- Parameters:
job_id (
str) – Unique identifier assigned by the backend.backend (
str) – Registered backend name.backend_config (
dict[str,Any]) – Configuration used to reconstruct the backend.backend_state (
dict[str,Any]) – Persisted backend-specific job state.algorithm_info (
dict[str,Any] |None) – Submitted algorithm type, name, and settings.status (
str) – Initial job status.file_path (
str|Path|None) – Optional path for the persisted job record.run_hash (
str|None) – Deterministic hash used for cache lookup.input_hashes (
dict[str,str] |None) – Content hashes for submitted inputs.output_hashes (
list[dict[str,Any]] |None) – Content-hash descriptors for retrieved outputs.output_is_tuple (
bool|None) – Whether the retrieved result is a tuple.owner (
dict[str,str|None] |None) – Workspace and project permitted to manage this job through MCP.
- attach_backend(backend)[source]
Associate this in-memory job with its submitting backend.
- Return type:
- Parameters:
backend (RemoteBackend)
- fetch(local_dir=None, *, cleanup=False)[source]
Download and persist results, then optionally remove backend artifacts.
- cleanup()[source]
Remove backend artifacts for this terminal job.
Repeated cleanup is safe when supported by the backend.
- Raises:
RuntimeError – If the job has not reached a terminal state.
- Return type:
- wait()[source]
Block until the job reaches a terminal state.
- Return type:
- Returns:
The final status reported by the backend.
- Raises:
TimeoutError – If the configured timeout expires before completion.