Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add WebP artefacts #304

Merged
merged 2 commits into from
Dec 24, 2024
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Project specific
# ============================================================================

docs/_static/charts
docs/_static/charts/*.html
docs/api/autogen
docs/api/public

Expand Down
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ include docs/make.bat
include docs/robots.txt
include docs/_static/favicon.ico
recursive-include docs *.md *.py *.rst
recursive-include docs/_static/charts *.html *.webp
recursive-include docs/_static/charts *.webp
recursive-include docs/_static/css *.css
recursive-include docs/_static/img *.png *.webp *.svg *.gif *.jpg
recursive-include docs/_static/js *.js
recursive-include docs/_templates *.html
prune docs/_build
prune docs/_static/charts
prune docs/api/autogen
prune docs/api/public

Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ clean-all: clean-docs clean-build clean-pyc clean-cov clean-ci-caches clean-tox
.PHONY: clean-docs
clean-docs: ## remove documentation build artifacts
@echo "==> Removing documentation build artifacts..."
rm -fr docs/_build/ docs/_static/charts docs/api/autogen/ docs/api/public/
rm -fr docs/_build/ docs/api/autogen/ docs/api/public/
find . -wholename 'docs/_static/charts/*.html' -exec rm -fr {} +


.PHONY: clean-build
Expand Down
Binary file added docs/_static/charts/basic.webp
Binary file not shown.
Binary file added docs/_static/charts/basic_hist.webp
Binary file not shown.
Binary file added docs/_static/charts/lincoln_weather.webp
Binary file not shown.
Binary file not shown.
Binary file added docs/_static/charts/probly.webp
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ def reset_sys_argv() -> Generator[None]:

def compile_all_plotly_charts() -> None:
path_charts = PATH_DOCS / "_static/charts"
print(f"Writing image artefacts to {path_charts}...")
print(f"Writing image artifacts to {path_charts}...")
for example in ALL_EXAMPLES:
example.to_html(path=path_charts, minify_html=True)
example.to_webp(path=path_charts)
example.to_html(path_charts, minify_html=True)
example.to_webp(path_charts)

# Fix the end-of-file markers in the generated HTML files
from pre_commit_hooks.end_of_file_fixer import main as end_of_file_fixer
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Unreleased changes

### CI/CD

- Fix regressions tests by comparing against JSON artefacts instead of flaky JPEGs ({gh-pr}`299`)
- Fix regressions tests by comparing against JSON artifacts instead of flaky JPEGs ({gh-pr}`299`)

Thanks to {gh-user}`imprvhub` for their contributions to this release! 🚀

Expand Down Expand Up @@ -265,7 +265,7 @@ This release contains a number of improvements to the docs, API reference, CI/CD

### Documentation

- Use the `{raw} html :file: _static/charts/<PLOT-ID>.html` directive to load the interactive Plotly graphs in the generated Sphinx docs. The generated HTML artefacts only include a `<div>` wrapper block now and the plotly.min.js is now vendored and automatically loaded via the `html_js_files` Sphinx config ({gh-pr}`132`)
- Use the `{raw} html :file: _static/charts/<PLOT-ID>.html` directive to load the interactive Plotly graphs in the generated Sphinx docs. The generated HTML artifacts only include a `<div>` wrapper block now and the plotly.min.js is now vendored and automatically loaded via the `html_js_files` Sphinx config ({gh-pr}`132`)
- Small adjustments to the example plots in the documentation ({gh-pr}`132`)
- Reformat markdown files, removing all line breaks ({gh-pr}`132`)

Expand Down
2 changes: 1 addition & 1 deletion src/ridgeplot/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
from typing_extensions import Any, Literal, TypeIs, TypeVar

# Snippet used to generate and store the image artefacts:
# Snippet used to generate and store the image artifacts:
# >>> def save_fig(fig, name):
# ... height = 400
# ... width = 800
Expand Down
22 changes: 18 additions & 4 deletions tests/e2e/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
from ridgeplot_examples import ALL_EXAMPLES, Example
from ridgeplot_examples._base import round_fig_data

JSON_SIG_FIGS = 8

PATH_ROOT = Path(__file__).parents[2].resolve()
PATH_ARTIFACTS = PATH_ROOT / "tests/e2e/artifacts"
PATH_CHARTS = PATH_ROOT / "docs/_static/charts"


def test_paths_exist() -> None:
assert PATH_ROOT.name == "ridgeplot"
assert PATH_ARTIFACTS.is_dir()
assert PATH_CHARTS.is_dir()


@pytest.mark.parametrize("example", ALL_EXAMPLES, ids=lambda e: e.plot_id)
def test_examples_width_height_set(example: Example) -> None:
Expand All @@ -16,10 +28,6 @@ def test_examples_width_height_set(example: Example) -> None:
assert isinstance(example.fig.layout.height, int), msg


JSON_SIG_FIGS = 8
PATH_ARTIFACTS = Path(__file__).parent / "artifacts"


@pytest.mark.parametrize("example", ALL_EXAMPLES, ids=lambda e: e.plot_id)
def test_regressions(example: Example) -> None:
"""Verify that the rendered JPEG images match the current artifacts."""
Expand All @@ -46,6 +54,12 @@ def _update_all_artifacts() -> None:
# (Don't use JPEGs for regression tests because outputs
# will vary between Plotly versions and platforms)
example.to_jpeg(PATH_ARTIFACTS)
# Just to keep things in sync with the docs, we should also
# regenerate the WebP images used there. These are tracked
# by Git because some are used in the README (which needs
# to be rendered on GitHub), otherwise they would be in
# the .gitignore file (like the HTML artifacts).
example.to_webp(PATH_CHARTS)


if __name__ == "__main__":
Expand Down
Loading