qdk_chemistry.remote.cache.folder module
Folder-based cache backend for QDK/Chemistry.
Stores job metadata and DataClass blobs as plain files in a directory:
cache_dir/
<run_hash>.job.json # Job metadata
<content_hash>.<type_name>.h5 # DataClass blobs
Primitives (floats, ints, strings, …) are stored inline in the Job JSON and never written as separate files.
- class qdk_chemistry.remote.cache.folder.CacheBackend(*, is_shared=False)
Bases:
ABCAbstract base class for result caches.
Implementations must provide these operations:
get_job / put_job: persist
Jobmetadata keyed by the deterministic run_hash.get_data / put_data: content-addressed storage for
DataClassobjects. Primitives (floats, ints, …) are stored inline in the Job metadata and never touch these methods.delete_job / delete_data: remove cached metadata or blobs.
clear: remove all entries from the cache.
- Parameters:
is_shared (bool) – Set to
Truewhen 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 a DataClass object (or list) by its content hash, or
None.
- abstractmethod put_data(content_hash, data)
Store a DataClass object (or list) by its content hash.
- 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)
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.
- class qdk_chemistry.remote.cache.folder.FolderCache(path, *, is_shared=False, **_kwargs)[source]
Bases:
CacheBackendContent-addressed folder cache.
- Parameters:
path (str | pathlib.Path) – Directory to use as the cache root. Created on first write.
is_shared (bool) –
Truewhen this directory is a network mount reachable from remote compute nodes._kwargs (Any)
- 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.