Runner#

class oommfc.oommf.Runner#

Control the default runner.

Parameters:
  • cache_runner (bool) – If True the best way to run OOMMF is only determined once and the result is cached. Subsequent calls to the property runner will return the OOMMFRunner object from the cache. Setting this parameter to False will cause it to check for available methods again. Defaults to True.

  • envvar (str) – Name of the environment variable containing the path to oommf.tcl. Defaults to 'OOMMFTCL'.

  • oommf_exe (str) – The name or path of the executable oommf command. Defaults to 'oommf'.

  • docker_exe (str) – The name or path of the docker command. Defaults to 'docker'.


Methods

__dir__

Default dir() implementation.

__eq__

Return self==value.

__repr__

Return repr(self).

autoselect_runner

Find the best available way to run OOMMF.

Properties

runner

Return default OOMMF runner.


__repr__()#

Return repr(self).

autoselect_runner()#

Find the best available way to run OOMMF.

The function tries to find a suitable runner by checking envvar, ooommf_exe, and docker_runner, in this order. If no runner can be found an EnvironmentError is raised.

This method is also used to determine the default runner for the runner property as long as no runner has been cached. The method can be used to reset the default runner when a different runner has been set explicitly.

Raises:

EnvironmentError – If no OOMMF can be found on host.

Examples

  1. Setting best runner

>>> import oommfc as oc
...
>>> oc.runner.autoselect_runner()
>>> isinstance(oc.runner.runner, oc.oommf.OOMMFRunner)
True
property runner#

Return default OOMMF runner.

The default runner is determined using autoselect_runner(). If cache_runner is True the runner is cached during the first call and the same runner is returned in subsequent calls to this property.

This property also allows to set a specific OOMMFRunner. Before setting, a new runner is first checked to be functional by calling runner.status.

Examples

  1. Getting OOMMF Runner.

>>> import oommfc as oc
...
>>> runner = oc.runner.runner
>>> isinstance(runner, oc.oommf.OOMMFRunner)
True
  1. Setting OOMMF Runner.

>>> import oommfc as oc  
...
>>> oc.runner.runner = oc.oommf.DockerOOMMFRunner()  
Running OOMMF ...
OOMMF found and running.
>>> isinstance(oc.runner.runner,
...            oc.oommf.DockerOOMMFRunner)  
True