hyperion-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Hyperion.HasWorkers

Synopsis

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.

Instances

Instances details
HasWorkerLauncher env => HasWorkers (ReaderT env Process) Source #

This is our main instance for HasWorkers. The Cluster and Job monads are both cases of 'ReaderT env Process' with different envs.

Instance details

Defined in Hyperion.HasWorkers

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

Instances details
MonadUnliftProcess Process Source # 
Instance details

Defined in Hyperion.HasWorkers

Methods

withRunInProcess :: ((forall a. Process a -> Process a) -> Process b) -> Process b Source #

MonadUnliftProcess m => MonadUnliftProcess (ReaderT r m) Source # 
Instance details

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.

Instances

Instances details
HasWorkerLauncher ClusterEnv Source #

We make ClusterEnv an instance of HasWorkerLauncher. This makes Cluster an instance of HasWorkers and gives us access to functions in Hyperion.Remote.

Instance details

Defined in Hyperion.Cluster

HasWorkerLauncher JobEnv Source #

Make JobEnv an instance of HasWorkerLauncher. The WorkerLauncher returned by toWorkerLauncher launches workers with jobTaskCpus CPUs available to them.

This makes Job an instance of HasWorkers and gives us access to functions in Hyperion.Remote.

Instance details

Defined in Hyperion.Job

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.

Orphan instances

MonadBase Process Process Source #

Trivial orphan instance of MonadBase for Process.

Instance details

Methods

liftBase :: Process α -> Process α