Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Next Next commit
Fix training assets (#105)
  • Loading branch information
olivhoenen authored Feb 27, 2026
commit 6d03d6859716bed357ab7c5516938d5fc7ca0f88
2 changes: 0 additions & 2 deletions imas/assets/ITER_134173_106_equilibrium.ids
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ equilibrium/vacuum_toroidal_field/b0
dim: 1
size: 3
-5.2999999999999998e+00 -5.2999999999999998e+00 -5.2999999999999998e+00
equilibrium/grids_ggd
size: 1
equilibrium/time_slice
size: 3
equilibrium/time_slice[0]/boundary/outline/r
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_convert_core_edge_plasma.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def assert_equal(core_edge, plasma):


def test_convert_training_core_profiles():
with imas.training.get_training_db_entry() as entry:
with imas.training.get_training_db_entry(convert=True) as entry:
cp = entry.get("core_profiles")

pp = imas.convert_to_plasma_profiles(cp)
Expand Down
17 changes: 11 additions & 6 deletions imas/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# You should have received the IMAS-Python LICENSE file with this project.
"""Functions that are useful for the IMAS-Python training courses."""

from unittest.mock import patch

try:
from importlib.resources import files
except ImportError: # Python 3.8 support
Expand All @@ -12,15 +10,22 @@
import imas


def get_training_db_entry() -> imas.DBEntry:
"""Open and return an ``imas.DBEntry`` pointing to the training data."""
def get_training_db_entry(convert=False) -> imas.DBEntry:
"""Open and return an ``imas.DBEntry`` pointing to the training data.

Args:
convert: if True, converts assets to default DD version
"""
assets_path = files(imas) / "assets/"
entry = imas.DBEntry(f"imas:ascii?path={assets_path}", "r")

output_entry = imas.DBEntry("imas:memory?path=/", "w")
version = None if convert else "3.39.0"
output_entry = imas.DBEntry("imas:memory?path=/", "w", dd_version=version)
for ids_name in ["core_profiles", "equilibrium"]:
ids = entry.get(ids_name, autoconvert=False)
with patch.dict("os.environ", {"IMAS_AL_DISABLE_VALIDATE": "1"}):
if convert:
output_entry.put(imas.convert_ids(ids, output_entry.dd_version))
else:
output_entry.put(ids)
entry.close()
return output_entry
Loading