Skip to content

Commit

Permalink
test: make downloaded/rebuilt programs optional (#1621)
Browse files Browse the repository at this point in the history
* skip, don't crash/fail if downloaded programs or rebuilt regression mf6 programs not found
* only require dev build to gracefully run autotests
  • Loading branch information
wpbonelli authored Feb 15, 2024
1 parent e31e79b commit b77cd26
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
12 changes: 9 additions & 3 deletions autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ def targets() -> Dict[str, Path]:
# require development binaries
assert v.is_file(), f"Couldn't find binary '{k}' expected at: {v}"
d[k] = v
for k, v in _binaries["downloaded"] + _binaries["rebuilt"]:
# downloaded/rebuilt binaries are optional
for k, v in _binaries["downloaded"]:
# downloaded binaries are optional
if v.is_file():
d[k] = v
else:
warn(f"Couldn't find binary '{k}' expected at: {v}")
warn(f"Couldn't find downloaded binary '{k}' expected at: {v}")
for k, v in _binaries["rebuilt"]:
# rebuilt binaries are optional
if v.is_file():
d[k] = v
else:
warn(f"Couldn't find rebuilt binary '{k}' expected at: {v}")
return d


Expand Down
22 changes: 13 additions & 9 deletions autotest/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import flopy
import numpy as np
import pytest
from common_regression import (
COMPARE_PROGRAMS,
adjust_htol,
Expand Down Expand Up @@ -777,17 +778,20 @@ def run(self):

# run comparison simulation if libmf6 or mf6 regression
if self.compare in ["mf6_regression", "libmf6"]:
# todo: don't hardcode workspace or assume agreement with test case
# simulation workspace, set & access simulation workspaces directly
workspace = self.workspace / self.compare
success, _ = self.run_sim_or_model(
workspace,
self.targets.get(self.compare, self.targets["mf6"]),
)
assert success, f"Comparison model failed: {workspace}"
if self.compare not in self.targets:
warn(f"Couldn't find comparison program '{self.compare}', skipping comparison")
else:
# todo: don't hardcode workspace or assume agreement with test case
# simulation workspace, set & access simulation workspaces directly
workspace = self.workspace / self.compare
success, _ = self.run_sim_or_model(
workspace,
self.targets.get(self.compare, self.targets["mf6"]),
)
assert success, f"Comparison model failed: {workspace}"

# compare model results, if enabled
if self.verbose:
if self.verbose and self.compare in self.targets:
print("Comparing outputs")
self.compare_output(self.compare)

Expand Down
6 changes: 5 additions & 1 deletion autotest/test_gwf_csub_zdisp01.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from flopy.utils.compare import compare_heads

from framework import TestFramework
from conftest import try_get_target

cases = ["csub_zdisp01"]
cmppth = "mfnwt"
Expand Down Expand Up @@ -330,7 +331,10 @@ def build_models(idx, test):
cpth = cmppth
ws = os.path.join(test.workspace, cpth)
mc = flopy.modflow.Modflow(
name, model_ws=ws, version=cpth, exe_name=test.targets["mfnwt"]
name,
model_ws=ws,
version=cpth,
exe_name=try_get_target(test.targets, "mfnwt"),
)
dis = flopy.modflow.ModflowDis(
mc,
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_npf01_75x75.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from framework import TestFramework
from conftest import try_get_target

cases = ["npf01a_75x75", "npf01b_75x75"]
top = [100.0, 0.0]
Expand Down Expand Up @@ -149,7 +150,9 @@ def build_models(idx, test):

# build MODFLOW-2005 files
ws = os.path.join(test.workspace, "mf2005")
mc = flopy.modflow.Modflow(name, model_ws=ws, exe_name=test.targets["mf2005"])
mc = flopy.modflow.Modflow(
name, model_ws=ws, exe_name=try_get_target(test.targets, "mf2005")
)
dis = flopy.modflow.ModflowDis(
mc,
nlay=nlay,
Expand Down
6 changes: 5 additions & 1 deletion autotest/test_gwf_sto01.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from framework import TestFramework
from conftest import try_get_target

cases = ["gwf_sto01"]
cmppth = "mfnwt"
Expand Down Expand Up @@ -203,7 +204,10 @@ def build_models(idx, test):
cpth = cmppth
ws = os.path.join(test.workspace, cpth)
mc = flopy.modflow.Modflow(
name, model_ws=ws, version=cpth, exe_name=test.targets["mfnwt"]
name,
model_ws=ws,
version=cpth,
exe_name=try_get_target(test.targets, "mfnwt"),
)
dis = flopy.modflow.ModflowDis(
mc,
Expand Down

0 comments on commit b77cd26

Please sign in to comment.