dragon.workflows.runtime.Proxy
- class Proxy[source]
Bases:
DragonRuntime- __init__(sdesc, oob_net, cwd=None, remote_python_executable=None, local_runtime=None)[source]
Initialize a Proxy object for managing remote runtime connections.
- Parameters:
sdesc (dragon.infrastructure.messages.RuntimeDesc) – Serialized descriptor of the remote runtime containing connection information
oob_net (dragon.transport.oob.OutOfBand) – Out-of-band network connection to remote runtime for communication
cwd (str, optional) – Current working directory to use on remote runtime, defaults to None
remote_python_executable (str, optional) – Path to Python executable on remote runtime, defaults to None
Methods
__init__(sdesc, oob_net[, cwd, ...])Initialize a Proxy object for managing remote runtime connections.
close()Release transport resources without stopping a runtime.
detach()Detach from the proxy runtime.
disable()Deactivate this runtime, restoring the previously active one.
enable()Activate this runtime, making it the current one for the process.
get_env()Get the remote runtime environment variables.
Get the current working directory configured for the remote runtime.
Get the Python executable path configured for the remote runtime.
set_remote_cwd(cwd)Set the current working directory to use on the remote runtime.
set_remote_env(remote_env)Set the environment variables to use on the remote runtime.
Set the Python executable to use on the remote runtime.
stop(exit_path, remote_working_dir)Stop the runtime, if running.
- __init__(sdesc, oob_net, cwd=None, remote_python_executable=None, local_runtime=None)[source]
Initialize a Proxy object for managing remote runtime connections.
- Parameters:
sdesc (dragon.infrastructure.messages.RuntimeDesc) – Serialized descriptor of the remote runtime containing connection information
oob_net (dragon.transport.oob.OutOfBand) – Out-of-band network connection to remote runtime for communication
cwd (str, optional) – Current working directory to use on remote runtime, defaults to None
remote_python_executable (str, optional) – Path to Python executable on remote runtime, defaults to None
- detach()[source]
Detach from the proxy runtime.
This currently tears down the local helper runtime (if one was started for the proxy) and does not send a detach message to the remote runtime.
- __enter__()[source]
Enter the runtime context manager, activating this runtime.
- Returns:
This runtime instance
- Return type:
DragonRuntime
- __exit__(exc_type, exc_value, traceback)[source]
Exit the runtime context manager, restoring the previous runtime.
- enable()[source]
Activate this runtime, making it the current one for the process.
Pushes this runtime onto the process-global runtime stack together with a snapshot of the infrastructure environment it displaces, then calls the subclass
_activate()hook. The saved env letsdisable()restore whatever runtime (or base/local env) was active before, which is what makes nestedwithblocks work.Warning
Not thread-safe. This mutates process-global state (
os.environand theapi_setupconnection globals). Only enable/disable runtimes from a single thread, or serialize access externally.
- disable()[source]
Deactivate this runtime, restoring the previously active one.
Pops this runtime off the process-global stack (enforcing LIFO order), runs the subclass
_deactivate()hook, restores the infra env this runtime displaced, and — if a parent runtime remains on the stack — re-applies its non-infra (user) environment via_reactivate().Warning
Not thread-safe. See
enable().
- get_remote_cwd()[source]
Get the current working directory configured for the remote runtime.
- Returns:
Path to the remote working directory, or None if not set
- Return type:
str or None
- get_remote_python_executable()[source]
Get the Python executable path configured for the remote runtime.
- Returns:
Path to the remote Python executable, or None if not set
- Return type:
str or None
- set_remote_cwd(cwd)[source]
Set the current working directory to use on the remote runtime.
Configures the working directory that will be used when launching processes on the remote runtime.
- Parameters:
cwd (str) – Path to the desired working directory on the remote system
- set_remote_python_executable(remote_python_executable)[source]
Set the Python executable to use on the remote runtime.
Configures which Python interpreter will be used when launching Python processes on the remote runtime.
- Parameters:
remote_python_executable (str) – Path to the Python executable on the remote system