Skip to content

Commit

Permalink
Merge pull request MODFLOW-USGS#82 from MODFLOW-USGS/v0.1.8
Browse files Browse the repository at this point in the history
Release 0.1.8
  • Loading branch information
wpbonelli committed Apr 21, 2023
2 parents bdcfdae + 9d12e7a commit 590f27e
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 24 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
with:
repository: MODFLOW-USGS/modflow6-largetestmodels
path: modflow6-largetestmodels
token: ${{ github.token }}

- name: Install executables
uses: modflowpy/install-modflow-action@v1
Expand Down Expand Up @@ -160,10 +161,22 @@ jobs:
working-directory: modflow6-examples/etc
run: python ci_build_files.py

- name: Run tests
- name: Run local tests
working-directory: modflow-devtools
env:
BIN_PATH: ~/.local/bin/modflow
REPOS_PATH: ${{ github.workspace }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pytest -v -n auto --durations 0
GITHUB_TOKEN: ${{ github.token }}
run: pytest -v -n auto --durations 0 --ignore modflow_devtools/test/test_download.py

- name: Run network-dependent tests
# only invoke the GH API on one OS and Python version
# to avoid rate limits (1000 rqs / hour / repository)
# https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#usage-limits
if: runner.os == 'Linux' && matrix.python == '3.8'
working-directory: modflow-devtools
env:
BIN_PATH: ~/.local/bin/modflow
REPOS_PATH: ${{ github.workspace }}
GITHUB_TOKEN: ${{ github.token }}
run: pytest -v -n auto --durations 0 modflow_devtools/test/test_download.py
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### Version 0.1.8

#### New features

* [feat(fixtures)](https://github.com/MODFLOW-USGS/modflow-devtools/commit/3bf76d587a04954cc68a07d38e48876d42f06b58): Discover external model repo dirs with .git suffix (#80). Committed by w-bonelli on 2023-04-21.

#### Bug fixes

* [fix(multiple)](https://github.com/MODFLOW-USGS/modflow-devtools/commit/2307add30eb3134a786f7c722656b4d99a0fe91a): Fix some CI and fixture issues (#81). Committed by w-bonelli on 2023-04-21.

### Version 0.1.7

#### Refactoring
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

project = "modflow-devtools"
author = "MODFLOW Team"
release = "0.1.7"
release = "0.1.8"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/md/fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ See the [installation docs](install.md) for more information on installing test

### Configuration

It is recommended to set the environment variable `REPOS_PATH` to the location of the model repositories on the filesystem. Model repositories must live side-by-side in this location, and repository directories are expected to be named identically to GitHub repositories. If `REPOS_PATH` is not configured, `modflow-devtools` assumes tests are being run from an `autotest` subdirectory of the consuming project's root, and model repos live side-by-side with the consuming project. If this guess is incorrect and repositories cannot be found, tests requesting these fixtures will be skipped.
It is recommended to set the environment variable `REPOS_PATH` to the location of the model repositories on the filesystem. Model repositories must live side-by-side in this location, and repository directories are expected to be named identically to GitHub repositories (the directory may have a `.git` suffix). If `REPOS_PATH` is not configured, `modflow-devtools` assumes tests are being run from an `autotest` subdirectory of the consuming project's root, and model repos live side-by-side with the consuming project. If this guess is incorrect and repositories cannot be found, tests requesting these fixtures will be skipped.

**Note:** by default, all models found in the respective external repository will be returned by these fixtures. It is up to the consuming project to exclude models if needed. This can be accomplished by:

Expand Down
4 changes: 2 additions & 2 deletions modflow_devtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = "Joseph D. Hughes"
__date__ = "Apr 18, 2023"
__version__ = "0.1.7"
__date__ = "Apr 21, 2023"
__version__ = "0.1.8"
__maintainer__ = "Joseph D. Hughes"
__email__ = "[email protected]"
__status__ = "Production"
Expand Down
49 changes: 36 additions & 13 deletions modflow_devtools/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,33 @@ def pytest_generate_tests(metafunc):
repos_path = Path(repos_path)
else:
# by default, assume external repositories are
# in the same directory as the current project
# and tests are run from <proj root>/autotest.
# if no models are found, tests requesting the
# fixtures will be skipped.
# level (side-by-side) on the filesystem with
# the consuming project. also assume tests are
# run from <proj root>/autotest.
#
# external model repo directories are expected
# to be named identically to the GitHub repos,
# e.g. "modflow6-testmodels", with an optional
# ".git" suffix appended to the directory name.
#
# if model repositories are not found in either
# the default location or in REPOS_PATH, tests
# requesting these fixtures will be skipped.
repos_path = Path.cwd().parent.parent

def get_repo_path(repo_name: str) -> Optional[Path]:
"""Get the path for the repository with the given name
(optionally with .git suffix), or None if not found"""
repo_path = repos_path / repo_name
if not repo_path.is_dir():
repo_path = repos_path / (repo_name + ".git")
if not repo_path.is_dir():
repo_path = None
return repo_path

key = "test_model_mf6"
if key in metafunc.fixturenames:
repo_path = repos_path / "modflow6-testmodels"
repo_path = get_repo_path("modflow6-testmodels")
namefile_paths = (
get_namefile_paths(
repo_path / "mf6",
Expand All @@ -207,7 +225,7 @@ def pytest_generate_tests(metafunc):
selected=models_selected,
packages=packages_selected,
)
if repo_path.is_dir()
if repo_path
else []
)
metafunc.parametrize(
Expand All @@ -216,7 +234,7 @@ def pytest_generate_tests(metafunc):

key = "test_model_mf5to6"
if key in metafunc.fixturenames:
repo_path = repos_path / "modflow6-testmodels"
repo_path = get_repo_path("modflow6-testmodels")
namefile_paths = (
get_namefile_paths(
repo_path / "mf5to6",
Expand All @@ -226,7 +244,7 @@ def pytest_generate_tests(metafunc):
selected=models_selected,
packages=packages_selected,
)
if repo_path.is_dir()
if repo_path
else []
)
metafunc.parametrize(
Expand All @@ -235,7 +253,7 @@ def pytest_generate_tests(metafunc):

key = "large_test_model"
if key in metafunc.fixturenames:
repo_path = repos_path / "modflow6-largetestmodels"
repo_path = get_repo_path("modflow6-largetestmodels")
namefile_paths = (
get_namefile_paths(
repo_path,
Expand All @@ -245,7 +263,7 @@ def pytest_generate_tests(metafunc):
selected=models_selected,
packages=packages_selected,
)
if repo_path.is_dir()
if repo_path
else []
)
metafunc.parametrize(
Expand All @@ -254,7 +272,7 @@ def pytest_generate_tests(metafunc):

key = "example_scenario"
if key in metafunc.fixturenames:
repo_path = repos_path / "modflow6-examples"
repo_path = get_repo_path("modflow6-examples")

def is_nested(namfile_path: PathLike) -> bool:
p = Path(namfile_path)
Expand Down Expand Up @@ -291,7 +309,12 @@ def group_examples(namefile_paths) -> Dict[str, List[Path]]:

def get_examples():
# find MODFLOW 6 namfiles
namfiles = [p for p in (repo_path / "examples").rglob("mfsim.nam")]
examples_path = repo_path / "examples"
namfiles = (
[p for p in examples_path.rglob("mfsim.nam")]
if examples_path.is_dir()
else []
)

# group by scenario
examples = group_examples(namfiles)
Expand Down Expand Up @@ -334,7 +357,7 @@ def get_examples():

return examples

example_scenarios = get_examples() if repo_path.is_dir() else dict()
example_scenarios = get_examples() if repo_path else dict()
metafunc.parametrize(
key,
[(name, nfps) for name, nfps in example_scenarios.items()],
Expand Down
2 changes: 1 addition & 1 deletion modflow_devtools/test/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_list_artifacts(tmp_path, name, per_page):
"MODFLOW-USGS/modflow6",
name=name,
per_page=per_page,
max_pages=3,
max_pages=2,
verbose=True,
)

Expand Down
4 changes: 2 additions & 2 deletions modflow_devtools/test/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_get_model_paths_largetestmodels():
reason="repos not found",
)
@pytest.mark.parametrize(
"models", [(_examples_path, 63), (_largetestmodels_repo_path, 15)]
"models", [(_examples_path, 63), (_largetestmodels_repo_path, 16)]
)
def test_get_model_paths_exclude_patterns(models):
path, expected_count = models
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_get_namefile_paths_largetestmodels():
reason="repos not found",
)
@pytest.mark.parametrize(
"models", [(_examples_path, 43), (_largetestmodels_repo_path, 18)]
"models", [(_examples_path, 43), (_largetestmodels_repo_path, 19)]
)
def test_get_namefile_paths_exclude_patterns(models):
path, expected_count = models
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.7
0.1.8

0 comments on commit 590f27e

Please sign in to comment.