Skip to content

fix(exe path): FloPy now correctly resolves relative paths to mf6 executable (#1633)#1727

Merged
spaulins-usgs merged 2 commits into
modflowpy:developfrom
spaulins-usgs:develop
Mar 2, 2023
Merged

fix(exe path): FloPy now correctly resolves relative paths to mf6 executable (#1633)#1727
spaulins-usgs merged 2 commits into
modflowpy:developfrom
spaulins-usgs:develop

Conversation

@spaulins-usgs
Copy link
Copy Markdown
Contributor

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 21, 2023

Codecov Report

Merging #1727 (e30e609) into develop (ff9b926) will increase coverage by 0.0%.
The diff coverage is 72.7%.

@@           Coverage Diff           @@
##           develop   #1727   +/-   ##
=======================================
  Coverage     71.9%   71.9%           
=======================================
  Files          253     253           
  Lines        55996   56004    +8     
=======================================
+ Hits         40275   40282    +7     
- Misses       15721   15722    +1     
Impacted Files Coverage Δ
flopy/mbase.py 69.3% <72.7%> (+0.1%) ⬆️

Copy link
Copy Markdown
Contributor

@jlarsen-usgs jlarsen-usgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR should probably be merged after #1728. #1728 renames flopy_io.relpath_printstr() as flopy_io.relpath_safe() and has updated that method.

@christianlangevin
Copy link
Copy Markdown

Good call, @jlarsen-usgs. And should the os.path routines be converted to pathlib?

Comment thread flopy/mbase.py Outdated
raise Exception(
f"The program {exe_name} does not exist or is not executable."
)
if os.path.dirname(exe_name) == "":
Copy link
Copy Markdown
Contributor

@jlarsen-usgs jlarsen-usgs Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exe_name = Path(exe_name)
if str(exe_name.parent) = "":

Comment thread flopy/mbase.py Outdated
if os.path.dirname(exe_name) == "":
exe = which(exe_name)
if exe is None:
if exe_name.lower().endswith(".exe"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if exe_name.suffix.lower() == ".exe"

Comment thread flopy/mbase.py Outdated
print(
f"FloPy is using the following executable to run the model: {flopy_io.relpath_printstr(model_ws, exe)}"
# make relative path into absolute path
exe_name = os.path.abspath(exe_name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exe_name = exe_name.absolute()

Comment thread flopy/mbase.py Outdated
f"FloPy is using the following executable to run the model: {flopy_io.relpath_printstr(model_ws, exe)}"
# make relative path into absolute path
exe_name = os.path.abspath(exe_name)
if not os.path.exists(exe_name) and not os.path.exists(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not exe_name.exists() and not Path(f"{str(exe_name)}.exe").exits():

@jlarsen-usgs
Copy link
Copy Markdown
Contributor

Left a few potential suggestions for changing this over to pathlib from os. There might be better methods for dealing with the paths in pathlib, but here's a few that I saw.

@spaulins-usgs
Copy link
Copy Markdown
Contributor Author

@jlarsen-usgs All the pathlib changes you suggested have been added and the remaining exe path code has been updated for consistency.

@spaulins-usgs spaulins-usgs reopened this Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants