qdk_chemistry.remote.cache.folder module
Folder-based cache backend for QDK/Chemistry.
Stores job metadata and content-addressed data as plain files in a directory:
cache_dir/
<run_hash>.job.json # Job metadata
<content_hash>.<type_name>.h5 # DataClass blobs
<content_hash>.ndarray.npy # NumPy arrays
<content_hash>.list.json # Supported nested lists
Primitives (floats, ints, strings, …) are stored inline in the Job JSON and never written as separate files.
- qdk_chemistry.remote.cache.folder.CoreDataClass
alias of
DataClass
- qdk_chemistry.remote.cache.folder.instance_data_type_name(value)
Return a data-class instance’s wire-format identifier.
- qdk_chemistry.remote.cache.folder.get_dataclass_type(type_name)
Return the registered DataClass for a wire type name, if available.
- class qdk_chemistry.remote.cache.folder.CacheBackend(*, is_shared=False)
Bases:
ABCAbstract base class for result caches.
Implementations must provide these operations:
get_jobandput_jobpersistJobmetadata by run hash.get_dataandput_datastore supported values by content hash.delete_jobanddelete_dataremove cached metadata or blobs.clearremoves all cache entries.
- Parameters:
is_shared (
bool) – Set toTruewhen the backing store is reachable from multiple machines (e.g. a network-mounted folder). Defaults toFalse.
- __init__(*, is_shared=False)
Initialise the cache backend.
- Parameters:
is_shared (bool)
- Return type:
None
- abstractmethod get_job(run_hash)
Retrieve job metadata by run_hash, or
Noneon miss.
- abstractmethod put_job(run_hash, job)
Store (or update) job metadata keyed by run_hash.
- abstractmethod get_data(content_hash)
Retrieve cached data by its content hash, or
None.
- abstractmethod put_data(content_hash, data, *, shared_only=False)
Store data by content hash, optionally requiring shared storage.
- abstractmethod delete_job(run_hash)
Remove job metadata by run_hash. Returns
Trueif it existed.
- abstractmethod delete_data(content_hash)
Remove a DataClass blob by content hash. Returns
Trueif it existed.
Whether this cache is reachable from both local and remote.
- has_data(content_hash, *, shared_only=False)
Check whether a DataClass blob exists without deserializing it.
The default implementation calls
get_data()and checks forNone. Backends that can answer this more cheaply (e.g. aHEADrequest or aglob) should override. When shared_only is true, non-shared backends always returnFalse.
- to_config()
Return constructor kwargs sufficient to recreate this backend.
Subclasses should override this if they accept configuration (paths, URLs, credentials, etc.). The default returns an empty dict, which is only valid for backends that need no arguments.
- Return type:
- for_remote()
Return the cache view reachable from a remote compute node.
- Return type:
- qdk_chemistry.remote.cache.folder.is_cacheable(value)
Return whether a value can be stored as a cache data entry.
- class qdk_chemistry.remote.cache.folder.FolderCache(path, *, is_shared=False, **_kwargs)[source]
Bases:
CacheBackendContent-addressed folder cache.
- Parameters:
- put_data(content_hash, data, *, shared_only=False)[source]
Store data by content hash unless shared storage is required but unavailable.
- has_data(content_hash, *, shared_only=False)[source]
Fast existence check via glob (no deserialization).
- delete_job(run_hash)[source]
Remove job metadata by run_hash.
Only the
.job.jsonfile is deleted. Data blobs are left intact because they may be referenced by other jobs.