Skip to content

Commit

Permalink
Remove "host_name" arg from make_averaged_dataset worker
Browse files Browse the repository at this point in the history
The "host_name" argument in the "make_averaged_dataset" worker was removed as
it's unnecessary. Tests and calls to NextWorker were updated accordingly to
reflect this change.
  • Loading branch information
douglatornell committed Mar 4, 2024
1 parent 757e61c commit 138ed66
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
10 changes: 2 additions & 8 deletions nowcast/next_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ def after_download_results(msg, config, checklist):
next_workers[msg.type].append(
NextWorker(
"nowcast.workers.make_averaged_dataset",
args=["skookum", "day", var_group, "--run-date", run_date],
args=["day", var_group, "--run-date", run_date],
)
)
if arrow.get(run_date).shift(days=+1).day == 1:
Expand Down Expand Up @@ -1571,13 +1571,7 @@ def after_make_averaged_dataset(msg, config, checklist):
next_workers[msg.type].append(
NextWorker(
"nowcast.workers.make_averaged_dataset",
args=[
"skookum",
"month",
reshapr_var_group,
"--run-date",
first_of_month,
],
args=["month", reshapr_var_group, "--run-date", first_of_month],
host="localhost",
)
)
Expand Down
3 changes: 0 additions & 3 deletions nowcast/workers/make_averaged_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ def main():
_configure_structlog()
worker = NowcastWorker(NAME, description=__doc__)
worker.init_cli()
worker.cli.add_argument(
"host_name", help="Name of the host to run the downsampling extraction on"
)
worker.cli.add_argument(
"avg_time_interval",
choices={"day", "month"},
Expand Down
4 changes: 2 additions & 2 deletions tests/test_next_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ def test_success_nowcast_green_launch_make_averaged_dataset_day(
)
expected = NextWorker(
"nowcast.workers.make_averaged_dataset",
args=["skookum", "day", var_group, "--run-date", "2024-02-07"],
args=["day", var_group, "--run-date", "2024-02-07"],
host="localhost",
)
assert expected in workers
Expand Down Expand Up @@ -2246,7 +2246,7 @@ def test_month_end_day_success_launch_month_average(
workers = next_workers.after_make_averaged_dataset(msg, config, checklist)
expected = NextWorker(
"nowcast.workers.make_averaged_dataset",
args=["skookum", "month", reshapr_var_group, "--run-date", "2024-02-01"],
args=["month", reshapr_var_group, "--run-date", "2024-02-01"],
host="localhost",
)
assert expected in workers
Expand Down
26 changes: 10 additions & 16 deletions tests/workers/test_make_averaged_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,37 +86,31 @@ def test_instantiate_worker(self, mock_worker):
"SalishSeaCast worker that creates a down-sampled time-series dataset netCDF4 file"
)

def test_add_host_name_arg(self, mock_worker):
worker = make_averaged_dataset.main()

assert worker.cli.parser._actions[3].dest == "host_name"
assert worker.cli.parser._actions[3].help

def test_add_avg_time_interval_arg(self, mock_worker):
worker = make_averaged_dataset.main()

assert worker.cli.parser._actions[4].dest == "avg_time_interval"
assert worker.cli.parser._actions[4].choices == {"day", "month"}
assert worker.cli.parser._actions[4].help
assert worker.cli.parser._actions[3].dest == "avg_time_interval"
assert worker.cli.parser._actions[3].choices == {"day", "month"}
assert worker.cli.parser._actions[3].help

def test_add_reshapr_var_group_arg(self, mock_worker):
worker = make_averaged_dataset.main()

assert worker.cli.parser._actions[5].dest == "reshapr_var_group"
assert worker.cli.parser._actions[5].choices == {
assert worker.cli.parser._actions[4].dest == "reshapr_var_group"
assert worker.cli.parser._actions[4].choices == {
"biology",
"chemistry",
"physics",
}
assert worker.cli.parser._actions[5].help
assert worker.cli.parser._actions[4].help

def test_add_run_date_option(self, mock_worker):
worker = make_averaged_dataset.main()
assert worker.cli.parser._actions[6].dest == "run_date"
assert worker.cli.parser._actions[5].dest == "run_date"
expected = nemo_nowcast.cli.CommandLineInterface.arrow_date
assert worker.cli.parser._actions[6].type == expected
assert worker.cli.parser._actions[6].default == arrow.now().floor("day")
assert worker.cli.parser._actions[6].help
assert worker.cli.parser._actions[5].type == expected
assert worker.cli.parser._actions[5].default == arrow.now().floor("day")
assert worker.cli.parser._actions[5].help


class TestConfig:
Expand Down

0 comments on commit 138ed66

Please sign in to comment.