Skip to content

Commit

Permalink
Merge branch 'main' into warning-default-props
Browse files Browse the repository at this point in the history
  • Loading branch information
Huongg authored May 16, 2024
2 parents cfce1db + a8f57ad commit 55ce863
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 20 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Please follow the established format:
- Enhance Kedro-Viz documentation by using Kedro-sphinx-theme. (#1898)
- Remove default props from functional components. (#1906)
- Fix for schema change in strawberry-graphql JSON scalar. (#1903)
- Fix messaging level when package compatibility is not satisfied. (#1904)

# Release 9.0.0

Expand Down
9 changes: 5 additions & 4 deletions package/kedro_viz/api/rest/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,17 @@ def get_selected_pipeline_response(registered_pipeline_id: str):


def get_package_compatibilities_response(
package_requirements: Dict[str, str],
package_requirements: Dict[str, Dict[str, str]],
) -> List[PackageCompatibilityAPIResponse]:
"""API response for `/api/package_compatibility`."""
package_requirements_response = []

for package_name, compatible_version in package_requirements.items():
for package_name, package_info in package_requirements.items():
compatible_version = package_info["min_compatible_version"]
try:
package_version = get_package_version(package_name)
except PackageNotFoundError as exc:
logger.exception("Failed to get package version. Error: %s", str(exc))
except PackageNotFoundError:
logger.warning(package_info["warning_message"])
package_version = "0.0.0"

is_compatible = packaging.version.parse(
Expand Down
12 changes: 11 additions & 1 deletion package/kedro_viz/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@

SHAREABLEVIZ_SUPPORTED_PLATFORMS = ["aws", "azure", "gcp"]

PACKAGE_REQUIREMENTS = {"fsspec": "2023.9.0", "kedro-datasets": "2.1.0"}
PACKAGE_REQUIREMENTS = {
"fsspec": {
"min_compatible_version": "2023.9.0",
"warning_message": "Publish and share Kedro-Viz requires fsspec >= 2023.9.0",
},
"kedro-datasets": {
"min_compatible_version": "2.1.0",
"warning_message": "Experiment Tracking is exclusively supported "
"for users with kedro-datasets >= 2.1.0",
},
}
61 changes: 46 additions & 15 deletions package/tests/test_api/test_rest/test_responses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# pylint: disable=too-many-lines
import logging
import operator
from pathlib import Path
from typing import Any, Dict, Iterable, List
Expand All @@ -7,7 +8,6 @@

import pytest
from fastapi.testclient import TestClient
from importlib_metadata import PackageNotFoundError

from kedro_viz.api import apps
from kedro_viz.api.rest.responses import (
Expand Down Expand Up @@ -829,10 +829,30 @@ class TestPackageCompatibilities:
@pytest.mark.parametrize(
"package_name, package_version, package_requirements, expected_compatibility_response",
[
("fsspec", "2023.9.1", {"fsspec": "2023.0.0"}, True),
("fsspec", "2023.9.1", {"fsspec": "2024.0.0"}, False),
("kedro-datasets", "2.1.0", {"kedro-datasets": "2.1.0"}, True),
("kedro-datasets", "1.8.0", {"kedro-datasets": "2.1.0"}, False),
(
"fsspec",
"2023.9.1",
{"fsspec": {"min_compatible_version": "2023.0.0"}},
True,
),
(
"fsspec",
"2023.9.1",
{"fsspec": {"min_compatible_version": "2024.0.0"}},
False,
),
(
"kedro-datasets",
"2.1.0",
{"kedro-datasets": {"min_compatible_version": "2.1.0"}},
True,
),
(
"kedro-datasets",
"1.8.0",
{"kedro-datasets": {"min_compatible_version": "2.1.0"}},
False,
),
],
)
def test_get_package_compatibilities_response(
Expand All @@ -854,16 +874,27 @@ def test_get_package_compatibilities_response(
assert package_response.package_version == package_version
assert package_response.is_compatible is expected_compatibility_response

def test_get_package_compatibilities_exception_response(
self,
mocker,
):
mocker.patch(
"kedro_viz.api.rest.responses.get_package_compatibilities_response",
side_effect=PackageNotFoundError("random-package"),
)
package_name = "random-package"
response = get_package_compatibilities_response({package_name: "1.0.0"})
def test_get_package_compatibilities_exception_response(self, caplog):
mock_package_requirement = {
"random-package": {
"min_compatible_version": "1.0.0",
"warning_message": "random-package is not available",
}
}

with caplog.at_level(logging.WARNING):
response = get_package_compatibilities_response(mock_package_requirement)

assert len(caplog.records) == 1

record = caplog.records[0]

assert record.levelname == "WARNING"
assert (
mock_package_requirement["random-package"]["warning_message"]
in record.message
)

expected_response = PackageCompatibilityAPIResponse(
package_name="random-package", package_version="0.0.0", is_compatible=False
)
Expand Down

0 comments on commit 55ce863

Please sign in to comment.