Skip to content

Commit

Permalink
Add manual trigger to AMSJobLogTailHandler SCMSUITE-10077 SO107
Browse files Browse the repository at this point in the history
  • Loading branch information
dormrod committed Oct 22, 2024
1 parent 08f62cf commit 7fb4b40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion interfaces/adfsuite/ams.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Dict, List, Literal, Set, Union

import numpy as np

from scm.plams.core.basejob import SingleJob
from scm.plams.core.errors import FileError, JobError, PlamsError, PTError, ResultsError
from scm.plams.core.functions import config, log, parse_heredoc
Expand Down Expand Up @@ -67,6 +68,12 @@ def on_any_event(self, event):
except FileNotFoundError:
self._seekto = 0

def trigger(self):
if self._job.path is None:
return
src_path = os.path.join(self._job.path, "ams.log")
self.on_any_event(FileModifiedEvent(src_path))

except ImportError:
_has_watchdog = False

Expand Down Expand Up @@ -2199,7 +2206,8 @@ def __init__(self, molecule: Union[Molecule, Dict[str, Molecule], None] = None,
def run(self, jobrunner=None, jobmanager=None, watch=False, **kwargs) -> AMSResults:
"""Run the job using *jobmanager* and *jobrunner* (or defaults, if ``None``).
If *watch* is set to ``True``, the contents of the AMS driver logfile will be forwarded line by line to the PLAMS logfile (and stdout), allowing for an easier monitoring of the running job. Not that the forwarding of the AMS driver logfile will cause make the call to this method block until the job's execution has finished, even when using a parallel |JobRunner|.
If *watch* is set to ``True``, the contents of the AMS driver logfile will be forwarded line by line to the PLAMS logfile (and stdout), allowing for an easier monitoring of the running job.
Not that the forwarding of the AMS driver logfile will make the call to this method block until the job's execution has finished, even when using a parallel |JobRunner|.
Other keyword arguments (*\*\*kwargs*) are stored in ``run`` branch of job's settings.
Expand All @@ -2220,6 +2228,7 @@ def run(self, jobrunner=None, jobmanager=None, watch=False, **kwargs) -> AMSResu
try:
results = super().run(jobrunner=jobrunner, jobmanager=jobmanager, **kwargs)
results.wait()
event_handler.trigger()
finally:
observer.stop()
observer.join()
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ numpy==1.23.4
scipy==1.9.3
natsort==8.1.0
ase==3.22.1
rdkit==2024.03.1
rdkit==2024.03.1
networkx==2.8.8
watchdog==2.1.8

0 comments on commit 7fb4b40

Please sign in to comment.