From 7fb4b404630dd370cfa7826533bd486643eb9f02 Mon Sep 17 00:00:00 2001 From: David Ormrod Morley Date: Mon, 21 Oct 2024 12:12:44 +0200 Subject: [PATCH] Add manual trigger to AMSJobLogTailHandler SCMSUITE-10077 SO107 --- interfaces/adfsuite/ams.py | 11 ++++++++++- requirements.txt | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/interfaces/adfsuite/ams.py b/interfaces/adfsuite/ams.py index e5212515..ee8b8167 100644 --- a/interfaces/adfsuite/ams.py +++ b/interfaces/adfsuite/ams.py @@ -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 @@ -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 @@ -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. @@ -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() diff --git a/requirements.txt b/requirements.txt index b442c7fb..2d1b016e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,6 @@ numpy==1.23.4 scipy==1.9.3 natsort==8.1.0 ase==3.22.1 -rdkit==2024.03.1 \ No newline at end of file +rdkit==2024.03.1 +networkx==2.8.8 +watchdog==2.1.8 \ No newline at end of file