From b15250184c0b875fa838aaae7193de9059b7c2f4 Mon Sep 17 00:00:00 2001 From: Nicholas Devenish Date: Tue, 15 Aug 2023 12:16:48 +0100 Subject: [PATCH 1/4] Fix undefined behaviour from unthrown error (#656) Added in code review for 4783b2c, but without throw. --- newsfragments/656.bugfix | 1 + src/dxtbx/model/beam.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 newsfragments/656.bugfix diff --git a/newsfragments/656.bugfix b/newsfragments/656.bugfix new file mode 100644 index 000000000..6696aae3a --- /dev/null +++ b/newsfragments/656.bugfix @@ -0,0 +1 @@ +Fix situation where a bad ``Beam.probe`` could cause undefined behaviour. diff --git a/src/dxtbx/model/beam.h b/src/dxtbx/model/beam.h index 6df5325d1..7f9cefb37 100644 --- a/src/dxtbx/model/beam.h +++ b/src/dxtbx/model/beam.h @@ -319,7 +319,7 @@ namespace dxtbx { namespace model { case neutron: return std::string("neutron"); default: - DXTBX_ERROR("Unknown probe type"); + throw DXTBX_ERROR("Unknown probe type"); } } @@ -335,7 +335,7 @@ namespace dxtbx { namespace model { return Probe::neutron; } - DXTBX_ERROR("Unknown probe " + probe); + throw DXTBX_ERROR("Unknown probe " + probe); } void set_probe(Probe probe) { From 785eec165f26fa430ec14e8540c1d2dd6658bde3 Mon Sep 17 00:00:00 2001 From: James Beilsten-Edmands <30625594+jbeilstenedmands@users.noreply.github.com> Date: Thu, 24 Aug 2023 10:20:43 +0100 Subject: [PATCH 2/4] Fix pkg_resources->importlib performance regression (#658) Regression observed in large experiment lists with scaling/profile models. Only seems to affect Python 3.10, potentially stemming from: https://bugs.python.org/issue44246 Fixes #657 --- newsfragments/658.bugfix | 1 + src/dxtbx/model/experiment_list.py | 10 +++++++++- src/dxtbx/model/profile.py | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 newsfragments/658.bugfix diff --git a/newsfragments/658.bugfix b/newsfragments/658.bugfix new file mode 100644 index 000000000..f5cdda54d --- /dev/null +++ b/newsfragments/658.bugfix @@ -0,0 +1 @@ +Fix performance regression loading large experiment lists containing profile/scaling models. diff --git a/src/dxtbx/model/experiment_list.py b/src/dxtbx/model/experiment_list.py index ec836614f..92298851d 100644 --- a/src/dxtbx/model/experiment_list.py +++ b/src/dxtbx/model/experiment_list.py @@ -64,6 +64,14 @@ class InvalidExperimentListError(RuntimeError): """ +try: + scaling_model_entry_points = importlib.metadata.entry_points()[ + "dxtbx.scaling_model_ext" + ] +except KeyError: + scaling_model_entry_points = [] + + class ExperimentListDict: """A helper class for serializing the experiment list to dictionary (needed to save the experiment list to JSON format.""" @@ -465,7 +473,7 @@ def _lookup_model(self, name, experiment_dict): @staticmethod def _scaling_model_from_dict(obj): """Get the scaling model from a dictionary.""" - for entry_point in importlib.metadata.entry_points()["dxtbx.scaling_model_ext"]: + for entry_point in scaling_model_entry_points: if entry_point.name == obj["__id__"]: return entry_point.load().from_dict(obj) diff --git a/src/dxtbx/model/profile.py b/src/dxtbx/model/profile.py index ba3852586..20ead45f2 100644 --- a/src/dxtbx/model/profile.py +++ b/src/dxtbx/model/profile.py @@ -3,6 +3,11 @@ import importlib.metadata import logging +try: + profile_entry_points = importlib.metadata.entry_points()["dxtbx.profile_model"] +except KeyError: + profile_entry_points = [] + class ProfileModelFactory: """ @@ -16,7 +21,7 @@ def from_dict(obj): """ if obj is None: return None - for entry_point in importlib.metadata.entry_points()["dxtbx.profile_model"]: + for entry_point in profile_entry_points: if entry_point.name == obj["__id__"]: return entry_point.load().from_dict(obj) logging.getLogger("dxtbx.model.profile").warn( From 589d872af7eb60ecb8df1fbcb75ca2cc893569bf Mon Sep 17 00:00:00 2001 From: DiamondLightSource-build-server Date: Tue, 29 Aug 2023 04:45:59 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Bump=20version:=203.16.0=20=E2=86=92=203.16?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 42f48c05d..d14feddb5 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 3.16.0 +current_version = 3.16.1 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P[a-z]+)?(?P\d+)? diff --git a/setup.py b/setup.py index 8d6f78679..0f9cdb4fa 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ # Static version number which is updated by bump2version # Do not change this manually - use 'bump2version ' -__version_tag__ = "3.16.0" +__version_tag__ = "3.16.1" setup_kwargs = { "name": "dxtbx", From 61fa485eb06ced9124c0410c7b547062d7e099c0 Mon Sep 17 00:00:00 2001 From: DiamondLightSource-build-server Date: Tue, 29 Aug 2023 04:45:59 +0100 Subject: [PATCH 4/4] Towncrier for 3.16.1 towncrier --name "DIALS" --version 3.16.1 --- CHANGELOG.rst | 10 ++++++++++ newsfragments/656.bugfix | 1 - newsfragments/658.bugfix | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) delete mode 100644 newsfragments/656.bugfix delete mode 100644 newsfragments/658.bugfix diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6e5f63187..ea40d73ab 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,13 @@ +DIALS 3.16.1 (2023-08-29) +========================= + +Bugfixes +-------- + +- Fix situation where a bad ``Beam.probe`` could cause undefined behaviour. (`#656 `_) +- Fix performance regression loading large experiment lists containing profile/scaling models. (`#658 `_) + + dxtbx 3.16.0 (2023-08-14) ========================= diff --git a/newsfragments/656.bugfix b/newsfragments/656.bugfix deleted file mode 100644 index 6696aae3a..000000000 --- a/newsfragments/656.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix situation where a bad ``Beam.probe`` could cause undefined behaviour. diff --git a/newsfragments/658.bugfix b/newsfragments/658.bugfix deleted file mode 100644 index f5cdda54d..000000000 --- a/newsfragments/658.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix performance regression loading large experiment lists containing profile/scaling models.