Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hyperion.HasWorkers
Contents
Synopsis
- class (MonadBase Process m, MonadUnliftProcess m, MonadIO m) => HasWorkers m where
- getWorkerLauncher :: m (WorkerLauncher JobId)
- class MonadUnliftProcess m where
- withRunInProcess :: ((forall a. m a -> Process a) -> Process b) -> m b
- class HasWorkerLauncher env where
- toWorkerLauncher :: env -> WorkerLauncher JobId
- withRemoteRun :: HasWorkers m => (RemoteProcessRunner -> m a) -> m a
- remoteEvalWithDictM :: (HasWorkers m, Serializable b) => Closure (Dict (Serializable b)) -> m (Closure (Process b)) -> m b
- remoteEvalM :: (HasWorkers m, Static (Binary b), Typeable b) => m (Closure (Process b)) -> m b
- remoteEval :: (HasWorkers m, Static (Binary b), Typeable b) => Closure (Process b) -> m b
Documentation
class (MonadBase Process m, MonadUnliftProcess m, MonadIO m) => HasWorkers m where Source #
A class for monads that can run things in the Process
monad,
and have access to a WorkerLauncher
. An instance of HasWorkers
can use remoteBind
and remoteEval
to run computations in worker
processes at remote locations.
Methods
getWorkerLauncher :: m (WorkerLauncher JobId) Source #
Instances
HasWorkerLauncher env => HasWorkers (ReaderT env Process) Source # | This is our main instance for |
Defined in Hyperion.HasWorkers Methods getWorkerLauncher :: ReaderT env Process (WorkerLauncher JobId) Source # |
class MonadUnliftProcess m where Source #
A class for Monads that can run continuations in the Process monad, modeled after MonadUnliftIO (https:/hackage.haskell.orgpackageunliftio-core-0.2.0.1docs/Control-Monad-IO-Unlift.html).
Methods
withRunInProcess :: ((forall a. m a -> Process a) -> Process b) -> m b Source #
Instances
MonadUnliftProcess Process Source # | |
Defined in Hyperion.HasWorkers Methods withRunInProcess :: ((forall a. Process a -> Process a) -> Process b) -> Process b Source # | |
MonadUnliftProcess m => MonadUnliftProcess (ReaderT r m) Source # | |
Defined in Hyperion.HasWorkers Methods withRunInProcess :: ((forall a. ReaderT r m a -> Process a) -> Process b) -> ReaderT r m b Source # |
class HasWorkerLauncher env where Source #
A class indicating that type env
contains a WorkerLauncher
.
Methods
toWorkerLauncher :: env -> WorkerLauncher JobId Source #
Instances
HasWorkerLauncher ClusterEnv Source # | We make |
Defined in Hyperion.Cluster Methods toWorkerLauncher :: ClusterEnv -> WorkerLauncher JobId Source # | |
HasWorkerLauncher JobEnv Source # | Make This makes |
Defined in Hyperion.Job Methods |
withRemoteRun :: HasWorkers m => (RemoteProcessRunner -> m a) -> m a Source #
Uses the WorkerLauncher
to get a RemoteProcessRunner
and pass it
to the given continuation.
This function is essentially a composition of getWorkerLauncher
with
withRemoteRunProcess
, lifted from Process
to m
using MonadUnliftProcess
.
We use the machinery of MonadUnliftProcess
because
withRemoteRunProcess
expects something that runs in the Process
monad, not in m
. Our main use case is when 'm ~ ReaderT env
Process', where env
is an instance of HasWorkerLauncher
.
remoteEvalWithDictM :: (HasWorkers m, Serializable b) => Closure (Dict (Serializable b)) -> m (Closure (Process b)) -> m b Source #
Compute a closure at a remote location. The user supplies an 'm (Closure (...))' which is only evaluated when a remote worker becomes available (for example after the worker makes it out of the Slurm queue).
remoteEvalM :: (HasWorkers m, Static (Binary b), Typeable b) => m (Closure (Process b)) -> m b Source #
Evaluate a Closure
at a remote location, assuming a 'Static
(Binary b)' instance. The Closure itself is ony computed when a
worker becomes available.
remoteEval :: (HasWorkers m, Static (Binary b), Typeable b) => Closure (Process b) -> m b Source #
Evaluate a Closure
at a remote location.