Skip to content

Ensure that Model.run() works when specifying a custom XML path - #2889

Merged
pshriwise merged 3 commits into
openmc-dev:developfrom
paulromano:model-run-path-fix
Mar 12, 2024
Merged

pshriwise merged 3 commits into
openmc-dev:developfrom
paulromano:model-run-path-fix

Conversation

@paulromano

Copy link
Copy Markdown
Contributor

Description

The Model.run() method allows you to specify keyword arguments that are passed to export_to_model_xml. If you pass a path keyword argument, it will be used to write the corresponding XML file but it is not taken into account in the call to openmc.run which will cause it to look for "model.xml" (or a set of individual XML files). This change ensures that when the user calls model.run(path=...), the right path is used in the call to openmc.run().

Fixes # (issue)

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@paulromano
paulromano requested a review from drewejohnson as a code owner March 4, 2024 03:59
@paulromano

Copy link
Copy Markdown
Contributor Author

I noticed that I was getting test failures in unrelated tests due to the use of pytest.warns(None), which no longer works in pytest 8.1 (released today). I've updated a few lines of code in the relevant tests to get them passing.

@pshriwise pshriwise left a comment

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.

Thanks for the update and the CI fix @paulromano!

@pshriwise
pshriwise merged commit c4a75f7 into openmc-dev:develop Mar 12, 2024
@shimwell

Copy link
Copy Markdown
Member

ah sorry I was late to this PR.

If I was earlier I would have mentioned that os.mkdir(xml_path) fails when making multiple directories

e.g
xml_path = Path('output/file/stroage')
os.mkdir(xml_path)

FileNotFoundError: [Errno 2] No such file or directory:

in other places we make use of pathlib and parents= True
xml_path.mkdir(parents=True, exist_ok=True)

@paulromano
paulromano deleted the model-run-path-fix branch April 18, 2024 23:14
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
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.

3 participants