Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions imas/backends/imas_core/db_entry_al.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from .al_context import ALContext, LazyALContext
from .db_entry_helpers import delete_children, get_children, put_children
from .imas_interface import LLInterfaceError, ll_interface
from .mdsplus_model import mdsplus_model_dir
from .mdsplus_model import mdsplus_model_dir, get_mdsplus_model_var
from .uda_support import extract_idsdef, get_dd_version_from_idsdef_xml

_OPEN_MODES = {
Expand Down Expand Up @@ -120,7 +120,7 @@ def _setup_backend(cls, backend: str, mode: int, factory: IDSFactory) -> None:
# Building the MDS+ models is required when creating a new Data Entry
ids_path = mdsplus_model_dir(factory)
if ids_path:
os.environ["ids_path"] = ids_path
os.environ[get_mdsplus_model_var()] = ids_path

elif backend == "uda":
# Set IDSDEF_PATH to point the UDA backend to the selected DD version
Expand Down
19 changes: 18 additions & 1 deletion imas/backends/imas_core/mdsplus_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pathlib import Path
from subprocess import CalledProcessError, check_output
from zlib import crc32
from packaging.version import Version

try:
from importlib.resources import as_file, files
Expand All @@ -24,6 +25,8 @@
from imas.exception import MDSPlusModelError
from imas.ids_factory import IDSFactory

from .imas_interface import ll_interface

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -292,6 +295,20 @@ def create_model_ids_xml(cache_dir_path, fname, version):
raise e


def get_mdsplus_model_var() -> str:
"""
Return the environemnt variable name used by IMAS-Core to locate models:

- 'ids_path' for IMAS-Core<5.6
- 'MDSPLUS_MODELS_PATH' for IMAS-Core>=5.6
"""
return (
"ids_path"
if ll_interface._al_version < Version("5.6.0")
else "MDSPLUS_MODELS_PATH"
)


def create_mdsplus_model(cache_dir_path: Path) -> None:
"""Use jtraverser to compile a valid MDS model file."""
try:
Expand Down Expand Up @@ -322,7 +339,7 @@ def create_mdsplus_model(cache_dir_path: Path) -> None:
env={
"PATH": os.environ.get("PATH", ""),
"LD_LIBRARY_PATH": os.environ.get("LD_LIBRARY_PATH", ""),
"ids_path": str(cache_dir_path),
get_mdsplus_model_var(): str(cache_dir_path),
},
)
# Touch a file to show that we have finished the model
Expand Down
Loading