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 propertyrunner
will return theOOMMFRunner
object from the cache. Setting this parameter toFalse
will cause it to check for available methods again. Defaults toTrue
.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.
Return repr(self).
Find the best available way to run OOMMF.
Properties
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
, anddocker_runner
, in this order. If no runner can be found anEnvironmentError
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
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()
. Ifcache_runner
isTrue
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 callingrunner.status
.Examples
Getting OOMMF Runner.
>>> import oommfc as oc ... >>> runner = oc.runner.runner >>> isinstance(runner, oc.oommf.OOMMFRunner) True
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