Skip to content

Commit

Permalink
move lint/format-related changes out, remove marker from generate_cla…
Browse files Browse the repository at this point in the history
…sses tests
  • Loading branch information
wpbonelli committed Nov 13, 2023
1 parent 5df7505 commit 4ccea05
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
19 changes: 14 additions & 5 deletions autotest/test_generate_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@ def nonempty(itr: Iterable):


def pytest_generate_tests(metafunc):
# defaults
"""
Test mf6 module code generation on a small, hopefully
fairly representative set of MODFLOW 6 input & output
specification versions, including the develop branch,
the latest official release, and a few older releases
and commits.
TODO: May make sense to run the full battery of tests
against all of the versions of mf6io flopy guarantees
support for- maybe develop and latest release? Though
some backwards compatibility seems ideal if possible.
This would need changes in GH Actions CI test matrix.
"""

owner = "MODFLOW-USGS"
repo = "modflow6"
ref = [
Expand Down Expand Up @@ -59,10 +72,6 @@ def pytest_generate_tests(metafunc):
@pytest.mark.generation
@pytest.mark.mf6
@pytest.mark.slow
@pytest.mark.skipif(
branch == "master" or branch.startswith("v"),
reason="skip on master and release branches",
)
def test_generate_classes_from_github_refs(
request, project_root_path, ref, worker_id, function_tmpdir
):
Expand Down
4 changes: 2 additions & 2 deletions docs/make_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ As described above, making a release manually involves the following steps:

- Update MODFLOW 6 dfn files in the repository and MODFLOW 6 package classes by running `python -m flopy.mf6.utils.generate_classes --ref master --no-backup`

- Format Python source files. This can be achieved by running `black` and `isort` on the `flopy` module.
- Run `isort` and `black` on the `flopy` module. This can be achieved by running `python scripts/pull_request_prepare.py` from the project root. The commands `isort .` and `black .` can also be run individually instead.

- Use `run_notebooks.py` in the `scripts` directory to rerun all notebooks in `.docs/Notebooks`.

Expand All @@ -121,7 +121,7 @@ As described above, making a release manually involves the following steps:

2. Set the development version as appropriate: `python scripts/update_version.py -v <version>`. The version number must comply with [PEP 440](https://peps.python.org/pep-0440/).

3. Format Python files by running `black` and `isort` on the `flopy` module.
3. Lint Python files: `python scripts/pull_request_prepare.py`

4. Commit and push the updated `develop` branch.

Expand Down
8 changes: 8 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ For instance, `e689af57e7439b9005749d806248897ad550eab5_20150811_041632_uncommit

**Note**: the `process_benchmarks.py` script depends on `seaborn`, which is not included as a dependency in either `etc/environment.yml` or in any of the optional groups in `pyproject.toml`, since this is the only place it is used in this repository.

## Preparing for PRs

The `pull_request_prepare.py` script lints Python source code files by running `black` and `isort` on the `flopy` subdirectory. This script should be run before opening a pull request, as CI will fail if the code is not properly formatted. For instance, from the project root:

```shell
python scripts/pull_request_prepare.py
```

## Running notebooks

The `run_notebooks.py` script runs notebooks located in the `.docs/Notebooks` directory.
Expand Down
21 changes: 21 additions & 0 deletions scripts/pull_request_prepare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os

try:
import isort

print(f"isort version: {isort.__version__}")
except ModuleNotFoundError:
print("isort not installed\n\tInstall using pip install isort")

try:
import black

print(f"black version: {black.__version__}")
except ModuleNotFoundError:
print("black not installed\n\tInstall using pip install black")

print("running isort...")
os.system("isort -v ../flopy")

print("running black...")
os.system("black -v ../flopy")

0 comments on commit 4ccea05

Please sign in to comment.