Repository navigation
Convert path_input to str in _process_CLI_arguments - #4188
Open
barlowa124 wants to merge 1 commit into
Open
barlowa124 wants to merge 1 commit into
barlowa124 wants to merge 1 commit into
Conversation
The returned args are documented as a list of str, but path_input was appended unchanged. openmc.lib.init() calls .encode() on every argument, so Model.init_lib(directory=Path(...)) raised AttributeError after exporting the XML files. subprocess-based callers are unaffected. Fixes: openmc-dev#4185
This branch has not been deployed
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.
Description
Model.init_lib(directory=Path(...))fails withAttributeError: 'PosixPath' object has no attribute 'encode'(#4185). Thedirectoryargument is documented asPathLike, is passed through aspath_inputto_process_CLI_arguments, and reachesopenmc.lib.init, which calls.encode()on every argument.restart_fileis converted withstr()in the same function.path_inputwas appended unchanged.The fix converts
path_inputwithstr(), matching therestart_filehandling two blocks earlier. The subprocess-based callers (run,calculate_volumes) acceptstrarguments, so they are unaffected.plot_geometrytakes apath_inputdocumented asstronly and appends it unchanged. That path is left alone sincesubprocess.Popenacceptsos.PathLikearguments and the annotation does not promisePathLikesupport.str()was used rather thanos.fspath()to match therestart_fileconversion directly above it. For aPathLikeargument the two are equivalent.No documentation change is needed.
init_libalready annotatesdirectoryasPathLike | None, so the change brings the implementation in line with the documented contract.tests/unit_testshad no coverage of_process_CLI_arguments.The new
test_executor.pychecks thatpath_inputcomes back asstrfor bothstrandPathinputs. It could not be run locally becauseimport openmcrequires a builtlibopenmcand this environment has no HDF5 toolchain for the C++ build. The function was verified standalone instead. Before the change it returned aPosixPathfor aPathinput. After the change it returnsstr.Fixes #4185
AI Assistance
Checklist
Summary by CodeRabbit
Bug Fixes
Tests