Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ updates:
# Check for updates once a week
schedule:
interval: "weekly"
# Group actions version bumps into a single PR
groups:
actions-deps:
patterns:
- "*"

4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: Checkout IMAS-Python sources
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
# until saxonche is available in 3.13
# https://saxonica.plan.io/issues/6561
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
name: Build distribution
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
# until saxonche is available in 3.13
# https://saxonica.plan.io/issues/6561
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_with_pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v7

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

uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
Expand Down
17 changes: 17 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
Changelog
=========

What's new in IMAS-Python 2.3.1
-------------------------------

Improvements
''''''''''''

- :merge:`140`: improve performance of ``hasattr()`` on IDS structures
- :merge:`139`: improve performance of :py:meth:`~imas.ids_toplevel.IDSToplevel.validate` for large arrays of structures

Bugs
''''

- :issue:`146`: Fix creation of MDSplus models, regression since 2.2.0 when used together with IMAS-Core >= 5.6
- Fix broken test (due to breaking change in xxhash>=4 dep)



What's new in IMAS-Python 2.3.0
-------------------------------

Expand Down
14 changes: 11 additions & 3 deletions imas/backends/imas_core/mdsplus_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import time
import uuid
from pathlib import Path
from subprocess import CalledProcessError, check_output
from subprocess import STDOUT, CalledProcessError, check_output
from zlib import crc32
from packaging.version import Version

Expand Down Expand Up @@ -324,12 +324,19 @@ def create_mdsplus_model(cache_dir_path: Path) -> None:
"Could not determine CompileTree class in jTraverser.jar."
)
compiletree = compiletree_class.rpartition(".class")[0].replace("/", ".")
# only add option to suppress warning if the JVM supports it
native_access = ["--enable-native-access=ALL-UNNAMED"]
try:
check_output(["java", *native_access, "-version"], stderr=STDOUT)
except CalledProcessError:
native_access = []
check_output(
[
"java",
"-Xms1g", # what do these do?
"-Xmx8g", # what do these do?
"-XX:+UseG1GC", # what do these do?
*native_access,
"-cp",
jarfile,
compiletree,
Expand All @@ -339,13 +346,14 @@ def create_mdsplus_model(cache_dir_path: Path) -> None:
env={
"PATH": os.environ.get("PATH", ""),
"LD_LIBRARY_PATH": os.environ.get("LD_LIBRARY_PATH", ""),
get_mdsplus_model_var(): str(cache_dir_path),
# MDSplus locates models through '<tree>_path' (tree='ids')
"ids_path": str(cache_dir_path),
},
)
# Touch a file to show that we have finished the model
(cache_dir_path / "done.txt").touch()
except CalledProcessError as e:
logger.error("Error making MDSPlus model in {path}", cache_dir_path)
logger.error("Error making MDSPlus model in %s", cache_dir_path)
raise e


Expand Down
21 changes: 11 additions & 10 deletions imas/ids_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, coordinate_spec: str) -> None:
logger.debug(
f"Ignoring invalid coordinate specifier {spec}", exc_info=True
)
self.references: "tuple[IDSPath]" = tuple(refs)
self.references: "tuple[IDSPath, ...]" = tuple(refs)
"""A tuple paths that this coordinate refers to.
"""

Expand Down Expand Up @@ -357,28 +357,29 @@ def _capture_goto_errors(self, dim, coordinate):
IDSPath.goto().
"""
did_capture = []
path = self._node._path
try:
yield did_capture
except CoordinateLookupError as exc:
raise ValidationError(exc.args[0])
except IndexError as exc:
# Can happen in IDSPath.goto when an invalid index is encountered.
coordinate_refs = coordinate.format_refs(self._node)
path = self._node._path
raise ValidationError(
f"Error while validating element `{path}`: dimension {dim + 1} has an "
f"invalid index for coordinate(s) {coordinate_refs}."
) from exc
except Exception as exc:
# Ignore all other exceptions and log them
if "Unexpected index" in str(exc):
logger.debug(
"Ignored AoS coordinate outside our tree (see IMAS-4675) of "
"element `%s`, dimension %s, coordinate `%s`",
path,
dim,
coordinate.references,
)
if logger.isEnabledFor(logging.DEBUG):
logger.debug(
"Ignored AoS coordinate outside our tree (see IMAS-4675) "
"of element `%s`, dimension %s, coordinate `%s`",
self._node._path,
dim,
coordinate.references,
)
else:
if self._node._version <= "3.38.1":
version_error = (
Expand All @@ -395,7 +396,7 @@ def _capture_goto_errors(self, dim, coordinate):
coordinate.references,
dim,
version_error,
exc_info=1,
exc_info=True,
)
# Flag to the caller that an error was suppressed
did_capture.append(1)
2 changes: 1 addition & 1 deletion imas/ids_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, parent: IDSBase, metadata: IDSMetadata):
def __getattr__(self, name):
if name not in self._children:
raise AttributeError(
f"IDS structure '{self._path}' has no attribute '{name}'"
f"IDS structure '{self.metadata.path_string}' has no attribute '{name}'"
)
# Create child node
child_meta = self._children[name]
Expand Down
2 changes: 1 addition & 1 deletion imas/test/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_hash_str1d(minimal):
"multiple entries to test!",
]
minimal.str_1d = string_list
hashes = list(map(xxh3_64_digest, string_list))
hashes = [xxh3_64_digest(s.encode("utf-8")) for s in string_list]
expected = xxh3_64_digest(struct.pack("<Q", len(string_list)) + b"".join(hashes))
assert expected == b"\x98\x011\x9dx+\x0e\xc0"
assert imas.util.calc_hash(minimal.str_1d) == expected
Expand Down
Loading