fix(exe path): FloPy now correctly resolves relative paths to mf6 executable (#1633)#1727
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1727 +/- ##
=======================================
Coverage 71.9% 71.9%
=======================================
Files 253 253
Lines 55996 56004 +8
=======================================
+ Hits 40275 40282 +7
- Misses 15721 15722 +1
|
christianlangevin
approved these changes
Feb 24, 2023
|
Good call, @jlarsen-usgs. And should the os.path routines be converted to pathlib? |
| raise Exception( | ||
| f"The program {exe_name} does not exist or is not executable." | ||
| ) | ||
| if os.path.dirname(exe_name) == "": |
Contributor
There was a problem hiding this comment.
exe_name = Path(exe_name)
if str(exe_name.parent) = "":| if os.path.dirname(exe_name) == "": | ||
| exe = which(exe_name) | ||
| if exe is None: | ||
| if exe_name.lower().endswith(".exe"): |
Contributor
There was a problem hiding this comment.
if exe_name.suffix.lower() == ".exe"| 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) |
Contributor
There was a problem hiding this comment.
exe_name = exe_name.absolute()| 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( |
Contributor
There was a problem hiding this comment.
if not exe_name.exists() and not Path(f"{str(exe_name)}.exe").exits():
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. |
Contributor
Author
|
@jlarsen-usgs All the pathlib changes you suggested have been added and the remaining exe path code has been updated for consistency. |
This was referenced Mar 3, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.