Skip to content

Commit 474bc8b

Browse files
authored
Merge pull request #133 from iterorganization/release/2.3
2 parents 049c5f7 + 77939fc commit 474bc8b

33 files changed

Lines changed: 735 additions & 279 deletions

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Github Actions
4+
- package-ecosystem: "github-actions"
5+
# Look for `/.github/workflows` and `/action.yml` or `.yaml`
6+
directory: "/"
7+
# Check for updates once a week
8+
schedule:
9+
interval: "weekly"
10+

.github/workflows/linting.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212

1313
steps:
1414
- name: Checkout IMAS-Python sources
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v6
1616

1717
- name: Set up Python
18-
uses: actions/setup-python@v5
18+
uses: actions/setup-python@v6
1919
with:
2020
# until saxonche is available in 3.13
2121
# https://saxonica.plan.io/issues/6561

.github/workflows/publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
name: Build distribution
1111
runs-on: ubuntu-22.04
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v6
1414
with:
1515
fetch-depth: 0
1616
- name: Set up Python
17-
uses: actions/setup-python@v5
17+
uses: actions/setup-python@v6
1818
with:
1919
# until saxonche is available in 3.13
2020
# https://saxonica.plan.io/issues/6561
@@ -25,7 +25,7 @@ jobs:
2525
- name: Build a binary wheel and a source tarball
2626
run: python3 -m build .
2727
- name: Store the distribution packages
28-
uses: actions/upload-artifact@v4
28+
uses: actions/upload-artifact@v7
2929
with:
3030
name: python-package-distributions
3131
path: dist/
@@ -43,7 +43,7 @@ jobs:
4343
id-token: write # IMPORTANT: mandatory for trusted publishing
4444
steps:
4545
- name: Download all the dists
46-
uses: actions/download-artifact@v4
46+
uses: actions/download-artifact@v8
4747
with:
4848
name: python-package-distributions
4949
path: dist/
@@ -63,7 +63,7 @@ jobs:
6363
id-token: write # IMPORTANT: mandatory for trusted publishing
6464
steps:
6565
- name: Download all the dists
66-
uses: actions/download-artifact@v4
66+
uses: actions/download-artifact@v8
6767
with:
6868
name: python-package-distributions
6969
path: dist/

.github/workflows/test_with_pytest.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v4
17+
uses: actions/checkout@v6
1818

1919
- name: Set up Python ${{ matrix.python-version }}
2020

21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v6
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
- name: Display Python version
@@ -37,13 +37,13 @@ jobs:
3737
python -m pytest -n=auto --cov=imas --cov-report=term-missing --cov-report=xml:coverage.xml --cov-report=html:htmlcov --junit-xml=junit.xml
3838
3939
- name: Upload coverage report ${{ matrix.python-version }}
40-
uses: actions/upload-artifact@v4
40+
uses: actions/upload-artifact@v7
4141
with:
4242
name: coverage-report-${{ matrix.python-version }}
4343
path: htmlcov
4444

4545
- name: Upload test report ${{ matrix.python-version }}
46-
uses: actions/upload-artifact@v4
46+
uses: actions/upload-artifact@v7
4747
with:
4848
name: test-report-${{ matrix.python-version }}
4949
path: junit.xml

.github/workflows/verify_sphinx_doc.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ python:
2020
sphinx:
2121
builder: html
2222
configuration: docs/source/conf.py
23-
fail_on_warning: false
23+
fail_on_warning: true

docs/source/changelog.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,55 @@
33
Changelog
44
=========
55

6+
What's new in IMAS-Python 2.3.0
7+
-------------------------------
8+
9+
Features
10+
''''''''
11+
12+
- :merge:`131`: introduce alias and units metadata in the :ref:`Identifiers` API
13+
- :merge:`104`: add a :py:func:`imas.db_entry.DBEntry.list_filled_paths` function (requires imas_core >= 5.7 for HDF5 backend)
14+
15+
Improvements
16+
''''''''''''
17+
18+
- :issue:`116`: migrate `magnetics` obsolescent fields (`method -> ip`, `bpol_probe -> b_field_pol_probe`) with a value during a 3to4 conversion
19+
- :merge:`112`: include metadata variables when writing an IDS to a netCDF files with the function `to_xarray`, allowing to read back the IDS with a `get` (see :ref:`Store Xarray Datasets in IMAS-compatible netCDF file`)
20+
- improve documentation w.r.t netcdf URI and UDA backend usage limitations and associated workarounds
21+
22+
Bug fixes
23+
'''''''''
24+
25+
- :issue:`118`: fix deprecation warning with copy keyword for __array__ implementation (Numpy > 2)
26+
- :issue:`117`: fix 3to4 conversion of name/identifier when identifier is empty
27+
- :merge:`105`: fix training data assets that failed loading
28+
29+
30+
31+
What's new in IMAS-Python 2.2.0
32+
-------------------------------
33+
34+
Features
35+
''''''''
36+
- :issue:`44`: add `--convert-to-plasma-ids` option to `imas convert`
37+
38+
Improvements
39+
''''''''''''
40+
41+
- :merge:`100`: remove legacy tool `extract_test_data`
42+
- :merge:`98`: support MDSplus models configuration change introduced in imas_core >= 5.6
43+
- :issue:`97`: better documentation, exception message and control of DD compatibility when using UDA backend
44+
- :merge:`95`: defer loading the default DD definitions
45+
- :issue:`91`: remove hidden `has_imas` attribute (may break compatibility of applications that used it!)
46+
47+
Bug fixes
48+
'''''''''
49+
50+
- :merge:`100`: fix incorrect type hints
51+
- :issue:`89`: properly unpack 0D data when reading an IDS from a netCDF file
52+
53+
54+
655
What's new in IMAS-Python 2.1.0
756
-------------------------------
857

docs/source/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
author = "ITER Organization"
3535
src_host = "https://github.com/iterorganization/"
3636

37+
# Warn about missing references
38+
nitpicky = True
39+
3740
# Parse urls here for convenience, to be re-used
3841
# ITER docs
3942
iter_projects = "https://github.com/iterorganization/"

docs/source/identifiers.rst

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ enumerated list of options for defining, for example:
1414
- These may have alternative naming conventions supported through aliases
1515
(e.g., "235U" and "U_235" for Uranium 235).
1616

17-
Identifiers are a list of possible valid labels. Each label has up to four
18-
representations:
17+
Identifiers are a list of possible valid options. Each option has three representations
18+
that are stored in an IDS:
1919

2020
1. An index (integer)
2121
2. A name (short string)
2222
3. A description (long string)
23-
4. List of aliases (list of short strings)
23+
24+
.. seealso::
25+
`Data Dictionary documentation for identifiers
26+
<https://imas-data-dictionary.readthedocs.io/en/latest/identifiers.html>`__
2427

2528

2629
Identifiers in IMAS-Python
@@ -32,6 +35,20 @@ constructed on-demand from the loaded Data Dictionary definitions.
3235
All identifier enums can be accessed through ``imas.identifiers``. A list of
3336
the available identifiers is stored as ``imas.identifiers.identifiers``.
3437

38+
Each identifier option provides the following attributes:
39+
40+
- ``name``: the name of the option.
41+
- ``index``: the integer index value of the option.
42+
- ``description``: a longer string describing the option.
43+
- ``aliases``: a list of aliases that can be used instead of the name.
44+
- ``units``: optional information about the units of the quantities that are affected by
45+
the identifier option. Take, for example, the `poloidal plan coordinate identifier
46+
<https://imas-data-dictionary.readthedocs.io/en/stable/generated/identifier/poloidal_plane_coordinates_identifier.html>`__
47+
which affects the units of ``grid/dim1`` and ``grid/dim2``.
48+
49+
.. versionadded:: 2.1.0 ``aliases`` for identifiers.
50+
.. versionadded:: 2.3.0 ``units`` metadata.
51+
3552
.. code-block:: python
3653
:caption: Accessing identifiers
3754
@@ -47,6 +64,9 @@ the available identifiers is stored as ``imas.identifiers.identifiers``.
4764
print(csid.total.index)
4865
print(csid.total.description)
4966
67+
# Search identifier options by their index value
68+
print(csid(1))
69+
5070
# Access identifiers with aliases (when available)
5171
mid = imas.identifiers.materials_identifier
5272
print(mid["235U"].name) # Access by canonical name
@@ -57,12 +77,12 @@ the available identifiers is stored as ``imas.identifiers.identifiers``.
5777
assert mid["235U"].name is mid.U_235.name
5878
5979
# Item access is also possible
60-
print(identifiers["edge_source_identifier"])
80+
print(imas.identifiers["edge_source_identifier"])
6181
6282
# You can use imas.util.inspect to list all options
63-
imas.util.inspect(identifiers.ggd_identifier)
83+
imas.util.inspect(imas.identifiers.ggd_identifier)
6484
# And also to get more details of a specific option
65-
imas.util.inspect(identifiers.ggd_identifier.SN)
85+
imas.util.inspect(imas.identifiers.ggd_identifier.SN)
6686
6787
# When an IDS node is an identifier, you can use
6888
# metadata.identifier_enum to get the identifier
@@ -186,6 +206,7 @@ material_identifier["235U"].
186206
mat.names[0] = mid.U_235.name # enum value via alias
187207
mat.names[0] = mid["U_235"].name # enum value via alias
188208
209+
189210
Compare identifiers
190211
-------------------
191212

docs/source/intro.rst

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,6 @@ get an error message if this is not possible:
8686
Load and store an IDS to disk with IMAS-Core
8787
''''''''''''''''''''''''''''''''''''''''''''
8888

89-
.. note::
90-
91-
- This functionality requires the IMAS-Core, until this library is openly available
92-
on GitHub you may need to fetch it from `git.iter.org <https://git.iter.org/>`_
93-
(requires to have an ITER account). Using IMAS-Core also enable slicing methods
94-
:py:meth:`~imas.db_entry.DBEntry.get_slice`,
95-
:py:meth:`~imas.db_entry.DBEntry.put_slice` and
96-
:py:meth:`~imas.db_entry.DBEntry.get_sample` (with IMAS-Core>=5.4).
97-
- If you can't have access to it, you can save IDS to disk with the built-in
98-
netCDF backend :ref:`Load and store an IDS to disk with netCDF`
99-
10089
To store an IDS to disk, we need to indicate the following URI to the
10190
IMAS-Core: ``imas:<backend>?path=<path_to_folder>`` or using the legacy query keys
10291
``imas:<backend>?user=<user>;database=<database>;version=<version>;pulse=<pulse>;run=<run>``
@@ -115,11 +104,9 @@ In IMAS-Python you do this as follows:
115104
>>> # now store the core_profiles IDS we just populated
116105
>>> dbentry.put(core_profiles)
117106
118-
.. image:: imas_structure.png
119-
120107
To load an IDS from disk, you need to specify the same information as
121108
when storing the IDS (see above). Once the data entry is opened, you
122-
can use ``<IDS>.get()`` to load IDS data from disk:
109+
can use ``dbentry.get()`` to load IDS data from disk:
123110

124111
.. code-block:: python
125112
@@ -146,11 +133,34 @@ In IMAS-Python you do this as follows:
146133
147134
To load an IDS from disk, you need to specify the same file information as
148135
when storing the IDS. Once the data entry is opened, you
149-
can use ``<IDS>.get()`` to load IDS data from disk:
136+
can use ``dbentry.get()`` to load IDS data from disk:
150137

151138
.. code-block:: python
152139
153140
>>> # Now load the core_profiles IDS back from disk
154141
>>> dbentry2 = imas.DBEntry("mypulsefile.nc","r")
155142
>>> core_profiles2 = dbentry2.get("core_profiles")
156143
>>> print(core_profiles2.ids_properties.comment.value)
144+
145+
146+
Data Entry API overview
147+
'''''''''''''''''''''''
148+
149+
See the documentation of :py:class:`imas.DBEntry <imas.db_entry.DBEntry>` for more
150+
details on reading and writing IDSs to disk. Useful functions include:
151+
152+
- :py:meth:`~imas.db_entry.DBEntry.put` and :py:meth:`~imas.db_entry.DBEntry.put_slice`
153+
to write a full IDS or write append a time slice to existing data.
154+
- :py:meth:`~imas.db_entry.DBEntry.get`, :py:meth:`~imas.db_entry.DBEntry.get_slice` and
155+
:py:meth:`~imas.db_entry.DBEntry.get_sample` to read all time slices, a single time
156+
slice, or a sample of time slices from disk. ``get_slice()`` and ``get_sample()`` can
157+
also interpolate data to a requested point in time.
158+
159+
All three ``get()`` methods have a ``lazy`` mode, which will only load data from disk
160+
when you need it. This can greatly speed up data access in some scenarios. See
161+
:ref:`Lazy loading` for more details.
162+
- :py:meth:`~imas.db_entry.DBEntry.list_all_occurrences` to query whether there are any
163+
occurrences of a certain IDS stored on disk.
164+
- :py:meth:`~imas.db_entry.DBEntry.list_filled_paths` to query which Data Dictionary
165+
paths have data filled inside a specific IDS.
166+

0 commit comments

Comments
 (0)