Skip to content

Commit

Permalink
fix(get-modflow): accommodate mf6 release asset name change (#1855)
Browse files Browse the repository at this point in the history
* accommodate mf6 windows release asset name change
* reformat jupytext scripts (broken by running black)
  • Loading branch information
wpbonelli authored Jun 29, 2023
1 parent 4f63366 commit b8dffbc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .docs/Notebooks/array_output_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
# + [markdown] pycharm={"name": "#%% md\n"}
# load and run the Freyberg model

import os

# + pycharm={"name": "#%%\n"}
import os
import sys
from tempfile import TemporaryDirectory

Expand Down
2 changes: 1 addition & 1 deletion .docs/Notebooks/plot_cross_section_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#
# ### Mapping is demonstrated for MODFLOW-2005 and MODFLOW-6 models in this notebook

import os

# + pycharm={"name": "#%%\n"}
import os
import sys
from tempfile import TemporaryDirectory

Expand Down
6 changes: 3 additions & 3 deletions .docs/Notebooks/plot_map_view_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
# ### Mapping is demonstrated for MODFLOW-2005, MODFLOW-USG, and MODFLOW-6 models in this notebook
#

import os

# +
import os
import sys
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -315,8 +315,6 @@
# + [markdown] pycharm={"name": "#%% md\n"}
# Array contours can be exported directly to a shapefile.

from shapefile import Reader

# + pycharm={"name": "#%%\n"}
from flopy.export.utils import ( # use export_contourf for filled contours
export_contours,
Expand All @@ -325,6 +323,8 @@
shp_path = os.path.join(modelpth, "contours.shp")
export_contours(shp_path, contour_set)

from shapefile import Reader

with Reader(shp_path) as r:
nshapes = len(r.shapes())
print("Contours:", nshapes)
Expand Down
3 changes: 2 additions & 1 deletion autotest/test_flopy_module.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import os
import re
from packaging.version import Version
from pathlib import Path

import numpy as np
from packaging.version import Version

import flopy


def test_import_and_version_string():
import flopy

# an error is raised if the version string can't be parsed
Version(flopy.__version__)

Expand Down
18 changes: 7 additions & 11 deletions flopy/utils/get_modflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,14 @@ def run_main(
release = get_release(repo, release_id, quiet)
assets = release.get("assets", [])

# Windows 64-bit asset in modflow6 repo release has no OS tag
if repo == "modflow6" and ostag == "win64":
asset = list(sorted(assets, key=lambda a: len(a["name"])))[0]
for asset in assets:
if ostag in asset["name"]:
break
else:
for asset in assets:
if ostag in asset["name"]:
break
else:
raise ValueError(
f"could not find ostag {ostag!r} from release {release['tag_name']!r}; "
f"see available assets here:\n{release['html_url']}"
)
raise ValueError(
f"could not find ostag {ostag!r} from release {release['tag_name']!r}; "
f"see available assets here:\n{release['html_url']}"
)
asset_name = asset["name"]
download_url = asset["browser_download_url"]
if repo == "modflow6":
Expand Down

0 comments on commit b8dffbc

Please sign in to comment.