Skip to content

Commit 6d03d68

Browse files
authored
Fix training assets (#105)
1 parent 049c5f7 commit 6d03d68

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

imas/assets/ITER_134173_106_equilibrium.ids

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ equilibrium/vacuum_toroidal_field/b0
2626
dim: 1
2727
size: 3
2828
-5.2999999999999998e+00 -5.2999999999999998e+00 -5.2999999999999998e+00
29-
equilibrium/grids_ggd
30-
size: 1
3129
equilibrium/time_slice
3230
size: 3
3331
equilibrium/time_slice[0]/boundary/outline/r

imas/test/test_convert_core_edge_plasma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def assert_equal(core_edge, plasma):
1212

1313

1414
def test_convert_training_core_profiles():
15-
with imas.training.get_training_db_entry() as entry:
15+
with imas.training.get_training_db_entry(convert=True) as entry:
1616
cp = entry.get("core_profiles")
1717

1818
pp = imas.convert_to_plasma_profiles(cp)

imas/training.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# You should have received the IMAS-Python LICENSE file with this project.
33
"""Functions that are useful for the IMAS-Python training courses."""
44

5-
from unittest.mock import patch
6-
75
try:
86
from importlib.resources import files
97
except ImportError: # Python 3.8 support
@@ -12,15 +10,22 @@
1210
import imas
1311

1412

15-
def get_training_db_entry() -> imas.DBEntry:
16-
"""Open and return an ``imas.DBEntry`` pointing to the training data."""
13+
def get_training_db_entry(convert=False) -> imas.DBEntry:
14+
"""Open and return an ``imas.DBEntry`` pointing to the training data.
15+
16+
Args:
17+
convert: if True, converts assets to default DD version
18+
"""
1719
assets_path = files(imas) / "assets/"
1820
entry = imas.DBEntry(f"imas:ascii?path={assets_path}", "r")
1921

20-
output_entry = imas.DBEntry("imas:memory?path=/", "w")
22+
version = None if convert else "3.39.0"
23+
output_entry = imas.DBEntry("imas:memory?path=/", "w", dd_version=version)
2124
for ids_name in ["core_profiles", "equilibrium"]:
2225
ids = entry.get(ids_name, autoconvert=False)
23-
with patch.dict("os.environ", {"IMAS_AL_DISABLE_VALIDATE": "1"}):
26+
if convert:
2427
output_entry.put(imas.convert_ids(ids, output_entry.dd_version))
28+
else:
29+
output_entry.put(ids)
2530
entry.close()
2631
return output_entry

0 commit comments

Comments
 (0)