Slurm launcher#
Provides a module for launching Fluent within a Slurm environment.
Examples#
Note that the keys scheduler_headnode
, scheduler_queue
and scheduler_account
are optional and should be specified in a similar manner to Fluent’s scheduler options.
>>> slurm = pyfluent.launch_fluent(
... scheduler_options={
... "scheduler": "slurm",
... "scheduler_headnode": "<headnode>",
... "scheduler_queue": "<queue>",
... "scheduler_account": "<account>"
... },
... additional_arguments="-t16 -cnf=m1:8,m2:8",
... )
>>> type(slurm)
<class 'ansys.fluent.core.launcher.slurm_launcher.SlurmFuture'>
>>> slurm.pending(), slurm.running(), slurm.done() # before Fluent is launched
(True, False, False)
>>> slurm.pending(), slurm.running(), slurm.done() # after Fluent is launched
(False, True, False)
>>> session = slurm.result()
>>> type(session)
<class 'ansys.fluent.core.session_solver.Solver'>
>>> session.exit()
>>> slurm.pending(), slurm.running(), slurm.done()
(False, False, True)
Classes:
|
Encapsulates asynchronous launch of Fluent within a Slurm environment. |
|
Instantiates Fluent session within a Slurm environment. |
- class ansys.fluent.core.launcher.slurm_launcher.SlurmFuture(future, job_id)#
Bases:
object
Encapsulates asynchronous launch of Fluent within a Slurm environment.
The interface is similar to Python’s future object.
Methods:
Attaches the callable function.
cancel
([timeout])Attempt to cancel the Fluent launch within timeout seconds.
done
()Return
True
if the Fluent launch was successfully cancelled or Fluent was finished running, otherwiseFalse
.exception
([timeout])Return the exception raised by the Fluent launch.
pending
()Return
True
if the Fluent launch is currently waiting for Slurm allocation or Fluent is being launched, otherwiseFalse
.result
([timeout])Return the session instance corresponding to the Fluent launch.
running
()Return
True
if Fluent is currently running, otherwiseFalse
.- add_done_callback(fn)#
Attaches the callable function. The function will be called, with the session as its only argument, when Fluent is launched.
- Parameters:
- fn
Callable
Callback function.
- fn
- cancel(timeout=60)#
Attempt to cancel the Fluent launch within timeout seconds.
- done()#
Return
True
if the Fluent launch was successfully cancelled or Fluent was finished running, otherwiseFalse
.
- exception(timeout=None)#
Return the exception raised by the Fluent launch. If Fluent hasn’t yet launched, then this method will wait up to timeout seconds. If Fluent hasn’t launched in timeout seconds, then a TimeoutError will be raised. If timeout is not specified or None, there is no limit to the wait time.
If the Fluent launch completed without raising, None is returned.
- pending()#
Return
True
if the Fluent launch is currently waiting for Slurm allocation or Fluent is being launched, otherwiseFalse
.
- result(timeout=None)#
Return the session instance corresponding to the Fluent launch. If Fluent hasn’t yet launched, then this method will wait up to timeout seconds. If Fluent hasn’t launched in timeout seconds, then a TimeoutError will be raised. If timeout is not specified or None, there is no limit to the wait time.
If the Fluent launch raised an exception, this method will raise the same exception.
- Parameters:
- timeout
int
,optional
timeout in seconds
- timeout
- Returns:
Union
[Meshing
,PureMeshing
,Solver
,SolverIcing
]The session instance corresponding to the Fluent launch.
- running()#
Return
True
if Fluent is currently running, otherwiseFalse
.