Skip to content

Commit

Permalink
Merge pull request #78 from MODFLOW-USGS/v0.1.7
Browse files Browse the repository at this point in the history
Release 0.1.7
  • Loading branch information
wpbonelli authored Apr 18, 2023
2 parents 5b45f11 + 4fec01f commit bdcfdae
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 28 deletions.
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### Version 0.1.7

#### Refactoring

* [refactor(fixtures)](https://github.com/MODFLOW-USGS/modflow-devtools/commit/2bbe35f3a4b63d9c6d558d7669c986a6fb7056de): Add entries to default exe name/path mapping (#75). Committed by w-bonelli on 2023-03-01.
* [refactor(versioning)](https://github.com/MODFLOW-USGS/modflow-devtools/commit/5fbc6b98e34afe9e43cc1d8c1b26f87e64f00699): Don't track version explicitly in readme (#76). Committed by w-bonelli on 2023-04-06.

### Version 0.1.6

#### Refactoring
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# MODFLOW developer tools

### Version 0.1.6 — release candidate
[![GitHub tag](https://img.shields.io/github/tag/MODFLOW-USGS/modflow-devtools.svg)](https://github.com/MODFLOW-USGS/modflow-devtools/tags/latest)
[![PyPI Version](https://img.shields.io/pypi/v/modflow-devtools.png)](https://pypi.python.org/pypi/modflow-devtools)
[![PyPI Versions](https://img.shields.io/pypi/pyversions/modflow-devtools.png)](https://pypi.python.org/pypi/modflow-devtools)
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.6"
release = "0.1.7"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
37 changes: 23 additions & 14 deletions docs/md/download.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
# Downloads
# Web utilities

Some utility functions are provided to query information and download artifacts and assets from the GitHub API. These are available in the `modflow_devtools.download` module and are briefly described below. See this project's test cases (in particular `test_download.py`) for more usage examples.
Some utility functions are provided for common web requests. Most use the GitHub API to query information or download artifacts and assets. See this project's test cases (in particular `test_download.py`) for detailed usage examples.

**Note:** to avoid GitHub API rate limits when using these functions, it is recommended to set the `GITHUB_TOKEN` environment variable. If this variable is set, the token will be borne on requests sent to the API.

## Retrieving information
## Queries

The following functions ask the GitHub API for information about a repository. The singular functions generally return a dictionary, while the plural functions return a list of dictionaries, with dictionary contents parsed directly from the API response's JSON.

- `get_releases(repo, per_page=30, max_pages=10, retries=3, verbose=False)`
- `get_release(repo, tag="latest", retries=3, verbose=False)`
- `get_release_assets(repo, tag="latest", simple=False, retries=3, verbose=False)`
- `list_artifacts(repo, name, per_page=None, max_pages=None, verbose=False)`

The `repo` parameter's format is `owner/name`, as in GitHub URLs.
The following functions ask the GitHub API for information about a repository. The singular functions generally return a dictionary, while the plural functions return a list of dictionaries, with dictionary contents parsed directly from the API response's JSON. The first parameter of each function is `repo`, a string whose format must be `owner/name`, as appearing in GitHub URLs.

For instance, to retrieve information about the latest executables release, then manually inspect available assets:

Expand Down Expand Up @@ -54,11 +47,27 @@ This prints:
'win64.zip': 'https://github.com/MODFLOW-USGS/executables/releases/download/12.0/win64.zip'}
```

## Downloading assets
## Downloads

The `download_artifact` function downloads and unzips the GitHub Actions artifact with the given ID to the given path, optionally deleting the zipfile afterwards. The `repo` format is `owner/name`, as in GitHub URLs. For instance:

The `download_artifact(repo, id, path=None, delete_zip=True, verbose=False)` function downloads and unzips the GitHub Actions artifact with the given ID to the given path, optionally deleting the zipfile afterwards. The `repo` format is `owner/name`, as in GitHub URLs.
```python
from modflow_devtools.download import list_artifacts, download_artifact

repo = "MODFLOW-USGS/modflow6"
artifacts = list_artifacts(repo, max_pages=1, verbose=True)
artifact = next(iter(artifacts), None)
if artifact:
download_artifact(
repo=repo,
id=artifact["id"],
path=function_tmpdir,
delete_zip=False,
verbose=False,
)
```

The `download_and_unzip(url, path=None, delete_zip=True, verbose=False)` function is a more generic alternative for downloading and unzipping files from arbitrary URLs.
The `download_and_unzip` function is a more generic alternative for downloading and unzipping files from arbitrary URLs.

For instance, to download a MODFLOW 6.4.1 Linux distribution and delete the zipfile after extracting:

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__ = "Feb 13, 2023"
__version__ = "0.1.6"
__date__ = "Apr 18, 2023"
__version__ = "0.1.7"
__maintainer__ = "Joseph D. Hughes"
__email__ = "[email protected]"
__status__ = "Production"
Expand Down
13 changes: 13 additions & 0 deletions modflow_devtools/executables.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,28 @@ def build_default_exe_dict(bin_path: PathLike) -> Dict[str, Path]:
ext, so = get_suffixes(sys.platform)

# downloaded executables
d["mf2000"] = dl_bin / f"mf2000{ext}"
d["mf2005"] = dl_bin / f"mf2005dbl{ext}"
d["mfnwt"] = dl_bin / f"mfnwtdbl{ext}"
d["mfusg"] = dl_bin / f"mfusgdbl{ext}"
d["mflgr"] = dl_bin / f"mflgrdbl{ext}"
d["mf2005s"] = dl_bin / f"mf2005{ext}"
d["mt3dms"] = dl_bin / f"mt3dms{ext}"
d["crt"] = dl_bin / f"crt{ext}"
d["gridgen"] = dl_bin / f"gridgen{ext}"
d["mp6"] = dl_bin / f"mp6{ext}"
d["mp7"] = dl_bin / f"mp7{ext}"
d["swtv4"] = dl_bin / f"swtv4{ext}"
d["sutra"] = dl_bin / f"sutra{ext}"
d["triangle"] = dl_bin / f"triangle{ext}"
d["vs2dt"] = dl_bin / f"vs2dt{ext}"
d["zonbudusg"] = dl_bin / f"zonbudusg{ext}"

# executables rebuilt from last release
d["mf6_regression"] = rb_bin / f"mf6{ext}"
d["libmf6_regression"] = rb_bin / f"libmf6{so}"
d["mf5to6_regression"] = rb_bin / f"mf5to6{ext}"
d["zbud6_regression"] = rb_bin / f"zbud6{ext}"

# local development version
d["mf6"] = d_bin / f"mf6{ext}"
Expand Down
13 changes: 4 additions & 9 deletions scripts/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def from_file(cls, path: PathLike) -> "Version":

class ReleaseType(Enum):
CANDIDATE = "Release Candidate"
APPROVED = "Production"
RELEASE = "Release"


_initial_version = Version(0, 0, 1)
Expand Down Expand Up @@ -92,19 +92,14 @@ def update_init_py(
def update_readme_markdown(
release_type: ReleaseType, timestamp: datetime, version: Version
):
# read README.md into memory
lines = _readme_path.read_text().rstrip().split("\n")

# rewrite README.md
with open(_readme_path, "w") as f:
for line in lines:
if "### Version " in line:
line = f"### Version {version}"
if release_type != ReleaseType.APPROVED:
if release_type != ReleaseType.RELEASE:
line += f" — {release_type.value.lower()}"

f.write(f"{line}\n")

print(f"Updated {_readme_path} to version {version}")


Expand Down Expand Up @@ -138,7 +133,7 @@ def update_version(
with lock:
update_version_txt(release_type, timestamp, version)
update_init_py(release_type, timestamp, version)
update_readme_markdown(release_type, timestamp, version)
# update_readme_markdown(release_type, timestamp, version)
update_docs_config(release_type, timestamp, version)
finally:
try:
Expand Down Expand Up @@ -187,7 +182,7 @@ def update_version(
print(_current_version)
else:
update_version(
release_type=ReleaseType.APPROVED
release_type=ReleaseType.RELEASE
if args.approve
else ReleaseType.CANDIDATE,
timestamp=datetime.now(),
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.6
0.1.7

0 comments on commit bdcfdae

Please sign in to comment.