From 0f8cf26880d41329730bf08c8e1ce43880401e79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 00:14:15 +0000 Subject: [PATCH 01/10] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-test.yml | 2 +- .github/workflows/clean-skops-user.yml | 2 +- .github/workflows/deploy-model-card-creator.yml | 2 +- .github/workflows/persistence-performance.yml | 2 +- .github/workflows/publish-pypi.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 38dd1f34..e2ee153c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -48,7 +48,7 @@ jobs: shell: bash - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} diff --git a/.github/workflows/clean-skops-user.yml b/.github/workflows/clean-skops-user.yml index 3480e1f8..c32ad9be 100644 --- a/.github/workflows/clean-skops-user.yml +++ b/.github/workflows/clean-skops-user.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 - name: Install Requirements run: pip install huggingface_hub - name: run cleanup diff --git a/.github/workflows/deploy-model-card-creator.yml b/.github/workflows/deploy-model-card-creator.yml index 3fb465ae..9758972b 100644 --- a/.github/workflows/deploy-model-card-creator.yml +++ b/.github/workflows/deploy-model-card-creator.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" diff --git a/.github/workflows/persistence-performance.yml b/.github/workflows/persistence-performance.yml index 52821194..d23d5dab 100644 --- a/.github/workflows/persistence-performance.yml +++ b/.github/workflows/persistence-performance.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" - name: Install requirements diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 55ff8c13..e6f388cb 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -25,7 +25,7 @@ jobs: with: ref: ${{ github.event.inputs.version }} - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.x' From 337b50f390726e9fb2fc2b7442dbacd0db571408 Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Mon, 11 Dec 2023 15:27:50 +0100 Subject: [PATCH 02/10] fix card tests --- skops/card/tests/test_card.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/skops/card/tests/test_card.py b/skops/card/tests/test_card.py index 6aba98b3..ebec9c7b 100644 --- a/skops/card/tests/test_card.py +++ b/skops/card/tests/test_card.py @@ -29,6 +29,8 @@ from skops.io import dump, load from skops.utils.importutils import import_or_raise +whitespaces = re.compile(r"\s+") + def fit_model(): X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]]) @@ -328,6 +330,11 @@ def _strip_multiple_chars(text, char): return text +def _strip_html_tag_whitespace(text): + # Utility function to remove whitespaces after html tags such as `
`. + return re.sub(re.compile(r"div>\s+"), "div>", text) + + class TestAddHyperparams: """Tests for the model hyperparameters""" @@ -1350,8 +1357,8 @@ def expected_lines(self): @pytest.mark.parametrize("meth", [repr, str]) def test_card_repr(self, card: Card, meth, expected_lines): - result = meth(card) - expected = "\n".join(expected_lines) + result = _strip_html_tag_whitespace(meth(card)) + expected = _strip_html_tag_whitespace("\n".join(expected_lines)) assert result == expected @pytest.mark.parametrize("meth", [repr, str]) @@ -1378,8 +1385,9 @@ def test_very_long_lines_are_shortened(self, card: Card, meth, expected_lines): ) expected_lines.insert(-1, extra_line) expected = "\n".join(expected_lines) + expected = _strip_html_tag_whitespace(expected) - result = meth(card) + result = _strip_html_tag_whitespace(meth(card)) assert result == expected @pytest.mark.parametrize("meth", [repr, str]) @@ -1389,8 +1397,9 @@ def test_without_model_attribute(self, card: Card, meth, expected_lines): # remove line 1 from expected results, which corresponds to the model del expected_lines[1] expected = "\n".join(expected_lines) + expected = _strip_html_tag_whitespace(expected) - result = meth(card) + result = _strip_html_tag_whitespace(meth(card)) assert result == expected @pytest.mark.parametrize("meth", [repr, str]) @@ -1415,8 +1424,9 @@ def test_with_metadata(self, card: Card, meth, expected_lines): " metadata.widget=[{...}],", ] expected = "\n".join(expected_lines[:2] + extra_lines + expected_lines[2:]) + expected = _strip_html_tag_whitespace(expected) - result = meth(card) + result = _strip_html_tag_whitespace(meth(card)) assert result == expected From 518a0c25547adadc7eb939b3ea32eb88a11b1f93 Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Mon, 11 Dec 2023 15:29:36 +0100 Subject: [PATCH 03/10] remove extra var --- skops/card/tests/test_card.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/skops/card/tests/test_card.py b/skops/card/tests/test_card.py index ebec9c7b..250dad00 100644 --- a/skops/card/tests/test_card.py +++ b/skops/card/tests/test_card.py @@ -29,8 +29,6 @@ from skops.io import dump, load from skops.utils.importutils import import_or_raise -whitespaces = re.compile(r"\s+") - def fit_model(): X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]]) From 5640785dc60b7f5b2bcffc7d4169bc9bad6e2b63 Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Mon, 11 Dec 2023 15:54:38 +0100 Subject: [PATCH 04/10] fix more tests --- skops/card/tests/test_card.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/skops/card/tests/test_card.py b/skops/card/tests/test_card.py index 250dad00..deec042e 100644 --- a/skops/card/tests/test_card.py +++ b/skops/card/tests/test_card.py @@ -30,6 +30,11 @@ from skops.utils.importutils import import_or_raise +def _strip_html_tag_whitespace(text): + # Utility function to remove whitespaces after html tags such as `
`. + return re.sub(re.compile(r"div>\s+"), "div>", text) + + def fit_model(): X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]]) y = np.dot(X, np.array([1, 2])) + 3 @@ -184,6 +189,7 @@ def test_default(self, model_card): result = model_card.select( "Model description/Training Procedure/Model Plot" ).format() + result = _strip_html_tag_whitespace(result) # don't compare whole text, as it's quite long and non-deterministic assert result.startswith("