From 5020d13c90618c434761a7f8292b2a1987d056d6 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 17 Mar 2025 15:51:38 -0400 Subject: [PATCH 1/9] feat: add function --- .github/ISSUE_TEMPLATE/bug_report.yml | 44 +++++++++------------------ src/zarr/__init__.py | 17 +++++++++++ tests/test_zarr.py | 9 ++++++ 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 705cd31cb5..520725f095 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -6,36 +6,20 @@ body: attributes: value: | Please provide the following information. - - type: input - id: Zarr-version - attributes: - label: Zarr version - description: Value of ``zarr.__version__`` - placeholder: v2.10.2, v2.11.3, v2.12.0, etc. - validations: - required: true - - type: input - id: Numcodecs-version - attributes: - label: Numcodecs version - description: Value of ``numcodecs.__version__`` - placeholder: v0.8.1, v0.9.0, v0.10.0, etc. - validations: - required: true - - type: input - id: Python-version - attributes: - label: Python Version - description: Version of Python interpreter - placeholder: 3.10, 3.11, 3.12 etc. - validations: - required: true - - type: input - id: OS - attributes: - label: Operating System - description: Operating System - placeholder: (Linux/Windows/Mac) + - type: textarea + id: version-info + attributes: + label: Versions + description: Output of ``zarr.print_debug_info()`` + placeholder: | + platform: macOS-15.3-arm64-arm-64bit-Mach-O + python: 3.13.2 + + zarr: 3.0.5 + + numcodecs: 0.15.1 + numpy: 2.2.3 + fsspec: 2025.3.0 validations: required: true - type: input diff --git a/src/zarr/__init__.py b/src/zarr/__init__.py index 4ffa4c9bbc..e4db6cc6a2 100644 --- a/src/zarr/__init__.py +++ b/src/zarr/__init__.py @@ -36,6 +36,22 @@ # in case setuptools scm screw up and find version to be 0.0.0 assert not __version__.startswith("0.0.0") + +def print_debug_info() -> None: + import platform + from importlib import import_module + + print(f"platform: {platform.platform()}") + print(f"python: {platform.python_version()}\n") + + print(f"zarr: {__version__}\n") + for package in ["numcodecs", "numpy", "fsspec", "s3fs", "botocore", "gcsfs"]: + try: + print(f"{package}: {import_module(package).__version__}") + except ModuleNotFoundError: + continue + + __all__ = [ "Array", "AsyncArray", @@ -65,6 +81,7 @@ "open_consolidated", "open_group", "open_like", + "print_debug_info", "save", "save_array", "save_group", diff --git a/tests/test_zarr.py b/tests/test_zarr.py index 2aa62e4231..5243f7b785 100644 --- a/tests/test_zarr.py +++ b/tests/test_zarr.py @@ -9,3 +9,12 @@ def test_exports() -> None: for export in __all__: getattr(zarr, export) + + +def test_print_debug_info() -> None: + """ + Ensure that print_debug_info does not raise an error + """ + from zarr import print_debug_info + + print_debug_info() From 35ef9a83af799e980b3d7681803cb69c96284751 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 17 Mar 2025 16:34:06 -0400 Subject: [PATCH 2/9] doc: add docstring --- src/zarr/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/zarr/__init__.py b/src/zarr/__init__.py index e4db6cc6a2..d433db6ea5 100644 --- a/src/zarr/__init__.py +++ b/src/zarr/__init__.py @@ -38,6 +38,9 @@ def print_debug_info() -> None: + """ + Print version info for use in bug reports. + """ import platform from importlib import import_module From 35d0c86ce935642066623c8dfbbffac8adf80043 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 17 Mar 2025 16:34:33 -0400 Subject: [PATCH 3/9] doc: add change log for print_debug_info --- changes/2913.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/2913.feature.rst diff --git a/changes/2913.feature.rst b/changes/2913.feature.rst new file mode 100644 index 0000000000..e0bfcba791 --- /dev/null +++ b/changes/2913.feature.rst @@ -0,0 +1 @@ +Added a `print_debug_info` function for bug reports. From a0ac6b6d06564bd2e2052427509beb3a174fdddb Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 17 Mar 2025 16:50:26 -0400 Subject: [PATCH 4/9] Update .github/ISSUE_TEMPLATE/bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 520725f095..1593e44304 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -10,7 +10,8 @@ body: id: version-info attributes: label: Versions - description: Output of ``zarr.print_debug_info()`` + description: Output of ``zarr.print_debug_info()``. This will automatically be rendered as code, no need for backticks. + render: shell placeholder: | platform: macOS-15.3-arm64-arm-64bit-Mach-O python: 3.13.2 From 809c7a0b18b9781084dd19bed229444cab19e467 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 24 Mar 2025 16:13:26 -0400 Subject: [PATCH 5/9] feat: expand debug printout + better test --- src/zarr/__init__.py | 37 +++++++++++++++++++++++++++++++------ tests/test_zarr.py | 13 +++++++++++-- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/zarr/__init__.py b/src/zarr/__init__.py index d433db6ea5..a97a42e0bc 100644 --- a/src/zarr/__init__.py +++ b/src/zarr/__init__.py @@ -42,17 +42,42 @@ def print_debug_info() -> None: Print version info for use in bug reports. """ import platform - from importlib import import_module + from importlib.metadata import version + + def print_packages(packages: list[str]) -> None: + for package in packages: + try: + print(f"{package}: {version(package)}") + except ModuleNotFoundError: + continue + + required = [ + "packaging", + "numpy", + "numcodecs", + "typing_extensions", + "donfig", + ] + optional = [ + "botocore", + "cupy-cuda12x", + "fsspec", + "numcodecs", + "s3fs", + "gcsfs", + "universal-pathlib", + # "rich", # doesn't provide __version__ + "obstore", + ] print(f"platform: {platform.platform()}") print(f"python: {platform.python_version()}\n") print(f"zarr: {__version__}\n") - for package in ["numcodecs", "numpy", "fsspec", "s3fs", "botocore", "gcsfs"]: - try: - print(f"{package}: {import_module(package).__version__}") - except ModuleNotFoundError: - continue + print("Required dependencies:") + print_packages(required) + print("Optional dependencies:") + print_packages(optional) __all__ = [ diff --git a/tests/test_zarr.py b/tests/test_zarr.py index 5243f7b785..f54004344e 100644 --- a/tests/test_zarr.py +++ b/tests/test_zarr.py @@ -1,3 +1,5 @@ +import pytest + import zarr @@ -11,10 +13,17 @@ def test_exports() -> None: getattr(zarr, export) -def test_print_debug_info() -> None: +def test_print_debug_info(capsys: pytest.CaptureFixture[str]) -> None: """ Ensure that print_debug_info does not raise an error """ - from zarr import print_debug_info + from numpy import __version__ as np_v + + from zarr import __version__, print_debug_info print_debug_info() + captured = capsys.readouterr() + # test that at least some of what we expect is + # printed out + assert f"zarr: {__version__}" in captured.out + assert f"numpy: {np_v}" in captured.out From 2939e1677b0ae0be1533dea810eea70f7f7c49cb Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 24 Mar 2025 16:15:34 -0400 Subject: [PATCH 6/9] feat: debug - also print out rich --- src/zarr/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zarr/__init__.py b/src/zarr/__init__.py index a97a42e0bc..f76752109c 100644 --- a/src/zarr/__init__.py +++ b/src/zarr/__init__.py @@ -66,7 +66,7 @@ def print_packages(packages: list[str]) -> None: "s3fs", "gcsfs", "universal-pathlib", - # "rich", # doesn't provide __version__ + "rich", "obstore", ] From 6344c0b97d9c07a7503ad8364502d062f97ae834 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 24 Mar 2025 16:57:24 -0400 Subject: [PATCH 7/9] test: print debug test for upstream --- tests/test_zarr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_zarr.py b/tests/test_zarr.py index f54004344e..f49873132e 100644 --- a/tests/test_zarr.py +++ b/tests/test_zarr.py @@ -17,7 +17,7 @@ def test_print_debug_info(capsys: pytest.CaptureFixture[str]) -> None: """ Ensure that print_debug_info does not raise an error """ - from numpy import __version__ as np_v + from importlib.metadata import version from zarr import __version__, print_debug_info @@ -26,4 +26,4 @@ def test_print_debug_info(capsys: pytest.CaptureFixture[str]) -> None: # test that at least some of what we expect is # printed out assert f"zarr: {__version__}" in captured.out - assert f"numpy: {np_v}" in captured.out + assert f"numpy: {version('numpy')}" in captured.out From 2268275f5aa12cb8e12a30ac90a70af77a214086 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Fri, 28 Mar 2025 16:29:29 -0400 Subject: [PATCH 8/9] feat: better formatting for print_debug_info --- src/zarr/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/zarr/__init__.py b/src/zarr/__init__.py index f76752109c..3da13e9e3e 100644 --- a/src/zarr/__init__.py +++ b/src/zarr/__init__.py @@ -45,11 +45,16 @@ def print_debug_info() -> None: from importlib.metadata import version def print_packages(packages: list[str]) -> None: + not_installed = [] for package in packages: try: print(f"{package}: {version(package)}") except ModuleNotFoundError: - continue + not_installed.append(package) + if not_installed: + print("\n**Not Installed:**") + for package in not_installed: + print(package) required = [ "packaging", @@ -71,12 +76,11 @@ def print_packages(packages: list[str]) -> None: ] print(f"platform: {platform.platform()}") - print(f"python: {platform.python_version()}\n") - + print(f"python: {platform.python_version()}") print(f"zarr: {__version__}\n") - print("Required dependencies:") + print("**Required dependencies:**") print_packages(required) - print("Optional dependencies:") + print("\n**Optional dependencies:**") print_packages(optional) From 7df75ac88a000752a6419f43724b0aba13a2b68c Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 31 Mar 2025 10:50:05 -0400 Subject: [PATCH 9/9] restore original issue template --- .github/ISSUE_TEMPLATE/bug_report.yml | 45 ++++++++++++++++++--------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 1593e44304..705cd31cb5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -6,21 +6,36 @@ body: attributes: value: | Please provide the following information. - - type: textarea - id: version-info - attributes: - label: Versions - description: Output of ``zarr.print_debug_info()``. This will automatically be rendered as code, no need for backticks. - render: shell - placeholder: | - platform: macOS-15.3-arm64-arm-64bit-Mach-O - python: 3.13.2 - - zarr: 3.0.5 - - numcodecs: 0.15.1 - numpy: 2.2.3 - fsspec: 2025.3.0 + - type: input + id: Zarr-version + attributes: + label: Zarr version + description: Value of ``zarr.__version__`` + placeholder: v2.10.2, v2.11.3, v2.12.0, etc. + validations: + required: true + - type: input + id: Numcodecs-version + attributes: + label: Numcodecs version + description: Value of ``numcodecs.__version__`` + placeholder: v0.8.1, v0.9.0, v0.10.0, etc. + validations: + required: true + - type: input + id: Python-version + attributes: + label: Python Version + description: Version of Python interpreter + placeholder: 3.10, 3.11, 3.12 etc. + validations: + required: true + - type: input + id: OS + attributes: + label: Operating System + description: Operating System + placeholder: (Linux/Windows/Mac) validations: required: true - type: input