Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Mar 2, 2023

Conversation

spaulins-usgs
Copy link
Contributor

No description provided.

@codecov
Copy link

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
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.

@langevin-usgs
Copy link
Contributor

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

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
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) = "":

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
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"

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
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()

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
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
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
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.

None yet

4 participants