Source code for nowcast.next_workers

# Copyright 2016-2019 Doug Latornell, 43ravens
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Functions to calculate lists of workers to launch after previous workers
end their work.

Function names **must** be of the form :py:func:`after_worker_name`.
"""
from nemo_nowcast import NextWorker


[docs]def after_download_weather(msg, config, checklist): """Calculate the list of workers to launch after the download_weather worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ next_workers = {"crash": [], "failure": [], "success": []} if msg.type == "success": next_workers[msg.type] = [ NextWorker( "nowcast.workers.make_weather_forcing", args=["--weather-date", msg.payload["forecast date"]]) ] return next_workers[msg.type]
[docs]def after_make_weather_forcing(msg, config, checklist): """Calculate the list of workers to launch after the make_weather_forcing worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ next_workers = {"crash": [], "failure": [], "success": []} if msg.type == "success": next_workers[msg.type] = [ NextWorker( "nowcast.workers.download_psy4", args=["--psy4-date", msg.payload["weather date"]] ) ] return next_workers[msg.type]
[docs]def after_download_psy4(msg, config, checklist): """Calculate the list of workers to launch after the download_psy4 worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ next_workers = {"crash": [], "failure": [], "success": []} if msg.type == "success": next_workers[msg.type] = [ NextWorker( "nowcast.workers.make_boundary_conditions", args=["--psy4-date", msg.payload["psy4 date"]], ) ] return next_workers[msg.type]
[docs]def after_make_boundary_conditions(msg, config, checklist): """Calculate the list of workers to launch after the make_boundary_conditions worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ next_workers = {"crash": [], "failure": [], "success": []} if msg.type == "success": next_workers[msg.type] = [ NextWorker("nowcast.workers.run_nemo", args=["--run-date", msg.payload["psy4 date"]]) ] return next_workers[msg.type]
[docs]def after_run_nemo(msg, config, checklist): """Calculate the list of workers to launch after the run_nemo worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ next_workers = { "crash": [], "failure": [], "success": [NextWorker("nowcast.workers.watch_nemo")], } return next_workers[msg.type]
[docs]def after_watch_nemo(msg, config, checklist): """Calculate the list of workers to launch after the watch_nemo worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ next_workers = {"crash": [], "failure": [], "success": []} if msg.type == "success": run_date = checklist["NEMO run"]["nowcast"]["run date"] next_workers[msg.type] = [ NextWorker("nowcast.workers.make_plots", args=["--run-date", run_date]) ] return next_workers[msg.type]
[docs]def after_make_plots(msg, config, checklist): """Calculate the list of workers to launch after the make_plots worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ next_workers = { "crash": [], "failure": [], "success": [NextWorker("nemo_nowcast.workers.clear_checklist")], } return next_workers[msg.type]
[docs]def after_clear_checklist(msg, config, checklist): """Calculate the list of workers to launch after the clear_checklist worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ next_workers = { "crash": [], "failure": [], "success": [NextWorker("nemo_nowcast.workers.rotate_logs")], } return next_workers[msg.type]
[docs]def after_rotate_logs(msg, config, checklist): """Calculate the list of workers to launch after the rotate_logs worker ends. :arg msg: Nowcast system message. :type msg: :py:class:`nemo_nowcast.message.Message` :returns: Worker(s) to launch next :rtype: list """ return []