qdk_chemistry.remote.backends.local module

Local backend for testing remote execution of QDK/Chemistry algorithms.

This backend simulates remote execution by running in a subprocess on the local machine. Useful for testing and development.

class qdk_chemistry.remote.backends.local.LocalBackend(*, poll_interval=DEFAULT_POLL_INTERVAL, timeout=DEFAULT_TIMEOUT, python_path=sys.executable)[source]

Bases: RemoteBackend

Backend for local execution (useful for testing remote workflows).

This backend simulates the remote execution workflow locally:

  • “Upload” copies files to a temporary directory

  • “Execute” runs the script in a subprocess

  • “Download” copies files back from the temporary directory

This is useful for:

  • Testing remote execution workflows without a remote system

  • Debugging serialization and script generation

  • Running algorithms in isolated subprocesses

Config options:

timeout (int): Execution timeout in seconds (default: 3600).

Example

>>> from qdk_chemistry.algorithms import create
>>>
>>> scf = create("scf_solver")
>>> energy, wfn = scf.run(structure, 0, 1, "cc-pvdz",
...                       cache="./cache", remote="local")
Parameters:
mcp_safe_config_options: ClassVar[frozenset[str]] = frozenset({'poll_interval', 'timeout'})

Constructor options that MCP clients may control.

Concrete backends must declare this attribute directly on the class to expose any options through MCP. The default is deny-all.

__init__(*, poll_interval=DEFAULT_POLL_INTERVAL, timeout=DEFAULT_TIMEOUT, python_path=sys.executable)[source]

Initialize the local backend.

Parameters:
  • poll_interval (float) – Seconds between job status checks.

  • timeout (float) – Maximum execution time in seconds.

  • python_path (str | Path) – Python executable used to launch the remote worker.

Return type:

None

connect()[source]

Create a temporary working directory.

Return type:

None

disconnect()[source]

Remove the connection workspace when it contains no jobs.

Return type:

None

upload(local_path, remote_path)[source]

Copy a file to the ‘remote’ working directory.

Parameters:
  • local_path (str | Path) – Path to local file.

  • remote_path (str) – Destination path (relative to workdir or absolute).

Return type:

None

download(remote_path, local_path)[source]

Copy a file from the ‘remote’ working directory.

Parameters:
  • remote_path (str) – Path to file in workdir.

  • local_path (str | Path) – Destination path on local system.

Return type:

None

check(backend_state)[source]

Check whether the background subprocess has finished.

Parameters:

backend_state (dict) – Persisted state for the submitted local job.

Return type:

JobStatus

cancel(backend_state)[source]

Kill the background subprocess.

Parameters:

backend_state (dict) – Persisted state for the submitted local job.

Return type:

None

fetch(backend_state, local_dir=None)[source]

Deserialize results from a completed local job.

Parameters:
  • backend_state (dict) – Persisted state for the completed local job.

  • local_dir (str | Path | None) – Optional directory for downloaded result files.

Return type:

Any

cleanup_job(backend_state)[source]

Remove one local job directory and its parent when empty.

Parameters:

backend_state (dict) – Persisted state for the terminal local job.

Return type:

None

name: str = 'local'