Skip to content

Commit

Permalink
review & PEP
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-seaice committed Sep 18, 2024
1 parent 25c8c31 commit 9ec70a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions payu/models/cesm_cmeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ def _setup_checks(self):
if (iostride<=0) :
warn(f"The pio_stride for {io_section} in {NUOPC_CONFIG} is "
"not set, using model default")
if (all(
if (all([
niotasks>0,
iostride>0,
ioroot + (niotasks-1)*iostride) >= npes
):
(ioroot + (niotasks-1)*iostride) >= npes
])):
raise ValueError(
f"The iolayout for {io_section} in {NUOPC_CONFIG} is "
"requesting out of range cpus"
Expand Down
24 changes: 13 additions & 11 deletions test/models/access-om3/test_access_om3.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def get(self, section, variable, value=None):
(100000, 50000, 1, 2, 0), # max cpu
(100000, 1, 1, 1, 99999), # max cpu
])
@pytest.mark.filterwarnings("error")
def test__setup_checks_npes(ncpu, moc_ntasks, moc_nthreads, moc_pestride, moc_rootpe):

cmeps_config(ncpu)
Expand Down Expand Up @@ -184,6 +185,7 @@ def test__setup_checks_too_many_pes(ncpu, moc_ntasks, moc_nthreads, moc_pestride
(5, 3, 2, 0, "netcdf4p"),
(100000, 50001, 1, 2, "netcdf4p"), # odd ncpu
])
@pytest.mark.filterwarnings("error")
def test__setup_checks_io(ncpu, pio_numiotasks, pio_stride, pio_root, pio_typename):

cmeps_config(ncpu)
Expand Down Expand Up @@ -281,20 +283,17 @@ def test__setup_checks_pio_async(pio_typename, pio_async_interface):

teardown_cmeps_config()

@pytest.mark.parametrize("pio_typename, pio_async_interface", [
("netcdf4p", ".false."),
("pnetcdf", ".false."),
("netcdf", ".false."),
@pytest.mark.parametrize("pio_numiotasks, pio_stride", [
(1, -99),
(-99, 1),
])
@pytest.mark.filterwarnings("error")
def test__setup_checks_not_pio_async(pio_typename, pio_async_interface):

def test__setup_checks_bad_io(pio_numiotasks, pio_stride):
cmeps_config(1)

test_runconf = copy.deepcopy(MOCK_IO_RUNCONF)
test_runconf["MOC_modelio"].update(dict(
pio_async_interface=pio_async_interface,
pio_typename=pio_typename,
pio_numiotasks=pio_numiotasks,
pio_stride=pio_stride,
))

with cd(ctrldir):
Expand All @@ -306,6 +305,9 @@ def test__setup_checks_not_pio_async(pio_typename, pio_async_interface):

model.runconfig = MockRunConfig(test_runconf)

model._setup_checks()
with pytest.warns(
Warning, match="using model default"
):
model._setup_checks()

teardown_cmeps_config()
teardown_cmeps_config()

0 comments on commit 9ec70a6

Please sign in to comment.