From fe571a49323d7e022d4ac319c565d4ef1e5f0cd2 Mon Sep 17 00:00:00 2001 From: Maarten Sebregts Date: Wed, 29 Oct 2025 10:51:19 +0100 Subject: [PATCH] Add warning when a user implicitly converts an IDS between major versions on put() And fix an example in the multi-DD documentation. --- docs/source/multi-dd.rst | 2 +- imas/backends/imas_core/db_entry_al.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/source/multi-dd.rst b/docs/source/multi-dd.rst index 701b4e8..a115ce2 100644 --- a/docs/source/multi-dd.rst +++ b/docs/source/multi-dd.rst @@ -23,7 +23,7 @@ example: factory_3_32_0 = imas.IDSFactory("3.32.0") # Use DD version 3.32.0 # Will write IDSs to the backend in DD version 3.32.0 - dbentry = imas.DBEntry(imas.ids_defs.HDF5_BACKEND, "TEST", 10, 2, version="3.32.0") + dbentry = imas.DBEntry("imas:hdf5?path=dd3.32.0-output/", "w", dd_version="3.32.0") dbentry.create() .. seealso:: :ref:`multi-dd training` diff --git a/imas/backends/imas_core/db_entry_al.py b/imas/backends/imas_core/db_entry_al.py index 2500bd3..0336179 100644 --- a/imas/backends/imas_core/db_entry_al.py +++ b/imas/backends/imas_core/db_entry_al.py @@ -11,6 +11,7 @@ from packaging.version import Version +import imas from imas.backends.db_entry_impl import GetSampleParameters, GetSliceParameters from imas.db_entry import DBEntryImpl from imas.exception import DataEntryException, LowlevelError @@ -280,6 +281,16 @@ def put(self, ids: IDSToplevel, occurrence: int, is_slice: bool) -> None: # Create a version conversion map, if needed nbc_map = None if ids._version != self._ids_factory._version: + if ids._version.split(".")[0] != self._ids_factory._version.split(".")[0]: + logger.warning( + "Provided IDS uses DD %s which has a different major version than " + "the Data Entry (%s). IMAS-Python will convert the data " + "automatically, but this does not cover all changes. " + "See %s/multi-dd.html#conversion-of-idss-between-dd-versions", + ids._version, + self._ids_factory._version, + imas.PUBLISHED_DOCUMENTATION_ROOT, + ) ddmap, source_is_older = dd_version_map_from_factories( ids_name, ids._parent, self._ids_factory )