Source code for puffin.jobs.sleep

# -*- coding: utf-8 -*-
__copyright__ = """This file is part of SCINE Puffin.
This code is licensed under the 3-clause BSD license.
Copyright ETH Zurich, Laboratory for Physical Chemistry, Reiher Group.
See LICENSE.txt for details
"""

import io
from time import sleep
from puffin.config import Configuration
from .job import Job


[docs]class Sleep(Job): """ A dummy job used for debug purposes. The job sleeps for a given amount of time. **Order Name** ``sleep`` **Optional Settings** Optional settings are read from the ``settings`` field, which is part of any ``Calculation`` stored in a SCINE Database. Possible settings for this job are: time :: int The time to sleep for in seconds. Default: 300. **Required Packages** - SCINE: Database (present by default) **Generated Data** This dummy job does not generate new data. """ def __init__(self): super().__init__() def run(self, manager, calculation, config: Configuration) -> bool: import scine_database as db # Gather all required collections calculations = manager.get_collection('calculations') # Link calculation if needed if not calculation.has_link(): calculation.link(calculations) # Get the requested sleep time sleeptime = 300 settings = calculation.get_settings() if 'time' in settings: sleeptime = int(settings['time']) sleep(sleeptime) calculation.set_executor(config['daemon']['uuid']) calculation.set_status(db.Status.COMPLETE) return True def required_programs(self): return ['database']