Skip to content

Commit f8ed355

Browse files
fixed pytest and updated documentation references
1 parent 835dccf commit f8ed355

File tree

8 files changed

+71
-95
lines changed

8 files changed

+71
-95
lines changed

benchmarks/technical.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ def timeraw_import_imas():
1919
# `asv compare` :(
2020
"""
2121
def track_imas_versions():
22-
equilibrium = imas.equilibrium()
23-
equilibrium.ids_properties.homogeneous_time = imas.imasdef.IDS_TIME_MODE_INDEPENDENT
24-
dbentry = imas.DBEntry(imas.imasdef.MEMORY_BACKEND, "test", 1, 1)
22+
ids_factory = imas.IDSFactory()
23+
equilibrium = ids_factory.equilibrium()
24+
equilibrium.ids_properties.homogeneous_time = imas.ids_defs.IDS_TIME_MODE_INDEPENDENT
25+
dbentry = imas.DBEntry(imas.ids_defs.MEMORY_BACKEND, "test", 1, 1)
2526
dbentry.create()
2627
dbentry.put(equilibrium)
2728
equilibrium = dbentry.get("equilibrium")

ci/run_benchmark.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ asv machine --yes
5959
# Run ASV for the current commit, develop and main
6060
asv run --skip-existing-successful HEAD^!
6161
asv run --skip-existing-successful develop^!
62-
# asv run --skip-existing-successful main^!
62+
asv run --skip-existing-successful main^!
6363

6464
# Compare results
6565
if [ `git rev-parse --abbrev-ref HEAD` == develop ]
@@ -75,5 +75,5 @@ asv publish
7575
# And persistently store them
7676
cp -rf .asv/{results,html} "$BENCHMARKS_DIR"
7777

78-
deactivate
78+
7979

ci/run_pytest.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ pip freeze
3737
# Clean artifacts created by pytest
3838
rm -f junit.xml
3939
rm -rf htmlcov
40-
mkdir -p ~/tmp
41-
export PYTEST_DEBUG_TEMPROOT=~/tmp
42-
python -m pytest -n=auto --cov=imas --cov-report=term-missing --cov-report=html --junit-xml=junit.xml -x
4340

44-
deactivate
41+
# setups local directory to not to full /tmp directory with pytest temporary files
42+
# mkdir -p ~/tmp
43+
# export PYTEST_DEBUG_TEMPROOT=~/tmp
44+
python -m pytest -n=auto --cov=imas --cov-report=term-missing --cov-report=html --junit-xml=junit.xml
45+
46+

docs/source/benchmarking.rst

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _`benchmarking IMAS`:
1+
.. _`benchmarking IMAS-Python`:
22

33
Benchmarking IMAS-Python
44
========================
@@ -19,15 +19,14 @@ Technical benchmarks
1919
package.
2020

2121
Basic functional benchmarks
22-
These are for benchmarking functionality with an equivalent feature in the IMAS
23-
Access Layer HLI. In addition to tracking the performance of the IMAS-Python features
24-
over time, we can also benchmark the performance against the traditional HLI.
22+
These are for benchmarking functionality with an addition to track the performance
23+
of the IMAS-Python features over time.
2524

2625
For example: putting and getting IDSs.
2726

2827
IMAS-Python-specific functional benchmarks
29-
These are for benchmarking functionality without an equivalent feature in the IMAS
30-
Access Layer HLI. We use these for tracking the IMAS-Python performance over time.
28+
These are for benchmarking core functionalities for checking performance. We use these
29+
for tracking the IMAS-Python core features performance over time.
3130

3231
For example: data conversion between DD versions.
3332

@@ -62,33 +61,31 @@ contains tabular results. Some examples:
6261
.. code-block:: text
6362
:caption: Example output for a test parametrized in ``hli``
6463
65-
[ 58.33%] ··· core_profiles.Generate.time_create_core_profiles ok
66-
[ 58.33%] ··· ======== ============
67-
hli
68-
-------- ------------
69-
imas 22.9±0.4μs
70-
imas 408±8μs
71-
======== ============
64+
[56.25%] ··· core_profiles.Generate.time_create_core_profiles ok
65+
[56.25%] ··· ====== =============
66+
hli
67+
------ -------------
68+
imas 2.04±0.01μs
69+
====== =============
7270
73-
Here we see the benchmark ``core_profiles.Generate.time_create_core_profiles`` was
74-
repeated for multiple values of ``hli``: once for the ``imas`` HLI, and once for the
75-
``imas`` HLI.
71+
72+
Here we see the benchmark ``core_profiles.Generate.time_create_core_profiles`` for
73+
imas-python ``imas-python``.
7674

7775
Some benchmarks are parametrized in multiple dimensions, as in below example. This
7876
results in a 2D table of results.
7977

8078
.. code-block:: text
81-
:caption: Example output for a test parametrized in ``hli`` and ``backend``
82-
83-
[ 70.83%] ··· core_profiles.Get.time_get ok
84-
[ 70.83%] ··· ======== ========== ============ =========
85-
-- backend
86-
-------- ---------------------------------
87-
hli 13 14 11
88-
======== ========== ============ =========
89-
imas 75.1±1ms 70.2±0.5ms 207±2ms
90-
imas 241±4ms 229±2ms 364±6ms
91-
======== ========== ============ =========
79+
:caption: Example output for a test parametrized in ``imas-python`` and ``backend``
80+
81+
[65.62%] ··· core_profiles.Get.time_get ok
82+
[65.62%] ··· ====== ========= ========== ============ ========= ============
83+
-- backend
84+
------ --------------------------------------------------------
85+
hli HDF5 MDSplus memory ASCII netCDF
86+
====== ========= ========== ============ ========= ============
87+
imas 172±3ms 86.7±2ms 68.5±0.8ms 291±3ms 14.2±0.7ms
88+
====== ========= ========== ============ ========= ============
9289
9390
.. note::
9491
The backends are listed by their numerical IDS:
@@ -103,7 +100,7 @@ Running benchmarks (advanced)
103100
-----------------------------
104101

105102
Running benchmarks quickly, as explained in the previous section, is great during
106-
development and for comparing the performance of IMAS-Python against the imas HLI. However,
103+
development and for comparing the performance of IMAS-Python. However,
107104
``asv`` can also track the performance of benchmarks over various commits of IMAS-Python.
108105
Unfortunately this is a bit more tricky to set up.
109106

@@ -113,22 +110,7 @@ Setup advanced benchmarking
113110

114111
First, some background on how ``asv`` tracks performance: it creates an isolated virtual
115112
environment (using the ``virtualenv`` package) and installs IMAS-Python for each commit that
116-
will be benchmarked. However, because the virtual environment is isolated, the ``imas``
117-
package won't be available. We need to work around it by setting the environment
118-
variable ``ASV_PYTHONPATH``:
119-
120-
.. code-block:: console
121-
:caption: Setting up the ``ASV_PYTHONPATH`` on SDCC
122-
123-
$ module load IMAS
124-
$ export ASV_PYTHONPATH="$PYTHONPATH"
125-
126-
.. caution::
127-
128-
``imas`` must not be available on the ``ASV_PYTHONPATH`` to avoid the interfering
129-
of two imas modules (one on the ``PYTHONPATH``, and the other installed by ``asv``
130-
in the virtual environment).
131-
113+
will be benchmarked.
132114

133115
Deciding which commits to benchmark
134116
'''''''''''''''''''''''''''''''''''
@@ -184,19 +166,14 @@ Instead, you can submit a benchmark job to the compute nodes.
184166
.. code-block:: bash
185167
:caption: Benchmark run script (``run_benchmarks.sh``)
186168
187-
# Load IMAS module
169+
# Load IMAS-AL-Core module
188170
module purge
189-
module load IMAS
190-
# Verify we can run python and import imas
171+
module load IMAS-AL-Core
172+
module load Python
173+
174+
# Verify we can run python
191175
echo "Python version:"
192176
python --version
193-
echo "Import imas:"
194-
python -c 'import imas; print(imas)'
195-
196-
# Set the ASV_PYTHONPATH so we can `import imas` in the benchmarks
197-
export ASV_PYTHONPATH="$PYTHONPATH"
198-
echo "ASV_PYTHONPATH=$ASV_PYTHONPATH"
199-
echo
200177
201178
# Activate the virtual environment which has asv installed
202179
. venv_imas/bin/activate

docs/source/changelog.rst

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,35 @@ New features
4040
- IMAS-Python 1.1 adds support for Identifiers defined by the Data Dictionary. This
4141
functionality is described in detail in :ref:`Identifiers`.
4242
- Support for the new
43-
:py:const:`~imaspy.ids_defs.FLEXBUFFERS_SERIALIZER_PROTOCOL` that is
43+
:py:const:`~imas.ids_defs.FLEXBUFFERS_SERIALIZER_PROTOCOL` that is
4444
implemented in Access Layer Core 5.3. This is a much faster and more efficient
4545
serialization format than the
46-
:py:const:`~imaspy.ids_defs.ASCII_SERIALIZER_PROTOCOL`. The Flexbuffers
46+
:py:const:`~imas.ids_defs.ASCII_SERIALIZER_PROTOCOL`. The Flexbuffers
4747
serializer protocol requires ``imas_core`` version 5.3 or newer. It is the
4848
default serializer format when it is available. This features is not available
49-
when the variable :py:const:`~imaspy.ids_defs.FLEXBUFFERS_SERIALIZER_PROTOCOL`
49+
when the variable :py:const:`~imas.ids_defs.FLEXBUFFERS_SERIALIZER_PROTOCOL`
5050
is set to ``None``.
5151
- Preview feature: :ref:`IMAS netCDF files`. Store IDSs in a self-describing
5252
netCDF file, which can be used for sharing and/or archiving data.
5353

5454
This feature is in `preview` status, meaning that it may change in upcoming
5555
minor releases of IMAS-Python.
5656

57-
- Additional utility functions in :py:mod:`imaspy.util`:
57+
- Additional utility functions in :py:mod:`imas.util`:
5858

59-
- :py:func:`imaspy.util.tree_iter` can be used to iterate over all nodes inside
59+
- :py:func:`imas.util.tree_iter` can be used to iterate over all nodes inside
6060
an IDS.
61-
- :py:func:`imaspy.util.get_parent` can be used to get the parent element of
61+
- :py:func:`imas.util.get_parent` can be used to get the parent element of
6262
an IDS node.
63-
- :py:func:`imaspy.util.get_time_mode` is a convenience function to get the
63+
- :py:func:`imas.util.get_time_mode` is a convenience function to get the
6464
``ids_properties/homogeneous_time`` value for any node in the IDS.
65-
- :py:func:`imaspy.util.get_toplevel` returns the IDS Toplevel element for any
65+
- :py:func:`imas.util.get_toplevel` returns the IDS Toplevel element for any
6666
node in the IDS.
67-
- :py:func:`imaspy.util.is_lazy_loaded` will indicate whether an IDS is lazy
67+
- :py:func:`imas.util.is_lazy_loaded` will indicate whether an IDS is lazy
6868
loaded.
69-
- :py:func:`imaspy.util.get_full_path` returns the full path (including Array
69+
- :py:func:`imas.util.get_full_path` returns the full path (including Array
7070
of Structure indices) of a node.
71-
- :py:func:`imaspy.util.get_data_dictionary_version` returns the Data
71+
- :py:func:`imas.util.get_data_dictionary_version` returns the Data
7272
Dictionary version for which an IDS was created.
7373

7474
- Add support for IMAS Access Layer Core 5.2 and later. IMAS-Python can now be used
@@ -84,18 +84,18 @@ New features
8484
8585
pip install 'imas[imas-core] @ git+ssh://git@github.com/iterorganization/imas-core.git'
8686
87-
- A diff tool for IDSs: :py:func:`imaspy.util.idsdiff`.
87+
- A diff tool for IDSs: :py:func:`imas.util.idsdiff`.
8888
- Implement ``==`` equality checking for IDS Structures and Arrays of Structures
8989
(`IMAS-5120 <https://jira.iter.org/browse/IMAS-5120>`__).
9090
- Add option to ignore unknown Data Dictionary versions of data stored in the
9191
backend.
9292

93-
During a :py:meth:`~imaspy.db_entry.DBEntry.get` or
94-
:py:meth:`~imaspy.db_entry.DBEntry.get_slice`, IMAS-Python first reads the version
93+
During a :py:meth:`~imas.db_entry.DBEntry.get` or
94+
:py:meth:`~imas.db_entry.DBEntry.get_slice`, IMAS-Python first reads the version
9595
of the Data Dictionary that was used to store the IDS. When this version is
9696
not known to IMAS-Python, an error is raised. This error can now be ignored by
9797
setting the parameter
98-
:py:param:`~imaspy.db_entry.DBEntry.get.ignore_unknown_dd_version` to
98+
:py:param:`~imas.db_entry.DBEntry.get.ignore_unknown_dd_version` to
9999
``True``, and IMAS-Python will do its best to load the data anyway.
100100

101101
- A new command line tool exists for analyzing which Data Dictionary fields are
@@ -128,18 +128,18 @@ Breaking changes
128128
Bug fixes
129129
'''''''''
130130

131-
- Fixed a bug in :py:func:`imaspy.util.inspect` when inspecting lazy loaded IDSs.
131+
- Fixed a bug in :py:func:`imas.util.inspect` when inspecting lazy loaded IDSs.
132132
- Fixed a bug when converting the ``neutron_diagnostics`` IDS to/from Data
133133
Dictionary version ``3.41.0``.
134134
- Fixed a bug that allowed setting arbitrary attributes on IDS structures. It is
135135
only allowed to use attributes defined by the Data Dictionary.
136-
- Fixed a bug with :py:func:`~imaspy.ids_toplevel.IDSToplevel.serialize` when
136+
- Fixed a bug with :py:func:`~imas.ids_toplevel.IDSToplevel.serialize` when
137137
the IDS is in a non-default Data Dictionary version.
138138
- Fixed a bug when assigning ``nan`` to a FLT_0D, which would lead to a
139139
confusing and incorrect log message in IMAS-Python 1.0.
140140
- Fixed incorrect oldest supported DD version. Previously IMAS-Python indicated that
141141
DD ``3.21.1`` was supported, however ``3.22.0`` is the oldest Data Dictionary
142-
tested (and provided) with IMAS-Python. :py:attr:`imaspy.OLDEST_SUPPORTED_VERSION`
142+
tested (and provided) with IMAS-Python. :py:attr:`imas.OLDEST_SUPPORTED_VERSION`
143143
has been updated to reflect this.
144144
- Fixed a bug when using numpy functions, such as
145145
:external:py:func:`numpy.isclose` on scalar numbers. Previously an error was
@@ -157,16 +157,16 @@ Bug fixes
157157
Improved performance
158158
''''''''''''''''''''
159159

160-
- Improved performance of :py:meth:`~imaspy.ids_toplevel.IDSToplevel.validate`.
160+
- Improved performance of :py:meth:`~imas.ids_toplevel.IDSToplevel.validate`.
161161
- Improved creation of IMAS-Python IDS objects. This made filling IDSs and loading
162-
them with :py:meth:`~imaspy.db_entry.DBEntry.get` /
163-
:py:meth:`~imaspy.db_entry.DBEntry.get_slice` 10-20% faster.
162+
them with :py:meth:`~imas.db_entry.DBEntry.get` /
163+
:py:meth:`~imas.db_entry.DBEntry.get_slice` 10-20% faster.
164164
- Improved the performance of lazy loading. This is most noticeable with the
165165
``HDF5`` backend, which is now up to 40x faster than with IMAS-Python 1.0.
166-
- Improved the performance of :py:meth:`~imaspy.db_entry.DBEntry.get` /
167-
:py:meth:`~imaspy.db_entry.DBEntry.get_slice` /
168-
:py:meth:`~imaspy.db_entry.DBEntry.put` /
169-
:py:meth:`~imaspy.db_entry.DBEntry.put_slice` for IDSs with many nested arrays
166+
- Improved the performance of :py:meth:`~imas.db_entry.DBEntry.get` /
167+
:py:meth:`~imas.db_entry.DBEntry.get_slice` /
168+
:py:meth:`~imas.db_entry.DBEntry.put` /
169+
:py:meth:`~imas.db_entry.DBEntry.put_slice` for IDSs with many nested arrays
170170
of structures. This performance improvement is most noticeable for IDSs with
171171
filled GGD grids and data structures (up to 25% faster).
172172

@@ -195,7 +195,7 @@ recent DD versions. Further details on IDS conversion can be found in
195195
- Automatically convert data between 0D and 1D when possible (`IMAS-5170
196196
<https://jira.iter.org/browse/IMAS-5170>`__).
197197
The following type changes are now automatically supported by
198-
:py:func:`imaspy.convert_ids <imaspy.ids_convert.convert_ids>`:
198+
:py:func:`imas.convert_ids <imas.ids_convert.convert_ids>`:
199199

200200
- INT_0D to INT_1D
201201
- FLT_0D to FLT_1D

docs/source/ci_config.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Test with AL<version>
4949
5. In the "Script" Task, update the module(s) in the Argument field
5050

5151
Benchmark
52-
This job runs the :ref:`ASV benchmarks <benchmarking IMAS>` on the CI server. It
52+
This job runs the :ref:`ASV benchmarks <benchmarking IMAS-Python>` on the CI server. It
5353
is configured such that it can only run on a single CI agent
5454
(`io-ls-bamboowk6.iter.org`). There are two reasons for this:
5555

imas/dd_helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def _run_xsl_transformation(
134134
stylesheet_file=str(xsl_file),
135135
output_file=str(output_file),
136136
)
137-
logger.info("Transformation complete: %s -> %s", xsd_file, output_file)
138137

139138

140139
def build_data_dictionary(repo, tag: str, rebuild=False) -> None:

imas/test/test_dd_helpers.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
_idsdef_unzipped_relpath = Path("idsdef_unzipped")
1010

11+
1112
@pytest.mark.skip(reason="skipping IDSDef.zip generation")
1213
def test_prepare_data_dictionaries():
1314
prepare_data_dictionaries()
@@ -50,7 +51,3 @@ def test_prepare_data_dictionaries():
5051

5152
if _build_dir.exists():
5253
shutil.rmtree(_idsdef_unzipped_relpath)
53-
54-
55-
if __name__ == "__main__":
56-
pytest.main()

0 commit comments

Comments
 (0)