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:

SlurmFuture(future, job_id)

Encapsulates asynchronous launch of Fluent within a Slurm environment.

SlurmLauncher(**kwargs)

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:

add_done_callback(fn)

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, otherwise False.

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, otherwise False.

result([timeout])

Return the session instance corresponding to the Fluent launch.

running()

Return True if Fluent is currently running, otherwise False.

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:
fnCallable

Callback function.

cancel(timeout=60)#

Attempt to cancel the Fluent launch within timeout seconds.

Parameters:
timeoutint, optional

timeout in seconds, by default 60

Returns:
bool

True if the Fluent launch is successfully cancelled, otherwise False.

done()#

Return True if the Fluent launch was successfully cancelled or Fluent was finished running, otherwise False.

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.

Parameters:
timeoutint, optional

timeout in seconds

Returns:
Exception

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, otherwise False.

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:
timeoutint, optional

timeout in seconds

Returns:
Union [Meshing, PureMeshing, Solver, SolverIcing]

The session instance corresponding to the Fluent launch.

running()#

Return True if Fluent is currently running, otherwise False.

class ansys.fluent.core.launcher.slurm_launcher.SlurmLauncher(**kwargs)#

Bases: object

Instantiates Fluent session within a Slurm environment.