Ejemplo n.º 1
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.make_CHS_currents_file --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        "run_type",
        choices={"nowcast", "forecast", "forecast2"},
        help="""
        Type of run the velocities come from:
        'nowcast' means velocities stored in nowcast-blue directory
        'forecast' means velocities stored in forecast directory
        'forecast2' means velocities stored in forecast2 directory
        """,
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Date to process the velocities for.",
    )
    worker.run(make_CHS_currents_file, success, failure)
Ejemplo n.º 2
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.collect_weather --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        "forecast",
        choices={"00", "06", "12", "18"},
        help="Name of forecast to collect files for.",
    )
    worker.cli.add_argument(
        "resolution",
        choices={"1km", "2.5km"},
        default="2.5km",
        help="Horizontal resolution of forecast to download files from.",
    )
    worker.cli.add_argument(
        "--backfill",
        action="store_true",
        help="Download forecast files for previous day's date.",
    )
    worker.cli.add_date_option(
        "--backfill-date",
        default=arrow.now().floor("day").shift(days=-1),
        help="Prior date to collect forecast files for.",
    )
    worker.run(collect_weather, success, failure)
    return worker
Ejemplo n.º 3
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.download_fvcom_results --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        "host_name", help="Name of the host to download results files from")
    worker.cli.add_argument(
        "model_config",
        choices={"r12", "x2"},
        help="""
        Model configuration to download results files from:
        'r12' means the r12 resolution
        'x2' means the x2 resolution
        """,
    )
    worker.cli.add_argument(
        "run_type",
        choices={"nowcast", "forecast"},
        help="Type of run to download results files from.",
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Date of the run to download results files from.",
    )
    worker.run(download_fvcom_results, success, failure)
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.make_forcing_links --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        'host_name', help='Name of the host to symlink forcing files on')
    worker.cli.add_argument(
        'run_type',
        choices={'nowcast+', 'forecast2', 'ssh', 'nowcast-green'},
        help='''
        Type of run to symlink files for:
        'nowcast+' means nowcast & 1st forecast runs,
        'forecast2' means 2nd forecast run,
        'ssh' means Neah Bay sea surface height files only (for forecast run).
        'nowcast-green' means nowcast green ocean run,
        ''')
    worker.cli.add_argument('--shared-storage',
                            action='store_true',
                            help='''
        If running on a machine (Salish) that directly accesses
        the repo datafiles, copy the forcing files instead of symlinking them
        so that they do not get changed as a result of preparations for faster
        runs on remote hosts
        ''')
    worker.cli.add_date_option('--run-date',
                               default=(arrow.now().floor('day')),
                               help='Date of the run to symlink files for.')
    worker.run(make_forcing_links, success, failure)
Ejemplo n.º 5
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.run_NEMO_agrif --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument("host_name",
                            help="Name of the host to queue the run on")
    worker.cli.add_argument(
        "run_type",
        choices={"nowcast-agrif"},
        help="""
        Type of run to execute:
        'nowcast-agrif' means nowcast green ocean run with AGRIF sub-grids
        """,
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Date to execute the run for.",
    )
    worker.run(run_NEMO_agrif, success, failure)
Ejemplo n.º 6
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.watch_fvcom --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument("host_name", help="Name of the host to monitor the run on")
    worker.cli.add_argument(
        "model_config",
        choices={"r12", "x2"},
        help="""
        Model configuration to monitor run for for:
        'r12' means the r12 resolution
        'x2' means the x2 resolution
        """,
    )
    worker.cli.add_argument(
        "run_type",
        choices={"nowcast", "forecast"},
        help="""
        Type of run to monitor:
        'nowcast' means nowcast run (after NEMO nowcast run)
        'forecast' means updated forecast run (next 36h UTC, after NEMO forecast run)
        """,
    )
    worker.run(watch_fvcom, success, failure)
Ejemplo n.º 7
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.update_forecast_datasets -h`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        "model",
        choices={"fvcom", "nemo", "wwatch3"},
        help="""
        Model to update the rolling forecast datasets for:
        'fvcom' means the Vancouver Harbour Fraser River (VHFR) FVCOM model,
        'nemo' means the Salish Sea NEMO model,
        'wwatch3' means the Strait of Georgia WaveWatch3(TM) model.
        """,
    )
    worker.cli.add_argument(
        "run_type",
        choices={"forecast", "forecast2"},
        help="""
        Type of run to update rolling forecast datasets for:
        'forecast' means afternoon updated forecast runs,
        'forecast2' means early morning preliminary forecast runs,
        """,
    )
    worker.cli.add_date_option(
        "--run-date",
        default=(arrow.now().floor("day")),
        help="Date of the run to update rolling forecast datasets for.",
    )
    worker.run(update_forecast_datasets, success, failure)
Ejemplo n.º 8
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.run_NEMO --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument('host_name',
                            help='Name of the host to execute the run on')
    worker.cli.add_argument(
        'run_type',
        choices={
            'nowcast', 'nowcast-green', 'nowcast-dev', 'forecast', 'forecast2'
        },
        help='''
        Type of run to execute:
        'nowcast' means nowcast physics run,
        'nowcast-green' means nowcast green ocean run,
        'nowcast-dev' means nowcast physics run with in-development features,
        'forecast' means updated forecast run,
        'forecast2' means preliminary forecast run,
        ''',
    )
    worker.cli.add_date_option('--run-date',
                               default=arrow.now().floor('day'),
                               help='Date to execute the run for.')
    worker.run(run_NEMO, success, failure)
Ejemplo n.º 9
0
def main():
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        "host_name", help="Name of the host to download results files from")
    worker.cli.add_argument(
        "run_type",
        choices={
            "nowcast",
            "nowcast-green",
            "forecast",
            "forecast2",
            "hindcast",
            "nowcast-agrif",
        },
        help="Type of run to download results files from.",
    )
    worker.cli.add_argument(
        "--dest-host",
        default="localhost",
        help=
        "Name of the host to download results files to. Default is :kbd:`localhost`.",
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Date of the run to download results files from.",
    )
    worker.run(download_results, success, failure)
    return worker
Ejemplo n.º 10
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.make_fvcom_atmos_forcing --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        "model_config",
        choices={"r12", "x2"},
        help="""
        Model configuration to make atmospheric forcing file for:
        'r12' means the r12 resolution
        'x2' means the x2 resolution
        """,
    )
    worker.cli.add_argument(
        "run_type",
        choices={"nowcast", "forecast"},
        help="""
        Type of run to make atmospheric forcing file for:
        'nowcast' means run for present UTC day (after NEMO nowcast run),
        'forecast' means updated forecast run (next 36h UTC, after NEMO forecast run)
        """,
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Date to make atmospheric forcing file for.",
    )
    worker.run(make_fvcom_atmos_forcing, success, failure)
Ejemplo n.º 11
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.run_NEMO --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument("host_name",
                            help="Name of the host to execute the run on")
    worker.cli.add_argument(
        "run_type",
        choices={
            "nowcast", "nowcast-green", "nowcast-dev", "forecast", "forecast2"
        },
        help="""
        Type of run to execute:
        'nowcast' means nowcast physics run,
        'nowcast-green' means nowcast green ocean run,
        'nowcast-dev' means nowcast physics run with in-development features,
        'forecast' means updated forecast run,
        'forecast2' means preliminary forecast run,
        """,
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Date to execute the run for.",
    )
    worker.run(run_NEMO, success, failure)
Ejemplo n.º 12
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.watch_NEMO --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument("host_name",
                            help="Name of the host to monitor the run on")
    worker.cli.add_argument(
        "run_type",
        choices={
            "nowcast", "nowcast-green", "nowcast-dev", "forecast", "forecast2"
        },
        help="""
        Type of run to monitor:
        'nowcast' means nowcast physics run,
        'nowcast-green' means nowcast green ocean run,
        'forecast' means updated forecast run,
        'forecast2' means preliminary forecast run,
        """,
    )
    worker.run(watch_NEMO, success, failure)
Ejemplo n.º 13
0
 def test_debug_arg(self):
     worker = NowcastWorker("worker_name", "description")
     worker.init_cli()
     assert isinstance(
         worker.cli.parser._get_option_tuples("--debug")[0][0],
         argparse._StoreTrueAction,
     )
Ejemplo n.º 14
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.make_ww3_wind_file --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        "host_name", help="Name of the host to create the wind file on"
    )
    worker.cli.add_argument(
        "run_type",
        choices={"forecast2", "forecast", "nowcast"},
        help="""
        Type of run to create wind file for:
        'forecast2' means preliminary forecast run (after NEMO forecast2 run),
        'forecast' means updated forecast run (after NEMO forecast run),
        'nowcast' means updated 1 day only (for hindcast runs)
        """,
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Start date of run to create the wind file for.",
    )
    worker.run(make_ww3_wind_file, success, failure)
Ejemplo n.º 15
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.upload_forcing --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        "host_name", help="Name of the host to upload forcing files to"
    )
    worker.cli.add_argument(
        "run_type",
        choices={"nowcast+", "forecast2", "ssh", "turbidity"},
        help="""
        Type of run to upload files for:
        'nowcast+' means nowcast & 1st forecast runs,
        'forecast2' means 2nd forecast run,
        'ssh' means Neah Bay sea surface height files only (for forecast run),
        'turbidity' means Fraser River turbidity file only
        (for nowcast-green run).
        """,
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Date of the run to upload files for.",
    )
    worker.run(upload_forcing, success, failure)
    return worker
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.make_ww3_current_file --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        'host_name',
        help='Name of the host to create the currents file on')
    worker.cli.add_argument(
        'run_type',
        choices={'forecast2', 'forecast'},
        help='''
        Type of run to create the currents file for:
        'forecast2' means preliminary forecast run (after NEMO forecast2 run),
        'forecast' means updated forecast run (after NEMO forecast run)
        ''',
    )
    worker.cli.add_date_option(
        '--run-date', default=arrow.now().floor('day'),
        help='Start date of run to create the currents file for.')
    worker.run(make_ww3_current_file, success, failure)
Ejemplo n.º 17
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.watch_NEMO --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        'host_name',
        help='Name of the host to monitor the run on')
    worker.cli.add_argument(
        'run_type',
        choices={
            'nowcast', 'nowcast-green', 'nowcast-dev', 'forecast', 'forecast2'},
        help='''
        Type of run to monitor:
        'nowcast' means nowcast physics run,
        'nowcast-green' means nowcast green ocean run,
        'forecast' means updated forecast run,
        'forecast2' means preliminary forecast run,
        ''',
    )
    worker.cli.add_argument(
        'pid', type=int,
        help='PID of the NEMO run bash script to monitor.'
    )
    worker.run(watch_NEMO, success, failure)
Ejemplo n.º 18
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.run_ww3 --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument("host_name",
                            help="Name of the host to execute the run on")
    worker.cli.add_argument(
        "run_type",
        choices={"forecast2", "nowcast", "forecast"},
        help="""
        Type of run to execute:
        'forecast2' means preliminary forecast run (after NEMO forecast2 run),
        'nowcast' means nowcast run (after NEMO forecast run)
        'forecast' means updated forecast run (after WaveWatch3 forecast run)
        """,
    )
    worker.cli.add_date_option(
        "--run-date",
        default=arrow.now().floor("day"),
        help="Date to execute the run for.",
    )
    worker.run(run_ww3, success, failure)
    return worker
Ejemplo n.º 19
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.run_NEMO_hindcast --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument("host_name",
                            help="Name of the host to queue the run on")
    worker.cli.add_argument(
        "--full-month",
        action="store_true",
        help="""
        Configure the hindcast run to be a calendar month in duration.
        The default run duration is 10 days, or the number of days remaining
        in the calendar month of the run.
        """,
    )
    worker.cli.add_argument("--prev-run-date",
                            default=None,
                            help="Start date of the previous hindcast run.")
    worker.cli.add_argument(
        "--walltime",
        default=None,
        help="""
        Walltime to request for the hindcast run.
        Defaults to 10 hours (10:00:00) for 10-ish day runs,
        and 30 hours (30:00:00) for --full-month runs.
        **IMPORTANT: Use seconds for walltime values greater than 23:59:59**
        """,
    )
    worker.run(run_NEMO_hindcast, success, failure)
Ejemplo n.º 20
0
 def test_system_exit_context_destroy(self):
     worker = NowcastWorker("worker_name", "description")
     worker.init_cli()
     worker.logger = Mock(name="logger")
     worker._context = Mock(name="context")
     worker.worker_func = Mock(name="worker_func", side_effect=SystemExit)
     worker._do_work()
     assert worker._context.destroy.call_count == 1
Ejemplo n.º 21
0
 def test_failure_tell_manager(self):
     worker = NowcastWorker("worker_name", "description")
     worker.init_cli()
     worker.logger = Mock(name="logger")
     worker.tell_manager = Mock(name="tell_manager")
     worker.worker_func = Mock(name="worker_func", side_effect=WorkerError)
     worker.failure = Mock(name="failure_func", return_value="failure")
     worker._do_work()
     worker.tell_manager.assert_called_once_with("failure")
Ejemplo n.º 22
0
 def test_success_tell_manager(self):
     worker = NowcastWorker("worker_name", "description")
     worker.init_cli()
     worker.logger = Mock(name="logger")
     worker.tell_manager = Mock(name="tell_manager")
     worker.worker_func = Mock(name="worker_func", return_value="checklist")
     worker.success = Mock(name="success_func", return_value="success")
     worker._do_work()
     worker.tell_manager.assert_called_once_with("success", "checklist")
Ejemplo n.º 23
0
 def test_success_func(self):
     worker = NowcastWorker("worker_name", "description")
     worker.init_cli()
     worker.logger = Mock(name="logger")
     worker.tell_manager = Mock(name="tell_manager")
     worker.worker_func = Mock(name="worker_func")
     worker.success = Mock(name="success_func")
     worker._do_work()
     worker.success.assert_called_once_with(worker._parsed_args)
Ejemplo n.º 24
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nemo_nowcast.workers.awaken --help`
    """
    worker = NowcastWorker(NAME, description=__doc__, package="nemo_nowcast.workers")
    worker.init_cli()
    worker.run(awaken, success, failure)
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.make_runoff_file --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_date_option(
        '--run-date', default=arrow.now().floor('day'),
        help='Date of the run to produce runoff file for.')
    worker.run(make_runoff_file, success, failure)
Ejemplo n.º 26
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.watch_NEMO_agrif --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument("host_name",
                            help="Name of the host to monitor the run on")
    worker.cli.add_argument("job_id",
                            help="Job identifier of the job to monitor")
    worker.run(watch_NEMO_agrif, success, failure)
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.download_live_ocean -h`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_date_option(
        '--run-date',
        default=arrow.now().floor('day'),
        help='Date to download the Live Ocean forecast product for.')
    worker.run(download_live_ocean, success, failure)
Ejemplo n.º 28
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.watch_NEMO_hindcast --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument("host_name",
                            help="Name of the host to monitor the run on")
    worker.cli.add_argument("--run-id",
                            help="Run id to watch; e.g. 01dec14hindcast")
    worker.run(watch_NEMO_hindcast, success, failure)
Ejemplo n.º 29
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.make_plots --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_argument(
        'run_type',
        choices={'nowcast', 'nowcast-green', 'forecast', 'forecast2'},
        help='''
        Type of run to produce plots for:
        'nowcast' means nowcast physics-only runs,
        'nowcast-green' means nowcast-green physics/biology runs
        'forecast' means forecast physics-only runs,
        'forecast2' means forecast2 preliminary forecast physics-only runs.
        ''',
    )
    worker.cli.add_argument('plot_type',
                            choices={'publish', 'research', 'comparison'},
                            help='''
        Which type of plots to produce:
        "publish" means ssh, weather and other approved plots for publishing,
        "research" means tracers, currents and other research plots
        "comparison" means ferry salinity plots
        ''')
    worker.cli.add_date_option('--run-date',
                               default=arrow.now().floor('day'),
                               help='Date of the run to symlink files for.')
    worker.cli.add_argument(
        '--test-figure',
        help='''Identifier for a single figure to do a test on.
        The identifier may be the svg_name of the figure used in make_plots
        (e.g. SH_wind is the svg_name of figures stored as SH_wind_{ddmmmyy}.svg),
        the name of the website figure module
        (e.g. storm_surge_alerts is the module name of 
        nowcast.figures.publish.storm_surge_alerts),
        or name of the figure function for legacy nowcast.figures.figures
        functions
        (e.g. Sandheads_winds is the function name of
        nowcast.figures.figures.Sandheads_winds).
        The figure will be rendered in
        /results/nowcast-sys/figures/test/{run_type}/{ddmmmyy}/ so that it is
        accessible in a browser at 
        https://salishsea.eos.ubc.ca/{run_type}/{ddmmmyy}/{svg_name}_{ddmmyy}.svg
        ''')
    worker.run(make_plots, success, failure)
Ejemplo n.º 30
0
def main():
    """Set up and run the worker.

    For command-line usage see:

    :command:`python -m nowcast.workers.get_vfpa_hadcp --help`
    """
    worker = NowcastWorker(NAME, description=__doc__)
    worker.init_cli()
    worker.cli.add_date_option(
        "--data-date",
        default=arrow.now().floor("day"),
        help="UTC date to get VFPA HADPC data for.",
    )
    worker.run(get_vfpa_hadcp, success, failure)