Skip to content

Resolve relative input paths relative to XML files - #4031

Merged
GuySten merged 5 commits into
openmc-dev:developfrom
paulromano:dagmc-relative-path-fix
Jul 28, 2026
Merged

Resolve relative input paths relative to XML files#4031
GuySten merged 5 commits into
openmc-dev:developfrom
paulromano:dagmc-relative-path-fix

Conversation

@paulromano

Copy link
Copy Markdown
Contributor

Description

Currently, if you call Model.from_model_xml() on a model.xml file that is not in your current directory, any files that it references with a relative path will be treated as though they are relative to your current working directory rather than the parent directory of the XML file itself. This PR fixes this so that XML-loading entry points now establish the directory containing the source XML file as the path-resolution context. Nested inputs such as DAGMC geometry, meshes, and other referenced files are therefore found relative to the XML file rather than the process's current working directory when openmc.config['resolve_paths'] is enabled. The context is scoped and safely restored after parsing, including nested XML-loading operations.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 18) 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)

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

I've updated plots.py.
Looks good to me now.

@GuySten GuySten added the Merging Soon PR will be merged in < 24 hrs if no further comments are made. label Jul 27, 2026
@GuySten GuySten added the Bugs label Jul 28, 2026
@GuySten
GuySten merged commit f3a8ba2 into openmc-dev:develop Jul 28, 2026
18 checks passed
@paulromano
paulromano deleted the dagmc-relative-path-fix branch July 28, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Merging Soon PR will be merged in < 24 hrs if no further comments are made.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants