openmc-dev/data

depletion scripts can find openmc._utils

shimwell opened this issue · 4 comments

Recently we moved utils into the openmc/data repository from it's rpevious home which was openmc._utils

Two of the depletion scripts try to import utils from this old location
generate_endf71_chain_casl.py
generate_endf71_chain.py

One option for fixing this is to import utils from the parent directory as demonstrated here

https://gist.github.com/JungeAlexander/6ce0a5213f3af56d7369

We could change this one line

from openmc._utils import download

to this

current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
from utils import download

Which isn't very nice but it works.

Or perhaps this is a good time to thing about making a package

Does anyone have any preference or other solutions?

Good catch!

We could make a file link with ln utils.py depletion/, that way changes to one would be contained in the other. I'm not sure how portable these are to windows though...

Alternatively, we can use pathlib.Path(__file__).resolve().parents[1] which finds the absolute path for the file (one of the generators), and then backs out one directory. This directory could be inserted into sys.path

I guess it also depends on where these file should be run by the end user. If I clone the repository, and then move one of the generator scripts, then the utils file will not be in the parent directory

🤔

I guess another option is to move the depletion scripts to the base folder. Are all the xml files and json files needed?

There might be a case that the XML files are not necessary, as they can be downloaded from https://openmc.org/depletion-chains/. But, cloning this repository does make it easier to track any issues and changes that might arise in the chains. The CASL chain has been particularly interesting.

I believe the JSON files should remain, because these are useful for augmenting the depletion chains to account for non-local energy deposition in the base energy deposition model. These can be generated by generate_serpent_fissq.py based on ENDF data. But keeping these files is nice for the same reason the XML files are stored, namely one can watch their changes over time

Thanks for fixing this @paulromano and @drewejohnson