Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
Signed-off-by: huongg <[email protected]>
  • Loading branch information
Huongg committed May 20, 2024
2 parents d8a6032 + e909630 commit 6a88863
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 155 deletions.
2 changes: 2 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Please follow the established format:
- Enhance kedro-viz doc integration. (#1874)
- Fix Kedro-Viz waiting for valid Kedro project. (#1871)
- 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
2 changes: 1 addition & 1 deletion demo-project/src/demo_project/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ wheel>=0.35, <0.37
pillow~=9.0
matplotlib==3.5.0
pre-commit~=1.17
seaborn~=0.11.2
seaborn>=0.13.0
2 changes: 1 addition & 1 deletion demo-project/src/docker_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ kedro>=0.18.0
kedro-datasets[pandas.CSVDataset,pandas.ExcelDataset, pandas.ParquetDataset, plotly.PlotlyDataset, matplotlib.MatplotlibWriter]>=2.1.0
scikit-learn~=1.0
pillow~=9.0
seaborn~=0.11.2
seaborn>=0.13.0
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

intersphinx_mapping = {
"kedro": ("https://docs.kedro.org/en/stable/", None),
"kedro-datasets": ("https://docs.kedro.org/projects/kedro-datasets/en/kedro-datasets-1.7.1/", None),
"kedro-datasets": ("https://docs.kedro.org/projects/kedro-datasets/en/kedro-datasets-3.0.0/", None),
}

# -- Options for HTML output -------------------------------------------------
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
17 changes: 8 additions & 9 deletions src/components/ui/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import './button.scss';
/**
* Generic Kedro Button
*/
const Button = ({ children, dataTest, disabled, onClick, size, mode }) => (
const Button = ({
children,
dataTest = 'TestDefaultDataValue',
disabled = false,
onClick,
size = 'regular',
mode = 'primary',
}) => (
<span className="kedro button">
<button
className={classnames(
Expand All @@ -23,14 +30,6 @@ const Button = ({ children, dataTest, disabled, onClick, size, mode }) => (
</span>
);

Button.defaultProps = {
dataTest: 'TestDefaultDataValue',
disabled: false,
mode: 'primary',
onClick: null,
size: 'regular',
};

Button.propTypes = {
dataTest: PropTypes.string,
disabled: PropTypes.bool,
Expand Down
27 changes: 5 additions & 22 deletions src/components/ui/dropdown/dropdown-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ import Button from '../button';
*/
const DropdownRenderer = ({
children,
defaultText,
disabled,
defaultText = 'Please select...',
disabled = false,
focusedOption,
handleRef,
haveSelectedValues,
haveSelectedValues = false,
onApplyAndClose,
onCancel,
onLabelClicked,
onOptionSelected,
onSelectChanged,
open,
open = false,
selectedOption,
showCancelApplyBtns,
title,
width,
width = 160,
placeholderText,
}) => {
const wrapperClasses = classnames('kedro', 'dropdown', {
Expand Down Expand Up @@ -169,23 +169,6 @@ const DropdownRenderer = ({
);
};

DropdownRenderer.defaultProps = {
children: null,
defaultText: 'Please select...',
disabled: false,
focusedOption: null,
handleRef: null,
haveSelectedValues: false,
onLabelClicked: null,
onOptionSelected: null,
onSelectChanged: null,
open: false,
selectedOption: null,
title: null,
width: 160,
placeholderText: null,
};

DropdownRenderer.propTypes = {
/**
* Child items. The nodes which React will pass down, defined inside the DropdownRenderer tag.
Expand Down
20 changes: 4 additions & 16 deletions src/components/ui/dropdown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import './dropdown.scss';
const Dropdown = (props) => {
const {
children,
defaultText,
disabled,
haveSelectedValues,
defaultText = 'Please select...',
disabled = false,
haveSelectedValues = false,
onApplyAndClose,
onCancel,
onChanged,
onClosed,
onOpened,
showCancelApplyBtns,
width,
width = 160,
placeholderText,
} = props;

Expand Down Expand Up @@ -333,18 +333,6 @@ const Dropdown = (props) => {
);
};

Dropdown.defaultProps = {
children: null,
defaultText: 'Please select...',
disabled: false,
haveSelectedValues: false,
onChanged: null,
onClosed: null,
onOpened: null,
width: 160,
placeholderText: null,
};

Dropdown.propTypes = {
/**
* Child items. The nodes which React will pass down, defined inside the DropdownRenderer tag
Expand Down
22 changes: 4 additions & 18 deletions src/components/ui/icon-button/icon-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const labelPositionTypes = ['right', 'left', 'bottom', 'top'];
* Icon button component
*/
const IconButton = ({
active,
active = false,
ariaLabel,
ariaLive,
children,
className,
container = 'li',
dataTest,
dataTest = 'TestDefaultDataValue',
dataHeapEvent,
disabled,
disabled = false,
icon,
labelText,
labelTextPosition = 'right',
onClick,
visible,
visible = true,
...rest
}) => {
const Icon = icon;
Expand Down Expand Up @@ -109,18 +109,4 @@ IconButton.propTypes = {
visible: PropTypes.bool,
};

IconButton.defaultProps = {
active: false,
ariaLabel: null,
ariaLive: null,
children: null,
dataTest: 'TestDefaultDataValue',
dataHeapEvent: null,
disabled: false,
icon: null,
labelText: null,
onClick: null,
visible: true,
};

export default IconButton;
13 changes: 2 additions & 11 deletions src/components/ui/menu-option/menu-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import './menu-option.scss';
*/
const MenuOption = ({
className,
focused,
focused = false,
id,
onSelected,
primaryText,
selected,
selected = false,
value,
}) => {
const wrapperClasses = classnames('kedro', 'menu-option', className, {
Expand Down Expand Up @@ -61,15 +61,6 @@ const MenuOption = ({
);
};

MenuOption.defaultProps = {
className: null,
focused: false,
id: null,
onSelected: null,
selected: false,
value: null,
};

MenuOption.propTypes = {
/**
* Container class
Expand Down
5 changes: 0 additions & 5 deletions src/components/ui/search-bar/search-bar-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ const SearchBarRenderer = (props) => {
);
};

SearchBarRenderer.defaultProps = {
children: null,
onSubmit: null,
};

SearchBarRenderer.propTypes = {
/**
* Child component, usually search-bar-results
Expand Down
16 changes: 2 additions & 14 deletions src/components/ui/search-bar/search-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const SearchBar = ({
onClear,
onFocus,
onSubmit,
placeholder,
theme,
placeholder = 'Search Here...',
theme = 'dark',
value: inputValue,
}) => {
const [value, setValue] = useState(inputValue);
Expand Down Expand Up @@ -115,18 +115,6 @@ const SearchBar = ({
);
};

SearchBar.defaultProps = {
children: null,
placeholder: 'Search Here...',
onBlur: null,
onChange: null,
onClear: null,
onFocus: null,
onSubmit: null,
theme: 'dark',
value: '',
};

SearchBar.propTypes = {
/**
* Child component, usually search-bar-results
Expand Down
Loading

0 comments on commit 6a88863

Please sign in to comment.