From fda0f56aa9fdf125b8d5f32ca825d1e88d5cf5c1 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 01:23:28 -0500 Subject: [PATCH 01/31] simplify CI, WIP --- .github/workflows/ci.yml | 78 +++++++------------------------ .github/workflows/docs-deploy.yml | 2 +- .github/workflows/screenshots.yml | 2 +- CONTRIBUTING.md | 4 +- examples/tests/test_examples.py | 9 +++- setup.py | 21 +-------- 6 files changed, 30 insertions(+), 86 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0427b867f..92b100136 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,13 +22,9 @@ jobs: strategy: fail-fast: false matrix: - include: - - name: Test py311 - pyversion: '3.11' - - name: Test py312 - pyversion: '3.12' - - name: Test py313 - pyversion: '3.13' + python: ["3.11", "3.12", "3.13"] + imgui_dep: ["imgui,", ""] + notebook_dep: ["notebook,", ""] steps: - uses: actions/checkout@v4 with: @@ -47,7 +43,14 @@ jobs: # remove pygfx from install_requires, we install using pygfx@main sed -i "/pygfx/d" ./setup.py pip install git+https://github.com/pygfx/pygfx.git@main - pip install -e ".["tests"]" + - name: Install fastplotlib + run: | + # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests + # sed removes trailing comma + export DEPS=$(echo "tests${{ matrix.imgui_dep }}${{ matrix.notebook_dep }}" | sed 's/,*$//g) + echo ${{ env.DEPS }} + # install fastplotlib with given extras options from above + pip install -e ".["${{ env.DEPS }}"]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" @@ -61,68 +64,19 @@ jobs: run: | WGPU_FORCE_OFFSCREEN=1 pytest -v tests/ pytest -v examples - FASTPLOTLIB_NB_TESTS=1 pytest --nbmake examples/notebooks/ - - uses: actions/upload-artifact@v4 - if: ${{ failure() }} - with: - name: screenshot-diffs - path: | - examples/diffs - examples/notebooks/diffs - - test-build-offscreen: - name: Test Linux, only offscreen - runs-on: ubuntu-latest - timeout-minutes: 30 - if: ${{ !github.event.pull_request.draft }} - strategy: - fail-fast: false - matrix: - include: - - name: Test py311 - pyversion: '3.11' - - name: Test py312 - pyversion: '3.12' - - name: Test py313 - pyversion: '3.13' - steps: - - uses: actions/checkout@v4 - with: - lfs: true - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.pyversion }} - - name: Install llvmpipe and lavapipe for offscreen canvas - run: | - sudo apt-get update -y -qq - sudo apt-get install --no-install-recommends -y libegl1-mesa-dev libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers xorg-dev - - name: Install dev dependencies - run: | - python -m pip install --upgrade pip setuptools - # remove pygfx from install_requires, we install using pygfx@main - sed -i "/pygfx/d" ./setup.py - pip install git+https://github.com/pygfx/pygfx.git@main - pip install -e ".["tests-desktop"]" - - name: Show wgpu backend - run: - python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" - - name: fetch git lfs files - run: | - git lfs fetch --all - git lfs pull - - name: Test examples + - name: Test examples notebooks + if: ${{ matrix.notebook_dep == 'notebook' }} env: PYGFX_EXPECT_LAVAPIPE: true - run: | - WGPU_FORCE_OFFSCREEN=1 pytest -v tests/ - pytest -v examples + run: FASTPLOTLIB_NB_TESTS=1 pytest --nbmake examples/notebooks/ - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: name: screenshot-diffs path: | examples/diffs + examples/notebooks/diffs + # test-build-full-mac: # name: Test Mac, notebook + glfw diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index 63b0f81d7..fe267291a 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -42,7 +42,7 @@ jobs: # remove pygfx from install_requires, we install using pygfx@main sed -i "/pygfx/d" ./setup.py pip install git+https://github.com/pygfx/pygfx.git@main - pip install -e ".["docs"]" + pip install -e ".[docs,notebook,imgui]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index b8ac88d56..9fd9769c2 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -34,7 +34,7 @@ jobs: # remove pygfx from install_requires, we install using pygfx@main sed -i "/pygfx/d" ./setup.py pip install git+https://github.com/pygfx/pygfx.git@main - pip install -e ".["tests"]" + pip install -e ".["tests,notebook,imgui"]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6e1a5396c..bb786f9fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ cd fastplotlib ```bash # install all extras in place -pip install -e ".[notebook,docs,tests]" +pip install -e ".[imgui, notebook, docs, tests]" ``` 5. Add the upstream remote branch: @@ -280,7 +280,7 @@ to open source software packages. # after cloning cd fastplotlib # install dev dependencies -pip install -e ".[tests, docs, notebook]" +pip install -e ".[imgui, tests, docs, notebook]" ``` 3) Check out a feature branch from `main` diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index caa8e9dca..7770e232c 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -10,6 +10,7 @@ import numpy as np import imageio.v3 as iio import pygfx +import fastplotlib as fpl MAX_TEXTURE_SIZE = 2048 pygfx.renderers.wgpu.set_wgpu_limits(**{"max-texture-dimension-2d": MAX_TEXTURE_SIZE}) @@ -107,7 +108,13 @@ def test_example_screenshots(module, force_offscreen): if not os.path.exists(screenshots_dir): os.mkdir(screenshots_dir) - screenshot_path = screenshots_dir / f"{module.stem}.png" + # test screenshots for both imgui and non-gui installs + if not fpl.IMGUI: + prefix = "no-imgui-" + else: + prefix = "" + + screenshot_path = screenshots_dir / f"{prefix}{module.stem}.png" black = np.zeros(img.shape).astype(np.uint8) black[:, :, -1] = 255 diff --git a/setup.py b/setup.py index a1c74d5e5..af9c82e03 100644 --- a/setup.py +++ b/setup.py @@ -16,45 +16,28 @@ "sphinx-gallery", "pydata-sphinx-theme", "glfw", - "jupyter-rfb>=0.4.1", # required so ImageWidget docs show up "ipywidgets>=8.0.0,<9", "sphinx-copybutton", "sphinx-design", "pandoc", - "jupyterlab", - "sidecar", "imageio[ffmpeg]", "matplotlib", "scikit-learn", - "imgui-bundle", ], "notebook": [ "jupyterlab", - "jupyter-rfb>=0.4.1", + "jupyter-rfb>=0.5.0", "ipywidgets>=8.0.0,<9", "sidecar", ], "tests": [ - "pytest<8.0.0", + "pytest", "nbmake", "black", "scipy", "imageio[ffmpeg]", - "jupyterlab", - "jupyter-rfb>=0.4.1", - "ipywidgets>=8.0.0,<9", - "scikit-learn", - "tqdm", - "sidecar", - "imgui-bundle", - ], - "tests-desktop": [ - "pytest<8.0.0", - "scipy", - "imageio[ffmpeg]", "scikit-learn", "tqdm", - "imgui-bundle", ], "imgui": ["imgui-bundle"], } From 37d87db16f90c048090fbded23770d0739ff8f1a Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 01:30:25 -0500 Subject: [PATCH 02/31] tweak --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92b100136..cfc5437cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,10 +47,10 @@ jobs: run: | # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests # sed removes trailing comma - export DEPS=$(echo "tests${{ matrix.imgui_dep }}${{ matrix.notebook_dep }}" | sed 's/,*$//g) - echo ${{ env.DEPS }} + DEPS=$(echo "tests,${{ matrix.imgui_dep }}${{ matrix.notebook_dep }}" | sed 's/,*$//g) + echo ${{ DEPS }} # install fastplotlib with given extras options from above - pip install -e ".["${{ env.DEPS }}"]" + pip install -e ".["${{ DEPS }}"]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" From 909c8c0a4bc00ce82cb3aee8d63a5f4a8de31c34 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 01:39:24 -0500 Subject: [PATCH 03/31] jupyter rfb v0.5.0 not on pypi yet --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index af9c82e03..48c691046 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ ], "notebook": [ "jupyterlab", - "jupyter-rfb>=0.5.0", + "jupyter-rfb>=0.4.4", "ipywidgets>=8.0.0,<9", "sidecar", ], From 4daf5033e1ab456f58e3f71445bac9c7df6a2cb8 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 01:39:35 -0500 Subject: [PATCH 04/31] tweak --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfc5437cd..8642aad56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: run: | # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests # sed removes trailing comma - DEPS=$(echo "tests,${{ matrix.imgui_dep }}${{ matrix.notebook_dep }}" | sed 's/,*$//g) + export DEPS=$(echo "tests,${{ matrix.imgui_dep }}${{ matrix.notebook_dep }}" | sed 's/,*$//g) echo ${{ DEPS }} # install fastplotlib with given extras options from above pip install -e ".["${{ DEPS }}"]" From 8dd07db120286d938446ff245b461a61eae40947 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 01:44:01 -0500 Subject: [PATCH 05/31] twaek --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8642aad56..bd499ba4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,10 +47,10 @@ jobs: run: | # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests # sed removes trailing comma - export DEPS=$(echo "tests,${{ matrix.imgui_dep }}${{ matrix.notebook_dep }}" | sed 's/,*$//g) - echo ${{ DEPS }} + echo "DEPS=$(echo "tests,${{ matrix.imgui_dep }}${{ matrix.notebook_dep }}" | sed 's/,*$//g)" >> $GITHUB_ENV + echo ${{ env.DEPS }} # install fastplotlib with given extras options from above - pip install -e ".["${{ DEPS }}"]" + pip install -e ".["${{ env.DEPS }}"]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" From 4933a32cb68bfd98c4a4eca8cb060ed1ef3c6598 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 01:53:04 -0500 Subject: [PATCH 06/31] ok let's make this look ugly --- .github/workflows/ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd499ba4f..d3c2aab01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,8 @@ jobs: fail-fast: false matrix: python: ["3.11", "3.12", "3.13"] - imgui_dep: ["imgui,", ""] - notebook_dep: ["notebook,", ""] + imgui_dep: ["imgui", ""] + notebook_dep: ["notebook", ""] steps: - uses: actions/checkout@v4 with: @@ -47,10 +47,8 @@ jobs: run: | # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests # sed removes trailing comma - echo "DEPS=$(echo "tests,${{ matrix.imgui_dep }}${{ matrix.notebook_dep }}" | sed 's/,*$//g)" >> $GITHUB_ENV - echo ${{ env.DEPS }} # install fastplotlib with given extras options from above - pip install -e ".["${{ env.DEPS }}"]" + pip install -e ".[$(echo "tests,${{ matrix.imgui_dep }},${{ matrix.notebook_dep }}" | sed 's/,*$//g)]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" From 765e7948cc119ae95aa3b179d516b042ebfe3dac Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:00:57 -0500 Subject: [PATCH 07/31] typical bash and sed bleh --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3c2aab01..fcf2ec21c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,8 +47,9 @@ jobs: run: | # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests # sed removes trailing comma + DEPS=$(echo "tests,${{ matrix.imgui_dep }},${{ matrix.notebook_dep }}" | sed 's/,*$//g') # install fastplotlib with given extras options from above - pip install -e ".[$(echo "tests,${{ matrix.imgui_dep }},${{ matrix.notebook_dep }}" | sed 's/,*$//g)]" + pip install -e ".[${{ DEPS }}]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" From e22dd0aed30c647a9b78f3cf0398795e5d16877e Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:02:25 -0500 Subject: [PATCH 08/31] ok so github really likes it ugly --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcf2ec21c..59dcffded 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,9 +47,8 @@ jobs: run: | # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests # sed removes trailing comma - DEPS=$(echo "tests,${{ matrix.imgui_dep }},${{ matrix.notebook_dep }}" | sed 's/,*$//g') # install fastplotlib with given extras options from above - pip install -e ".[${{ DEPS }}]" + pip install -e ".[$(echo "tests,${{ matrix.imgui_dep }},${{ matrix.notebook_dep }}" | sed 's/,*$//g')]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" From e2428b2609c3aaa4a6477475c56d4831ade0fdb4 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:05:54 -0500 Subject: [PATCH 09/31] needs more sed --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59dcffded..d29de6396 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests # sed removes trailing comma # install fastplotlib with given extras options from above - pip install -e ".[$(echo "tests,${{ matrix.imgui_dep }},${{ matrix.notebook_dep }}" | sed 's/,*$//g')]" + pip install -e ".[$(echo "tests,${{ matrix.imgui_dep }},${{ matrix.notebook_dep }}" | sed -e "s/,\+/,/g" -e "s/,$//")]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" From 2e1002fc8ca3e294d0cff977e732bb2219ccba9a Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:10:11 -0500 Subject: [PATCH 10/31] see if core dump fixed --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d29de6396..eef7603de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: PYGFX_EXPECT_LAVAPIPE: true run: | WGPU_FORCE_OFFSCREEN=1 pytest -v tests/ - pytest -v examples + WGPU_FORCE_OFFSCREEN=1 pytest -v examples/ - name: Test examples notebooks if: ${{ matrix.notebook_dep == 'notebook' }} env: From 389c9113dcf72c591702f74df86696de75cfd866 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:22:31 -0500 Subject: [PATCH 11/31] imgui and no-imgui matrix for regen screenshots --- .github/workflows/screenshots.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 9fd9769c2..9dea4e4d3 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -16,6 +16,9 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 if: ${{ !github.event.pull_request.draft }} + strategy: + matrix: + imgui_dep: ["imgui", ""] steps: - uses: actions/checkout@v4 with: @@ -34,7 +37,12 @@ jobs: # remove pygfx from install_requires, we install using pygfx@main sed -i "/pygfx/d" ./setup.py pip install git+https://github.com/pygfx/pygfx.git@main - pip install -e ".["tests,notebook,imgui"]" + - name: Install fastplotlib + run: | + # create string with one of: tests,imgui,notebook; test,imgui; test,notebook ; tests + # sed removes trailing comma + # install fastplotlib with with or without imgui depending on build matrix + pip install -e ".[$(echo "tests,notebook,${{ matrix.imgui_dep }}" | sed -e "s/,\+/,/g" -e "s/,$//")]" - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" @@ -43,7 +51,7 @@ jobs: PYGFX_EXPECT_LAVAPIPE: true run: | # regenerate screenshots - REGENERATE_SCREENSHOTS=1 pytest -v examples + WGPU_FORCE_OFFSCREEN=1 REGENERATE_SCREENSHOTS=1 pytest -v examples FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake examples/notebooks/ - uses: actions/upload-artifact@v3 if: always() From c3b346f5896b7159d9496e3012c900179bcc8238 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:22:52 -0500 Subject: [PATCH 12/31] update test utils --- examples/notebooks/nb_test_utils.py | 21 ++++++++++++++++++--- examples/tests/test_examples.py | 17 +++++++++-------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/examples/notebooks/nb_test_utils.py b/examples/notebooks/nb_test_utils.py index 3d9e50d34..8d36bb1e8 100644 --- a/examples/notebooks/nb_test_utils.py +++ b/examples/notebooks/nb_test_utils.py @@ -105,11 +105,21 @@ def plot_test(name, fig: fpl.Figure): def regenerate_screenshot(name, data): - iio.imwrite(SCREENSHOTS_DIR.joinpath(f"nb-{name}.png"), data) + if fpl.IMGUI: + prefix = "imgui-" + else: + prefix = "" + + iio.imwrite(SCREENSHOTS_DIR.joinpath(f"{prefix}nb-{name}.png"), data) def assert_screenshot_equal(name, data): - ground_truth = iio.imread(SCREENSHOTS_DIR.joinpath(f"nb-{name}.png")) + if fpl.IMGUI: + prefix = "imgui-" + else: + prefix = "" + + ground_truth = iio.imread(SCREENSHOTS_DIR.joinpath(f"{prefix}nb-{name}.png")) img = normalize_image(data) ref_img = normalize_image(ground_truth) @@ -140,9 +150,14 @@ def get_diffs_rgba(slicer): diffs_rgba = diffs_rgba.astype("u1") return diffs_rgba[..., slicer] + if fpl.IMGUI: + prefix = "imgui-" + else: + prefix = "" + # split into an rgb and an alpha diff diffs = { - DIFFS_DIR.joinpath(f"nb-diff-{name}-rgb.png"): slice(0, 3), + DIFFS_DIR.joinpath(f"{prefix}nb-diff-{name}-rgb.png"): slice(0, 3), } for path, slicer in diffs.items(): diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index 7770e232c..b777c1918 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -79,12 +79,12 @@ def test_example_screenshots(module, force_offscreen): # import the example module example = import_from_path(module.stem, module) - # there doesn't seem to be a resize event for the manual offscreen canvas - example.figure.imgui_renderer._backend.io.display_size = example.figure.canvas.get_logical_size() - - # run this once so any edge widgets set their sizes and therefore the subplots get the correct rect - # hacky but it works for now - example.figure.imgui_renderer.render() + if fpl.IMGUI: + # there doesn't seem to be a resize event for the manual offscreen canvas + example.figure.imgui_renderer._backend.io.display_size = example.figure.canvas.get_logical_size() + # run this once so any edge widgets set their sizes and therefore the subplots get the correct rect + # hacky but it works for now + example.figure.imgui_renderer.render() # render each subplot for subplot in example.figure: @@ -95,8 +95,9 @@ def test_example_screenshots(module, force_offscreen): # flush pygfx renderer example.figure.renderer.flush() - # render imgui - example.figure.imgui_renderer.render() + if fpl.IMGUI: + # render imgui + example.figure.imgui_renderer.render() # render a frame img = np.asarray(example.figure.renderer.target.draw()) From b2d6c3beb94fd8eb820a2bcb4b0a6e93537eece1 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:41:01 -0500 Subject: [PATCH 13/31] account for imagewidget which needs imgui --- .github/workflows/ci.yml | 4 +++- examples/notebooks/nb_test_utils.py | 21 +++------------------ examples/tests/test_examples.py | 6 ++++++ 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eef7603de..9eef7069a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,9 @@ jobs: WGPU_FORCE_OFFSCREEN=1 pytest -v tests/ WGPU_FORCE_OFFSCREEN=1 pytest -v examples/ - name: Test examples notebooks - if: ${{ matrix.notebook_dep == 'notebook' }} + # test notebooks only if imgui is also installed, otherwise the ImageWidget + # notebook makes things too complicated to have this optional in CI + if: ${{ matrix.notebook_dep == 'notebook' && matrix.imgui_dep == 'imgui' }} env: PYGFX_EXPECT_LAVAPIPE: true run: FASTPLOTLIB_NB_TESTS=1 pytest --nbmake examples/notebooks/ diff --git a/examples/notebooks/nb_test_utils.py b/examples/notebooks/nb_test_utils.py index 8d36bb1e8..c2afa257d 100644 --- a/examples/notebooks/nb_test_utils.py +++ b/examples/notebooks/nb_test_utils.py @@ -105,21 +105,11 @@ def plot_test(name, fig: fpl.Figure): def regenerate_screenshot(name, data): - if fpl.IMGUI: - prefix = "imgui-" - else: - prefix = "" - - iio.imwrite(SCREENSHOTS_DIR.joinpath(f"{prefix}nb-{name}.png"), data) + iio.imwrite(SCREENSHOTS_DIR.joinpath(f"nb-{name}.png"), data) def assert_screenshot_equal(name, data): - if fpl.IMGUI: - prefix = "imgui-" - else: - prefix = "" - - ground_truth = iio.imread(SCREENSHOTS_DIR.joinpath(f"{prefix}nb-{name}.png")) + ground_truth = iio.imread(SCREENSHOTS_DIR.joinpath(f"nb-{name}.png")) img = normalize_image(data) ref_img = normalize_image(ground_truth) @@ -150,14 +140,9 @@ def get_diffs_rgba(slicer): diffs_rgba = diffs_rgba.astype("u1") return diffs_rgba[..., slicer] - if fpl.IMGUI: - prefix = "imgui-" - else: - prefix = "" - # split into an rgb and an alpha diff diffs = { - DIFFS_DIR.joinpath(f"{prefix}nb-diff-{name}-rgb.png"): slice(0, 3), + DIFFS_DIR.joinpath(f"nb-diff-{name}-rgb.png"): slice(0, 3), } for path, slicer in diffs.items(): diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index b777c1918..01ba0276d 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -85,6 +85,12 @@ def test_example_screenshots(module, force_offscreen): # run this once so any edge widgets set their sizes and therefore the subplots get the correct rect # hacky but it works for now example.figure.imgui_renderer.render() + else: + # skip any imgui or ImageWidget tests + skip = ["image_widget", "imgui"] + for s in skip: + if s in module.stem: + return # render each subplot for subplot in example.figure: From 157bdc72d3e414bf984d05fc5d8c82aa460e10b4 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:42:27 -0500 Subject: [PATCH 14/31] modify regen --- .github/workflows/screenshots.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 9dea4e4d3..a192ff300 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -46,13 +46,17 @@ jobs: - name: Show wgpu backend run: python -c "from examples.tests.testutils import wgpu_backend; print(wgpu_backend)" - - name: Test examples + - name: Generate screenshots env: PYGFX_EXPECT_LAVAPIPE: true run: | # regenerate screenshots WGPU_FORCE_OFFSCREEN=1 REGENERATE_SCREENSHOTS=1 pytest -v examples - FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake examples/notebooks/ + - name: Generate screenshots notebook + if: ${{ matrix.notebook_dep == 'notebook' && matrix.imgui_dep == 'imgui' }} + env: + PYGFX_EXPECT_LAVAPIPE: true + run: FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake examples/notebooks/ - uses: actions/upload-artifact@v3 if: always() with: From 5c4f0c525a3b69ad7ab81cbc25f006452db55d44 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 02:49:36 -0500 Subject: [PATCH 15/31] tweak --- .github/workflows/screenshots.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index a192ff300..9d6839fac 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -17,6 +17,7 @@ jobs: timeout-minutes: 10 if: ${{ !github.event.pull_request.draft }} strategy: + fail-fast: false matrix: imgui_dep: ["imgui", ""] steps: From 4e2494576e50bccdcf31ac2b8d62dbedb6f80919 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 03:22:39 -0500 Subject: [PATCH 16/31] skip imgui required tests when not installed --- examples/tests/test_examples.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index 01ba0276d..48ea62fcf 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -36,9 +36,21 @@ examples_to_test = find_examples(query="# test_example = true") +def check_skip_imgui(module): + # skip any imgui or ImageWidget tests + with open(module, "r") as f: + contents = f.read() + if "ImageWidget" in contents: + pytest.skip("skipping ImageWidget tests since they require imgui") + elif "imgui" in contents or "imgui_bundle" in contents: + pytest.skip("skipping tests that require imgui") + + @pytest.mark.parametrize("module", examples_to_run, ids=lambda x: x.stem) def test_examples_run(module, force_offscreen): """Run every example marked to see if they run without error.""" + if not fpl.IMGUI: + check_skip_imgui(module) runpy.run_path(module, run_name="__main__") @@ -87,10 +99,8 @@ def test_example_screenshots(module, force_offscreen): example.figure.imgui_renderer.render() else: # skip any imgui or ImageWidget tests - skip = ["image_widget", "imgui"] - for s in skip: - if s in module.stem: - return + if not fpl.IMGUI: + check_skip_imgui(module) # render each subplot for subplot in example.figure: From 64681508ce74a1bff3fd7c14b064d547cd6a3c6b Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 03:22:47 -0500 Subject: [PATCH 17/31] cleanup --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eef7069a..3e1602baf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,9 @@ on: jobs: test-build-full: - name: Test Linux, notebook + offscreen + name: Test Linux runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 10 if: ${{ !github.event.pull_request.draft }} strategy: fail-fast: false From 0facc8eda922519563e00456dff9f3d9ec570446 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 03:29:17 -0500 Subject: [PATCH 18/31] move check earlier --- examples/tests/test_examples.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index 48ea62fcf..67519187b 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -88,6 +88,11 @@ def import_from_path(module_name, filename): @pytest.mark.parametrize("module", examples_to_test, ids=lambda x: x.stem) def test_example_screenshots(module, force_offscreen): """Make sure that every example marked outputs the expected.""" + + if not fpl.IMGUI: + # skip any imgui or ImageWidget tests + check_skip_imgui(module) + # import the example module example = import_from_path(module.stem, module) @@ -97,10 +102,6 @@ def test_example_screenshots(module, force_offscreen): # run this once so any edge widgets set their sizes and therefore the subplots get the correct rect # hacky but it works for now example.figure.imgui_renderer.render() - else: - # skip any imgui or ImageWidget tests - if not fpl.IMGUI: - check_skip_imgui(module) # render each subplot for subplot in example.figure: From 0425217ccfcb9e3a5e0309216275be8e40120d3a Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 03:36:13 -0500 Subject: [PATCH 19/31] more informative artifact upload names --- .github/workflows/ci.yml | 2 +- .github/workflows/screenshots.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e1602baf..fef377462 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: - name: screenshot-diffs + name: screenshot-diffs-${{ matrix.pyversion }}-${{ matrix.imgui_dep }}-${{ matrix.notebook_dep }} path: | examples/diffs examples/notebooks/diffs diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 9d6839fac..0fd8e2ffc 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -61,7 +61,7 @@ jobs: - uses: actions/upload-artifact@v3 if: always() with: - name: screenshots + name: screenshots-${{ matrix.imgui }} path: | examples/screenshots/ examples/notebooks/screenshots/ From 80072aeeb0f16b9a881b02983d117aae42669e01 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 03:41:31 -0500 Subject: [PATCH 20/31] typo --- .github/workflows/screenshots.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 0fd8e2ffc..7a97d16e1 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -61,7 +61,7 @@ jobs: - uses: actions/upload-artifact@v3 if: always() with: - name: screenshots-${{ matrix.imgui }} + name: screenshots-${{ matrix.imgui_dep }} path: | examples/screenshots/ examples/notebooks/screenshots/ From 0caa458f6e2a96881a54c5dd7d0181a09be5b94a Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 03:48:38 -0500 Subject: [PATCH 21/31] use upload-artifact v4 --- .github/workflows/screenshots.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 7a97d16e1..9ed03748a 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -58,7 +58,7 @@ jobs: env: PYGFX_EXPECT_LAVAPIPE: true run: FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake examples/notebooks/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: name: screenshots-${{ matrix.imgui_dep }} From d3f99a1c3b8ee33da00ceabb3e07485e465fde69 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 03:56:09 -0500 Subject: [PATCH 22/31] add no imgui ground truth imageS --- examples/screenshots/no-imgui-gridplot.png | 3 +++ examples/screenshots/no-imgui-gridplot_non_square.png | 3 +++ examples/screenshots/no-imgui-heatmap.png | 3 +++ examples/screenshots/no-imgui-image_cmap.png | 3 +++ examples/screenshots/no-imgui-image_rgb.png | 3 +++ examples/screenshots/no-imgui-image_rgbvminvmax.png | 3 +++ examples/screenshots/no-imgui-image_simple.png | 3 +++ examples/screenshots/no-imgui-image_small.png | 3 +++ examples/screenshots/no-imgui-image_vminvmax.png | 3 +++ examples/screenshots/no-imgui-line.png | 3 +++ examples/screenshots/no-imgui-line_cmap.png | 3 +++ examples/screenshots/no-imgui-line_cmap_more.png | 3 +++ examples/screenshots/no-imgui-line_collection.png | 3 +++ examples/screenshots/no-imgui-line_collection_cmap_values.png | 3 +++ .../no-imgui-line_collection_cmap_values_qualitative.png | 3 +++ examples/screenshots/no-imgui-line_collection_colors.png | 3 +++ examples/screenshots/no-imgui-line_collection_slicing.png | 3 +++ examples/screenshots/no-imgui-line_colorslice.png | 3 +++ examples/screenshots/no-imgui-line_dataslice.png | 3 +++ examples/screenshots/no-imgui-line_stack.png | 3 +++ .../no-imgui-linear_region_selectors_match_offsets.png | 3 +++ examples/screenshots/no-imgui-scatter_cmap_iris.png | 3 +++ examples/screenshots/no-imgui-scatter_colorslice_iris.png | 3 +++ examples/screenshots/no-imgui-scatter_dataslice_iris.png | 3 +++ examples/screenshots/no-imgui-scatter_iris.png | 3 +++ examples/screenshots/no-imgui-scatter_size.png | 3 +++ 26 files changed, 78 insertions(+) create mode 100644 examples/screenshots/no-imgui-gridplot.png create mode 100644 examples/screenshots/no-imgui-gridplot_non_square.png create mode 100644 examples/screenshots/no-imgui-heatmap.png create mode 100644 examples/screenshots/no-imgui-image_cmap.png create mode 100644 examples/screenshots/no-imgui-image_rgb.png create mode 100644 examples/screenshots/no-imgui-image_rgbvminvmax.png create mode 100644 examples/screenshots/no-imgui-image_simple.png create mode 100644 examples/screenshots/no-imgui-image_small.png create mode 100644 examples/screenshots/no-imgui-image_vminvmax.png create mode 100644 examples/screenshots/no-imgui-line.png create mode 100644 examples/screenshots/no-imgui-line_cmap.png create mode 100644 examples/screenshots/no-imgui-line_cmap_more.png create mode 100644 examples/screenshots/no-imgui-line_collection.png create mode 100644 examples/screenshots/no-imgui-line_collection_cmap_values.png create mode 100644 examples/screenshots/no-imgui-line_collection_cmap_values_qualitative.png create mode 100644 examples/screenshots/no-imgui-line_collection_colors.png create mode 100644 examples/screenshots/no-imgui-line_collection_slicing.png create mode 100644 examples/screenshots/no-imgui-line_colorslice.png create mode 100644 examples/screenshots/no-imgui-line_dataslice.png create mode 100644 examples/screenshots/no-imgui-line_stack.png create mode 100644 examples/screenshots/no-imgui-linear_region_selectors_match_offsets.png create mode 100644 examples/screenshots/no-imgui-scatter_cmap_iris.png create mode 100644 examples/screenshots/no-imgui-scatter_colorslice_iris.png create mode 100644 examples/screenshots/no-imgui-scatter_dataslice_iris.png create mode 100644 examples/screenshots/no-imgui-scatter_iris.png create mode 100644 examples/screenshots/no-imgui-scatter_size.png diff --git a/examples/screenshots/no-imgui-gridplot.png b/examples/screenshots/no-imgui-gridplot.png new file mode 100644 index 000000000..45571161d --- /dev/null +++ b/examples/screenshots/no-imgui-gridplot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a27ccf2230628980d16ab22a17df64504268da35a27cd1adb44102e64df033af +size 329247 diff --git a/examples/screenshots/no-imgui-gridplot_non_square.png b/examples/screenshots/no-imgui-gridplot_non_square.png new file mode 100644 index 000000000..f8c307c22 --- /dev/null +++ b/examples/screenshots/no-imgui-gridplot_non_square.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58f50c4fc1b00c9e78c840193d1e15d008b9fe1e7f2a3d8b90065be91e2178f5 +size 236474 diff --git a/examples/screenshots/no-imgui-heatmap.png b/examples/screenshots/no-imgui-heatmap.png new file mode 100644 index 000000000..3d1cf5ef2 --- /dev/null +++ b/examples/screenshots/no-imgui-heatmap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fac55efd9339b180b9e34d5cf244c473d6439e57e34f272c1a7e59183f1afa2 +size 98573 diff --git a/examples/screenshots/no-imgui-image_cmap.png b/examples/screenshots/no-imgui-image_cmap.png new file mode 100644 index 000000000..6c565ca2b --- /dev/null +++ b/examples/screenshots/no-imgui-image_cmap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82f7176a61e2c6953c22171bea561845bb79cb8179d76b20eef2b2cc475bbb23 +size 237327 diff --git a/examples/screenshots/no-imgui-image_rgb.png b/examples/screenshots/no-imgui-image_rgb.png new file mode 100644 index 000000000..355238724 --- /dev/null +++ b/examples/screenshots/no-imgui-image_rgb.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fce532d713d2c664eb3b676e0128060ebf17241387134812b490d3ad398d42c2 +size 269508 diff --git a/examples/screenshots/no-imgui-image_rgbvminvmax.png b/examples/screenshots/no-imgui-image_rgbvminvmax.png new file mode 100644 index 000000000..6282f2438 --- /dev/null +++ b/examples/screenshots/no-imgui-image_rgbvminvmax.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42e01469f0f7da37d3c1c90225bf7c03c44badd1f3612ac9bf88eaed5eeb6850 +size 50145 diff --git a/examples/screenshots/no-imgui-image_simple.png b/examples/screenshots/no-imgui-image_simple.png new file mode 100644 index 000000000..d00a166ce --- /dev/null +++ b/examples/screenshots/no-imgui-image_simple.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c8bb29f192617b9dde2490ce36c69bd8352b6ba5d068434bc53edaad91871356 +size 237960 diff --git a/examples/screenshots/no-imgui-image_small.png b/examples/screenshots/no-imgui-image_small.png new file mode 100644 index 000000000..aca14cd69 --- /dev/null +++ b/examples/screenshots/no-imgui-image_small.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1ea4bcf76158169bc06973457ea09997c13ecd4a91e6e634566beb31348ef68 +size 13194 diff --git a/examples/screenshots/no-imgui-image_vminvmax.png b/examples/screenshots/no-imgui-image_vminvmax.png new file mode 100644 index 000000000..6282f2438 --- /dev/null +++ b/examples/screenshots/no-imgui-image_vminvmax.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42e01469f0f7da37d3c1c90225bf7c03c44badd1f3612ac9bf88eaed5eeb6850 +size 50145 diff --git a/examples/screenshots/no-imgui-line.png b/examples/screenshots/no-imgui-line.png new file mode 100644 index 000000000..29610c612 --- /dev/null +++ b/examples/screenshots/no-imgui-line.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:709458b03d535bcf407fdae1720ccdcd11a5f79ccf673e85c7e64c5748f6d25e +size 173422 diff --git a/examples/screenshots/no-imgui-line_cmap.png b/examples/screenshots/no-imgui-line_cmap.png new file mode 100644 index 000000000..9340e191e --- /dev/null +++ b/examples/screenshots/no-imgui-line_cmap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69426f5aac61e59a08764626b2aded602e576479e652d76b6b3bf646e3218cc1 +size 48028 diff --git a/examples/screenshots/no-imgui-line_cmap_more.png b/examples/screenshots/no-imgui-line_cmap_more.png new file mode 100644 index 000000000..f0cea4ec1 --- /dev/null +++ b/examples/screenshots/no-imgui-line_cmap_more.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df9a2ef9d54b417e0387116eb6e6215c54b7c939867d0d62c768768baae27e5f +size 129510 diff --git a/examples/screenshots/no-imgui-line_collection.png b/examples/screenshots/no-imgui-line_collection.png new file mode 100644 index 000000000..ca74d3362 --- /dev/null +++ b/examples/screenshots/no-imgui-line_collection.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90f281301e8b23a22a5333e7b34316475907ac25ffc9a23b7395b7431c965343 +size 106518 diff --git a/examples/screenshots/no-imgui-line_collection_cmap_values.png b/examples/screenshots/no-imgui-line_collection_cmap_values.png new file mode 100644 index 000000000..df237aa1b --- /dev/null +++ b/examples/screenshots/no-imgui-line_collection_cmap_values.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f5a7257d121a15a8a35ca6e9c70de9d6fbb4977221c840dd34e25e67136f4ea +size 67209 diff --git a/examples/screenshots/no-imgui-line_collection_cmap_values_qualitative.png b/examples/screenshots/no-imgui-line_collection_cmap_values_qualitative.png new file mode 100644 index 000000000..0347f7361 --- /dev/null +++ b/examples/screenshots/no-imgui-line_collection_cmap_values_qualitative.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89a7bc62495e6454ee008e15f1504211777cc01e52f303c18f6068fd38ab3c12 +size 70090 diff --git a/examples/screenshots/no-imgui-line_collection_colors.png b/examples/screenshots/no-imgui-line_collection_colors.png new file mode 100644 index 000000000..dff4f83db --- /dev/null +++ b/examples/screenshots/no-imgui-line_collection_colors.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78b14e90e5ae1e185abb51d94ac9d99c1a4318b0ddf79c26a55e6061f22c0ed9 +size 60447 diff --git a/examples/screenshots/no-imgui-line_collection_slicing.png b/examples/screenshots/no-imgui-line_collection_slicing.png new file mode 100644 index 000000000..70c343361 --- /dev/null +++ b/examples/screenshots/no-imgui-line_collection_slicing.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d6b4090d3ae9e38256c9f04e17bf2499f0a35348552f62e9c8d8dc97c9e760a7 +size 132125 diff --git a/examples/screenshots/no-imgui-line_colorslice.png b/examples/screenshots/no-imgui-line_colorslice.png new file mode 100644 index 000000000..3befac6da --- /dev/null +++ b/examples/screenshots/no-imgui-line_colorslice.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f161ad7f351b56c988e1b27155e3963be5191dc09cbaa55615026d07df07334 +size 56338 diff --git a/examples/screenshots/no-imgui-line_dataslice.png b/examples/screenshots/no-imgui-line_dataslice.png new file mode 100644 index 000000000..957462d09 --- /dev/null +++ b/examples/screenshots/no-imgui-line_dataslice.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2f737e0afd8f57c7d621197d37fcf30199086f6c083ec0d3d8e5497965e6d12 +size 67938 diff --git a/examples/screenshots/no-imgui-line_stack.png b/examples/screenshots/no-imgui-line_stack.png new file mode 100644 index 000000000..26f4a3af8 --- /dev/null +++ b/examples/screenshots/no-imgui-line_stack.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4dd69dc4be7a2283ec11a8427a75a2ddfe4be0cdbbdaedef3dcbf5f567c11ea7 +size 130519 diff --git a/examples/screenshots/no-imgui-linear_region_selectors_match_offsets.png b/examples/screenshots/no-imgui-linear_region_selectors_match_offsets.png new file mode 100644 index 000000000..9871d65c1 --- /dev/null +++ b/examples/screenshots/no-imgui-linear_region_selectors_match_offsets.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:747b0915eeaf5985346e3b6807a550da53b516769d2517d7c2e0f189baefef91 +size 100604 diff --git a/examples/screenshots/no-imgui-scatter_cmap_iris.png b/examples/screenshots/no-imgui-scatter_cmap_iris.png new file mode 100644 index 000000000..35812357a --- /dev/null +++ b/examples/screenshots/no-imgui-scatter_cmap_iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:74438dc47ff3fc1391b6952a52c66160fece0545de4ad40c13d3d56b2e093257 +size 59951 diff --git a/examples/screenshots/no-imgui-scatter_colorslice_iris.png b/examples/screenshots/no-imgui-scatter_colorslice_iris.png new file mode 100644 index 000000000..61812c8d7 --- /dev/null +++ b/examples/screenshots/no-imgui-scatter_colorslice_iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a02a21459deeca379a69b30054bebcc3739553b9d377d25b953315094e714d1a +size 35763 diff --git a/examples/screenshots/no-imgui-scatter_dataslice_iris.png b/examples/screenshots/no-imgui-scatter_dataslice_iris.png new file mode 100644 index 000000000..9ef39785c --- /dev/null +++ b/examples/screenshots/no-imgui-scatter_dataslice_iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21ccf85a9242f6d7a724c38797688abd804d9a565e818b81ea0c8931aa05ca4e +size 38337 diff --git a/examples/screenshots/no-imgui-scatter_iris.png b/examples/screenshots/no-imgui-scatter_iris.png new file mode 100644 index 000000000..91dc29397 --- /dev/null +++ b/examples/screenshots/no-imgui-scatter_iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ec960574580af159f3502da09f1f34e841267985edb52b89baf034c1d49125e +size 37410 diff --git a/examples/screenshots/no-imgui-scatter_size.png b/examples/screenshots/no-imgui-scatter_size.png new file mode 100644 index 000000000..6fadfec4d --- /dev/null +++ b/examples/screenshots/no-imgui-scatter_size.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94b4b9d39f3d4ef2c46b6b4dd7f712ca612f31a7fc94ab5fad8015e48c637e91 +size 70290 From defcbc3d4d899b1396ae37848f1063540fae9f1d Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 04:31:40 -0500 Subject: [PATCH 23/31] increase jupyter_rfb version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 48c691046..befed8333 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ ], "notebook": [ "jupyterlab", - "jupyter-rfb>=0.4.4", + "jupyter-rfb>=0.5.1", "ipywidgets>=8.0.0,<9", "sidecar", ], From 65e99d79341c319640c0d3d8ad12ee2f61248b59 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 21:50:34 -0500 Subject: [PATCH 24/31] use bash find to exclude/include imagewidget nbs depending on imgui existance --- .github/workflows/ci.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fef377462..3a307de92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,13 +62,18 @@ jobs: run: | WGPU_FORCE_OFFSCREEN=1 pytest -v tests/ WGPU_FORCE_OFFSCREEN=1 pytest -v examples/ - - name: Test examples notebooks - # test notebooks only if imgui is also installed, otherwise the ImageWidget - # notebook makes things too complicated to have this optional in CI + - name: Test examples notebooks, exclude ImageWidget notebook + if: ${{ matrix.notebook_dep == 'notebook' }} + env: + PYGFX_EXPECT_LAVAPIPE: true + # test notebooks, exclude ImageWidget notebooks + run: FASTPLOTLIB_NB_TESTS=1 pytest --nbmake $(find ./examples/notebooks/ -maxdepth 1 -type f -name "*.ipynb" ! -name "image_widget*.ipynb" -print | xargs) + - name: Test ImageWidget notebooks + # test image widget notebooks only if imgui is installed if: ${{ matrix.notebook_dep == 'notebook' && matrix.imgui_dep == 'imgui' }} env: PYGFX_EXPECT_LAVAPIPE: true - run: FASTPLOTLIB_NB_TESTS=1 pytest --nbmake examples/notebooks/ + run: FASTPLOTLIB_NB_TESTS=1 pytest --nbmake $(find ./examples/notebooks/ -maxdepth 1 -type f -name "image_widget*.ipynb" -print | xargs) - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: From ad4143b69bda4d2df33cadfc6c78fd18462586db Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 21:58:00 -0500 Subject: [PATCH 25/31] test imagewidget gc in nbs only if imgui installed --- examples/notebooks/test_gc.ipynb | 70 +++++++++----------------------- 1 file changed, 20 insertions(+), 50 deletions(-) diff --git a/examples/notebooks/test_gc.ipynb b/examples/notebooks/test_gc.ipynb index 6a0130d8e..df08e7a2d 100644 --- a/examples/notebooks/test_gc.ipynb +++ b/examples/notebooks/test_gc.ipynb @@ -202,57 +202,27 @@ "metadata": {}, "outputs": [], "source": [ - "movies = [np.random.rand(100, 100, 100) for i in range(6)]\n", - "\n", - "iw = fpl.ImageWidget(movies)\n", - "\n", - "# add some events onto all the image graphics\n", - "for g in iw.managed_graphics:\n", - " for f in g._features:\n", - " g.add_event_handler(feature_changed_handler, f)\n", - "\n", - "iw.show()" - ] - }, - { - "cell_type": "markdown", - "id": "189bcd7a-40a2-4e84-abcf-c334e50f5544", - "metadata": {}, - "source": [ - "# Test that setting new data with different dims clears old ImageGraphics" + "if fpl.IMGUI:\n", + " # do image widget tests only if imgui is installed\n", + " movies = [np.random.rand(100, 100, 100) for i in range(6)]\n", + " \n", + " iw = fpl.ImageWidget(movies)\n", + " \n", + " # add some events onto all the image graphics\n", + " for g in iw.managed_graphics:\n", + " for f in g._features:\n", + " g.add_event_handler(feature_changed_handler, f)\n", + " \n", + " iw.show()\n", + " \n", + " old_graphics = [weakref.proxy(g) for g in iw.managed_graphics]\n", + " \n", + " # Test that setting new data with different dims clears old ImageGraphics\n", + " new_movies = [np.random.rand(100, 200, 200) for i in range(6)]\n", + " \n", + " iw.set_data(new_movies)\n", + " test_references(old_graphics)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7e855043-91c1-4f6c-bed3-b69cf4a87f84", - "metadata": {}, - "outputs": [], - "source": [ - "old_graphics = [weakref.proxy(g) for g in iw.managed_graphics]\n", - "\n", - "new_movies = [np.random.rand(100, 200, 200) for i in range(6)]\n", - "\n", - "iw.set_data(new_movies)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "59e3c193-5672-4a66-bdca-12f1dd675d32", - "metadata": {}, - "outputs": [], - "source": [ - "test_references(old_graphics)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ad3d2a24-88b3-4071-a49c-49667d5a7813", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From 8679d89c92c55114ad9efedb5556cae47454a4dc Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 22:43:24 -0500 Subject: [PATCH 26/31] regen screenshots nb with and w/o imgui --- .github/workflows/screenshots.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 9ed03748a..3c803a80e 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -53,11 +53,16 @@ jobs: run: | # regenerate screenshots WGPU_FORCE_OFFSCREEN=1 REGENERATE_SCREENSHOTS=1 pytest -v examples - - name: Generate screenshots notebook + - name: Generate screenshots notebook, exclude image widget + if: ${{ matrix.notebook_dep == 'notebook' }} + env: + PYGFX_EXPECT_LAVAPIPE: true + run: FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake $(find ./examples/notebooks/ -maxdepth 1 -type f -name "*.ipynb" ! -name "image_widget*.ipynb" -print | xargs) + - name: Generate screenshots notebook, include image widget if: ${{ matrix.notebook_dep == 'notebook' && matrix.imgui_dep == 'imgui' }} env: PYGFX_EXPECT_LAVAPIPE: true - run: FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake examples/notebooks/ + run: FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake $(find ./examples/notebooks/ -maxdepth 1 -type f -name "image_widget*.ipynb" -print | xargs) - uses: actions/upload-artifact@v4 if: always() with: From b295d12f3b4f103fdf171117f8a527866e032060 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 23:14:26 -0500 Subject: [PATCH 27/31] add nb back to regen matrix --- .github/workflows/screenshots.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 3c803a80e..be4ab5a66 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -20,6 +20,7 @@ jobs: fail-fast: false matrix: imgui_dep: ["imgui", ""] + notebook_dep: ["notebook", ""] steps: - uses: actions/checkout@v4 with: From cdc100cb6b12934123905d71651daebc23054cd1 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 23:24:09 -0500 Subject: [PATCH 28/31] we actually only need 2 variants of regen --- .github/workflows/screenshots.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index be4ab5a66..80bf95201 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -20,7 +20,6 @@ jobs: fail-fast: false matrix: imgui_dep: ["imgui", ""] - notebook_dep: ["notebook", ""] steps: - uses: actions/checkout@v4 with: @@ -55,12 +54,11 @@ jobs: # regenerate screenshots WGPU_FORCE_OFFSCREEN=1 REGENERATE_SCREENSHOTS=1 pytest -v examples - name: Generate screenshots notebook, exclude image widget - if: ${{ matrix.notebook_dep == 'notebook' }} env: PYGFX_EXPECT_LAVAPIPE: true run: FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake $(find ./examples/notebooks/ -maxdepth 1 -type f -name "*.ipynb" ! -name "image_widget*.ipynb" -print | xargs) - name: Generate screenshots notebook, include image widget - if: ${{ matrix.notebook_dep == 'notebook' && matrix.imgui_dep == 'imgui' }} + if: ${{ matrix.imgui_dep == 'imgui' }} env: PYGFX_EXPECT_LAVAPIPE: true run: FASTPLOTLIB_NB_TESTS=1 REGENERATE_SCREENSHOTS=1 pytest --nbmake $(find ./examples/notebooks/ -maxdepth 1 -type f -name "image_widget*.ipynb" -print | xargs) From e27e3f37092a01fe810739691d7be2dbe7e106f3 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 23:40:47 -0500 Subject: [PATCH 29/31] prefix no-imgui for nb screenshots --- examples/notebooks/nb_test_utils.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/notebooks/nb_test_utils.py b/examples/notebooks/nb_test_utils.py index c2afa257d..fc74f5875 100644 --- a/examples/notebooks/nb_test_utils.py +++ b/examples/notebooks/nb_test_utils.py @@ -105,11 +105,21 @@ def plot_test(name, fig: fpl.Figure): def regenerate_screenshot(name, data): - iio.imwrite(SCREENSHOTS_DIR.joinpath(f"nb-{name}.png"), data) + if fpl.IMGUI: + prefix = "" + else: + prefix = "no-imgui-" + + iio.imwrite(SCREENSHOTS_DIR.joinpath(f"{prefix}nb-{name}.png"), data) def assert_screenshot_equal(name, data): - ground_truth = iio.imread(SCREENSHOTS_DIR.joinpath(f"nb-{name}.png")) + if fpl.IMGUI: + prefix = "" + else: + prefix = "no-imgui-" + + ground_truth = iio.imread(SCREENSHOTS_DIR.joinpath(f"{prefix}nb-{name}.png")) img = normalize_image(data) ref_img = normalize_image(ground_truth) @@ -140,9 +150,14 @@ def get_diffs_rgba(slicer): diffs_rgba = diffs_rgba.astype("u1") return diffs_rgba[..., slicer] + if fpl.IMGUI: + prefix = "" + else: + prefix = "no-imgui-" + # split into an rgb and an alpha diff diffs = { - DIFFS_DIR.joinpath(f"nb-diff-{name}-rgb.png"): slice(0, 3), + DIFFS_DIR.joinpath(f"{prefix}nb-diff-{name}-rgb.png"): slice(0, 3), } for path, slicer in diffs.items(): From de96a23b268da419b86d23c7be376b693f296ad3 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 17 Jan 2025 23:50:29 -0500 Subject: [PATCH 30/31] add no-imgui-nb screenshots --- examples/notebooks/screenshots/no-imgui-nb-astronaut.png | 3 +++ examples/notebooks/screenshots/no-imgui-nb-astronaut_RGB.png | 3 +++ examples/notebooks/screenshots/no-imgui-nb-camera.png | 3 +++ examples/notebooks/screenshots/no-imgui-nb-lines-3d.png | 3 +++ examples/notebooks/screenshots/no-imgui-nb-lines-colors.png | 3 +++ examples/notebooks/screenshots/no-imgui-nb-lines-data.png | 3 +++ examples/notebooks/screenshots/no-imgui-nb-lines-underlay.png | 3 +++ examples/notebooks/screenshots/no-imgui-nb-lines.png | 3 +++ 8 files changed, 24 insertions(+) create mode 100644 examples/notebooks/screenshots/no-imgui-nb-astronaut.png create mode 100644 examples/notebooks/screenshots/no-imgui-nb-astronaut_RGB.png create mode 100644 examples/notebooks/screenshots/no-imgui-nb-camera.png create mode 100644 examples/notebooks/screenshots/no-imgui-nb-lines-3d.png create mode 100644 examples/notebooks/screenshots/no-imgui-nb-lines-colors.png create mode 100644 examples/notebooks/screenshots/no-imgui-nb-lines-data.png create mode 100644 examples/notebooks/screenshots/no-imgui-nb-lines-underlay.png create mode 100644 examples/notebooks/screenshots/no-imgui-nb-lines.png diff --git a/examples/notebooks/screenshots/no-imgui-nb-astronaut.png b/examples/notebooks/screenshots/no-imgui-nb-astronaut.png new file mode 100644 index 000000000..a1e524e2a --- /dev/null +++ b/examples/notebooks/screenshots/no-imgui-nb-astronaut.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:915f6c4695c932dc2aa467be750e58a0435fe86fe0e0fa5a52c6065e05ec3193 +size 85456 diff --git a/examples/notebooks/screenshots/no-imgui-nb-astronaut_RGB.png b/examples/notebooks/screenshots/no-imgui-nb-astronaut_RGB.png new file mode 100644 index 000000000..ec3208e01 --- /dev/null +++ b/examples/notebooks/screenshots/no-imgui-nb-astronaut_RGB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31cfa60229a4e297be507a8888e08d6950c2a7d4b323d34774c9462419272ada +size 84284 diff --git a/examples/notebooks/screenshots/no-imgui-nb-camera.png b/examples/notebooks/screenshots/no-imgui-nb-camera.png new file mode 100644 index 000000000..31b60d9c0 --- /dev/null +++ b/examples/notebooks/screenshots/no-imgui-nb-camera.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:800845fae18093945ed921237c8756b1afa31ee391fe679b03c57a67929e4ba9 +size 60087 diff --git a/examples/notebooks/screenshots/no-imgui-nb-lines-3d.png b/examples/notebooks/screenshots/no-imgui-nb-lines-3d.png new file mode 100644 index 000000000..35c777e6a --- /dev/null +++ b/examples/notebooks/screenshots/no-imgui-nb-lines-3d.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4253362c0908e0d983542be3691a3d94f27a0319fb9e7183315c77891dac140 +size 23232 diff --git a/examples/notebooks/screenshots/no-imgui-nb-lines-colors.png b/examples/notebooks/screenshots/no-imgui-nb-lines-colors.png new file mode 100644 index 000000000..b8e34aab3 --- /dev/null +++ b/examples/notebooks/screenshots/no-imgui-nb-lines-colors.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc95d6291d06ab64d142ba0048318caefa28b404bb4b31635df075dc651eaa08 +size 37276 diff --git a/examples/notebooks/screenshots/no-imgui-nb-lines-data.png b/examples/notebooks/screenshots/no-imgui-nb-lines-data.png new file mode 100644 index 000000000..8f58dbc6d --- /dev/null +++ b/examples/notebooks/screenshots/no-imgui-nb-lines-data.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8aa0b8303f0a69609198ea312800fc0eb98007c18d0ebc37672a9cf4f1cbaff +size 46780 diff --git a/examples/notebooks/screenshots/no-imgui-nb-lines-underlay.png b/examples/notebooks/screenshots/no-imgui-nb-lines-underlay.png new file mode 100644 index 000000000..b33cde5a6 --- /dev/null +++ b/examples/notebooks/screenshots/no-imgui-nb-lines-underlay.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:822410f43d48d12e70930b5b581bafe624ea72475d53ca0d98cdaa5649338c63 +size 51849 diff --git a/examples/notebooks/screenshots/no-imgui-nb-lines.png b/examples/notebooks/screenshots/no-imgui-nb-lines.png new file mode 100644 index 000000000..5d7e704ca --- /dev/null +++ b/examples/notebooks/screenshots/no-imgui-nb-lines.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e3ba744fcfa43df839fddce88f79fb8d7c5eafdd22f271e6b885e09b8891072 +size 31222 From 6482e275fefb842f440ea4ff5f25010671a0fd39 Mon Sep 17 00:00:00 2001 From: Kushal Kolar Date: Sat, 18 Jan 2025 07:08:42 -0500 Subject: [PATCH 31/31] python version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a307de92..097a23475 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.pyversion }} + python-version: ${{ matrix.python }} - name: Install llvmpipe and lavapipe for offscreen canvas run: | sudo apt-get update -y -qq pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy