From d749b02e49948809772e3afe25cbacfbbbdb5196 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Thu, 14 Nov 2024 16:50:02 +0000 Subject: [PATCH 1/5] Change how we detect tiled dataset for speed --- dkist/dataset/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dkist/dataset/utils.py b/dkist/dataset/utils.py index 6ab71090..ac3aa4b8 100644 --- a/dkist/dataset/utils.py +++ b/dkist/dataset/utils.py @@ -12,9 +12,9 @@ def dataset_info_str(ds_in): - # Check for an attribute that only appears on TiledDataset - # Not using isinstance to avoid circular import - is_tiled = hasattr(ds_in, "combined_headers") + # Import here to remove circular import + from dkist.dataset import TiledDataset + is_tiled = isinstance(ds_in, TiledDataset) dstype = type(ds_in).__name__ if is_tiled: tile_shape = ds_in.shape From 22d315c5c7589a6dcee238828b66312ae2489b9d Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Thu, 14 Nov 2024 16:56:16 +0000 Subject: [PATCH 2/5] Add a couple of repr benchmarks --- dkist/tests/test_benchmarks.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dkist/tests/test_benchmarks.py b/dkist/tests/test_benchmarks.py index 88f37108..f5f530e6 100644 --- a/dkist/tests/test_benchmarks.py +++ b/dkist/tests/test_benchmarks.py @@ -127,3 +127,13 @@ def test_slice_dataset(benchmark, large_visp_dataset): @benchmark def slice_dataset(dataset=large_visp_dataset, idx = np.s_[:2, 10:15, 0]): sliced = dataset[idx] + + +@pytest.mark.benchmark +def test_dataset_repr(benchmark, large_visp_dataset): + benchmark(repr, large_visp_dataset) + + +@pytest.mark.benchmark +def test_tileddataset_repr(benchmark, simple_tiled_dataset): + benchmark(repr, simple_tiled_dataset) From 518afb616704e33c08578a81489469ff25fe9444 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Thu, 14 Nov 2024 17:00:54 +0000 Subject: [PATCH 3/5] Add a performance improvement section to the changelog --- changelog/README.rst | 1 + pyproject.toml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/changelog/README.rst b/changelog/README.rst index 766d10d9..14d82bfb 100644 --- a/changelog/README.rst +++ b/changelog/README.rst @@ -21,6 +21,7 @@ Each file should be named like ``..rst``, where `` Date: Thu, 14 Nov 2024 17:01:53 +0000 Subject: [PATCH 4/5] Add changelog --- changelog/467.performance.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/467.performance.rst diff --git a/changelog/467.performance.rst b/changelog/467.performance.rst new file mode 100644 index 00000000..cae5f1e0 --- /dev/null +++ b/changelog/467.performance.rst @@ -0,0 +1 @@ +Improve the performance of the ``TiledDataset`` ``repr`` and ``str``. From 7dba062401445c72a93629a565916559bf73c39f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 10:39:05 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 29f5f012..79a421da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -177,4 +177,4 @@ write_to = "dkist/_version.py" [[tool.towncrier.type]] directory = "performance" name = "Performance Improvements" - showcontent = true \ No newline at end of file + showcontent = true