Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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
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:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with changing the default from convert to do-not-convert, however there's a couple of tests failing now that seem to need convert=True.

@olivhoenen olivhoenen Feb 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I hesitated but I'll fix the tests then because I would prefer that the default training examples do not come with messages about missing quantities, DD conversion aspects shall come at a later stage for newcomers IMO.

"""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 = imas.dd_zip.latest_dd_version() if convert else "3.39.0"
Comment thread
olivhoenen marked this conversation as resolved.
Resolved
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