pydvl.parallel.futures.ray
¶
RayExecutor
¶
RayExecutor(
max_workers: Optional[int] = None,
*,
config: Optional[ParallelConfig] = None,
cancel_futures: Union[CancellationPolicy, bool] = CancellationPolicy.ALL
)
Bases: Executor
Asynchronous executor using Ray that implements the concurrent.futures API.
PARAMETER | DESCRIPTION |
---|---|
max_workers |
Maximum number of concurrent tasks. Each task can request
itself any number of vCPUs. You must ensure the product of this
value and the n_cpus_per_job parameter passed to submit() does not
exceed available cluster resources. If set to |
cancel_futures |
Select which futures will be cancelled when exiting this
context manager.
TYPE:
|
Source code in src/pydvl/parallel/futures/ray.py
submit
¶
Submits a callable to be executed with the given arguments.
Schedules the callable to be executed as fn(*args, **kwargs) and returns a Future instance representing the execution of the callable.
PARAMETER | DESCRIPTION |
---|---|
fn |
Callable.
TYPE:
|
args |
Positional arguments that will be passed to
DEFAULT:
|
kwargs |
Keyword arguments that will be passed to
DEFAULT:
|
Returns: A Future representing the given call.
RAISES | DESCRIPTION |
---|---|
RuntimeError
|
If a task is submitted after the executor has been shut down. |
Source code in src/pydvl/parallel/futures/ray.py
shutdown
¶
Clean up the resources associated with the Executor.
This method tries to mimic the behaviour of
Executor.shutdown
while allowing one more value for cancel_futures
which instructs it
to use the CancellationPolicy
defined upon construction.
PARAMETER | DESCRIPTION |
---|---|
wait |
Whether to wait for pending futures to finish.
TYPE:
|
cancel_futures |
Overrides the executor's default policy for
cancelling futures on exit. If |