PyFrag
|
Public Member Functions | |
def | __init__ (self, name='plamsjob', settings=None, depend=None) |
def | __getstate__ (self) |
def | run (self, jobrunner=None, jobmanager=None, kwargs) |
def | pickle (self, filename=None) |
def | check (self) |
def | hash (self) |
def | prerun (self) |
def | postrun (self) |
Public Attributes | |
status | |
results | |
name | |
path | |
jobmanager | |
parent | |
settings | |
default_settings | |
depend | |
General abstract class for all kind of computational tasks. Methods common for all kinds of jobs are gathered here. Instances of |Job| should never be created. It should not be subclassed either. If you wish to define a new type of job please subclass either |SingleJob| or |MultiJob|. Methods that are meant to be explicitly called by the user are |run| and occasionally :meth:`~Job.pickle`. In most cases |pickling| is done automatically, but if for some reason you wish to do it manually, you can use :meth:`~Job.pickle` method. Methods that can be safely overridden in subclasses are: * :meth:`~Job.check` * :meth:`~Job.hash` (see |RPM|) * |prerun| and |postrun| (see :ref:`prerun-postrun`) Other methods should remain unchanged. Class attribute ``_result_type`` defines the type of results associated with this job. It should point to a class and it **must** be a |Results| subclass. Every job instance has the following attributes. Values of these attributes are adjusted automatically and should not be set by the user: * ``status`` -- current status of the job in human-readable format. * ``results`` -- reference to a results instance. An empty instance of the type stored in ``_result_type`` is created when the job constructor is called. * ``path`` -- an absolute path to the job folder. * ``jobmanager`` -- a job manager associated with this job. * ``parent`` -- a pointer to the parent job if this job is a child job of some |MultiJob|. ``None`` otherwise. These attributes can be modified, but only before |run| is called: * ``name`` -- the name of the job. * ``settings`` -- settings of the job. * ``default_settings`` -- see :ref:`default-settings`. * ``depend`` -- a list of explicit dependencies. * ``_dont_pickle`` -- additional list of this instance's attributes that will be removed before pickling. See :ref:`pickling` for details.
def qmworks.plams.core.basejob.Job.__getstate__ | ( | self | ) |
Prepare an instance for pickling. Attributes ``jobmanager``, ``parent``, ``default_settings`` and ``_lock`` are removed, as well as all attributes listed in ``self._dont_pickle``.
def qmworks.plams.core.basejob.Job.check | ( | self | ) |
Check if the calculation was successful. This method can be overridden in concrete subclasses for different types of jobs. It should return a boolean value. The definition here serves as a default, to prevent crashing if a subclass does not define its own :meth:`~scm.plams.basejob.Job.check`. It always returns ``True``.
def qmworks.plams.core.basejob.Job.hash | ( | self | ) |
Calculate the hash of this instance. Abstract method.
def qmworks.plams.core.basejob.Job.pickle | ( | self, | |
filename = None |
|||
) |
Pickle this instance and save to a file indicated by *filename*. If ``None``, save to ``[jobname].dill`` in the job folder.
def qmworks.plams.core.basejob.Job.postrun | ( | self | ) |
Actions to take just after the actual job execution. This method is initially empty, it can be defined in subclasses or directly added to either whole class or a single instance using |binding_decorators|.
def qmworks.plams.core.basejob.Job.prerun | ( | self | ) |
Actions to take before the actual job execution. This method is initially empty, it can be defined in subclasses or directly added to either whole class or a single instance using |binding_decorators|.
def qmworks.plams.core.basejob.Job.run | ( | self, | |
jobrunner = None , |
|||
jobmanager = None , |
|||
kwargs | |||
) |
Run the job using *jobmanager* and *jobrunner* (or defaults, if ``None``). Other keyword arguments (*\*\*kwargs*) are stored in ``run`` branch of job's settings. Returned value is the |Results| instance associated with this job. .. note:: This method should **not** be overridden. .. technical:: This method does not do too much by itself. After simple initial preparation it passes control to job runner, which decides if a new thread should be started for this job. The role of the job runner is to execute three methods that make the full job life cycle: :meth:`~Job._prepare`, :meth:`~Job._execute` and :meth:`~Job._finalize`. During :meth:`~Job._execute` the job runner is called once again to execute the runscript (only in case of |SingleJob|).