rhapsody.backends.execution.concurrent¶
Concurrent distributed execution backend for parallel and distributed computing.
This module provides a backend that executes tasks on local or single node HPC resources.
ConcurrentExecutionBackend
¶
Bases: BaseBackend
Simple async-only concurrent execution backend.
Attributes:
-
term_grace(float) –Seconds a cancelled command has to exit after SIGTERM, before SIGKILL.
-
kill_wait(float) –Seconds to wait for a command to finish after SIGKILL.
Source code in src/rhapsody/backends/execution/concurrent.py
__await__
¶
topology
¶
Single node: local GPU count, cores capped at the executor's worker count.
Source code in src/rhapsody/backends/execution/concurrent.py
submit_tasks
async
¶
Submit tasks for execution.
The backend keeps a task in tasks, and its handler in the task's "future", until
the task ends.
Source code in src/rhapsody/backends/execution/concurrent.py
cancel_task
async
¶
Cancel a task by its UID.
Parameters:
-
uid(str) –The UID of the task to cancel.
Returns:
-
bool(bool) –True if the task was found and cancellation was attempted, False otherwise.
Source code in src/rhapsody/backends/execution/concurrent.py
cancel_all_tasks
async
¶
Cancel all running tasks, and wait for their commands to stop.
Source code in src/rhapsody/backends/execution/concurrent.py
shutdown
async
¶
Shutdown the executor.
Source code in src/rhapsody/backends/execution/concurrent.py
state
async
¶
Get backend state.
Returns:
-
str(str) –Current backend state (INITIALIZED, RUNNING, SHUTDOWN)
__aenter__
async
¶
__aexit__
async
¶
create
async
classmethod
¶
create(executor: Executor) -> ConcurrentExecutionBackend
Alternative factory method for creating initialized backend.
Parameters:
-
executor(Executor) –A concurrent.Executor instance (ThreadPoolExecutor or ProcessPoolExecutor).
Returns:
-
ConcurrentExecutionBackend–Fully initialized ConcurrentExecutionBackend instance.
Source code in src/rhapsody/backends/execution/concurrent.py
register_callback
¶
Register a callback function for task state changes.
This chains the user's callback with the internal callback used by wait_tasks(). Both callbacks will be invoked on every state change.
Parameters:
-
func(Callable[[dict[str, Any], str], None]) –A callable that will be invoked when task states change. The function should accept task and state parameters.
Source code in src/rhapsody/backends/base.py
register_emitter
¶
register_emitter(emitter: Emitter) -> None
Receive the telemetry emitter, like :meth:register_callback receives the callback.
The :class:~rhapsody.telemetry.manager.TelemetryManager calls this when the backend is
attached to a session or workflow engine that has telemetry (it is called again, with a
new emitter, if the backend is attached to another manager). The default stores the
emitter in self.telemetry, which the backend then uses to report plain data. Override
it to react to the handoff and call super().register_emitter(emitter).
Parameters:
-
emitter(Emitter) –The handle with
enabledandemit(...).
Source code in src/rhapsody/backends/base.py
is_available
classmethod
¶
Return True if this backend's runtime dependencies are importable.
Used by :func:rhapsody.backends.discover_backends. A backend module imports even when
its optional runtime (Dragon, Dask, Orbit, ...) is missing, so backends with
optional dependencies override this to report whether they can actually be created.