diff --git a/RELEASE.md b/RELEASE.md index 9b70726658..3908db36d8 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -9,6 +9,7 @@ Please follow the established format: ## Bug fixes and other changes +- Add support for fastapi >= 0.100.0 (#1529) - Fix dataset factory patterns in Experiment Tracking. (#1588) # Release 6.6.1 diff --git a/package/features/steps/lower_requirements.txt b/package/features/steps/lower_requirements.txt index 317309a4c2..c8cf3c5225 100644 --- a/package/features/steps/lower_requirements.txt +++ b/package/features/steps/lower_requirements.txt @@ -1,5 +1,5 @@ ipython==7.0.0 -fastapi==0.73.0 +fastapi==0.100.0 fsspec==2021.4 aiofiles==22.1.0 uvicorn[standard]==0.22.0 diff --git a/package/kedro_viz/api/rest/responses.py b/package/kedro_viz/api/rest/responses.py index bb49e919cb..e7c6993fdb 100644 --- a/package/kedro_viz/api/rest/responses.py +++ b/package/kedro_viz/api/rest/responses.py @@ -2,7 +2,7 @@ # pylint: disable=missing-class-docstring,too-few-public-methods,invalid-name import abc import logging -from typing import Any, Dict, List, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union import fsspec import orjson @@ -10,7 +10,6 @@ from fastapi.encoders import jsonable_encoder from fastapi.responses import JSONResponse, ORJSONResponse from kedro.io.core import get_protocol_and_path -from pydantic import BaseModel from kedro_viz.api.rest.utils import get_package_version from kedro_viz.data_access import data_access_manager @@ -24,6 +23,16 @@ TranscodedDataNodeMetadata, ) +if TYPE_CHECKING: + from pydantic import BaseModel +else: + try: + # Triggered if pydantic v2 is installed + from pydantic.v1 import BaseModel + except ImportError: + # Triggered if pydantic v1 is installed + from pydantic import BaseModel + logger = logging.getLogger(__name__) _FSSPEC_PACKAGE_NAME = "fsspec" @@ -47,7 +56,7 @@ class BaseGraphNodeAPIResponse(BaseAPIResponse): type: str # If a node is a ModularPipeline node, this value will be None, hence Optional. - modular_pipelines: Optional[List[str]] + modular_pipelines: Optional[List[str]] = None class TaskNodeAPIResponse(BaseGraphNodeAPIResponse): @@ -81,9 +90,9 @@ class Config: class DataNodeAPIResponse(BaseGraphNodeAPIResponse): - layer: Optional[str] - dataset_type: Optional[str] - stats: Optional[Dict] + layer: Optional[str] = None + dataset_type: Optional[str] = None + stats: Optional[Dict] = None class Config: schema_extra = { @@ -108,12 +117,12 @@ class Config: class TaskNodeMetadataAPIResponse(BaseAPIResponse): - code: Optional[str] - filepath: Optional[str] - parameters: Optional[Dict] + code: Optional[str] = None + filepath: Optional[str] = None + parameters: Optional[Dict] = None inputs: List[str] outputs: List[str] - run_command: Optional[str] + run_command: Optional[str] = None class Config: schema_extra = { @@ -129,14 +138,14 @@ class Config: class DataNodeMetadataAPIResponse(BaseAPIResponse): - filepath: Optional[str] + filepath: Optional[str] = None type: str - plot: Optional[Dict] - image: Optional[str] - tracking_data: Optional[Dict] - run_command: Optional[str] - preview: Optional[Dict] - stats: Optional[Dict] + plot: Optional[Dict] = None + image: Optional[str] = None + tracking_data: Optional[Dict] = None + run_command: Optional[str] = None + preview: Optional[Dict] = None + stats: Optional[Dict] = None class Config: schema_extra = { @@ -152,8 +161,8 @@ class TranscodedDataNodeMetadataAPIReponse(BaseAPIResponse): filepath: str original_type: str transcoded_types: List[str] - run_command: Optional[str] - stats: Optional[Dict] + run_command: Optional[str] = None + stats: Optional[Dict] = None class ParametersNodeMetadataAPIResponse(BaseAPIResponse): @@ -199,7 +208,7 @@ class NamedEntityAPIResponse(BaseAPIResponse): """ id: str - name: Optional[str] + name: Optional[str] = None class ModularPipelineChildAPIResponse(BaseAPIResponse): diff --git a/package/requirements.txt b/package/requirements.txt index b3d2b9cd36..294f4ef325 100644 --- a/package/requirements.txt +++ b/package/requirements.txt @@ -1,9 +1,9 @@ packaging~=23.0 kedro>=0.17.5 ipython>=7.0.0, <9.0 -fastapi>=0.73.0, <0.96.0 -fsspec[s3]>=2021.4, <2024.1 -aiofiles>=22.1.0 +fastapi>=0.100.0,<0.102.0 +fsspec[s3]>=2021.4, <2024.1 +aiofiles==22.1.0 uvicorn[standard]~=0.22.0 watchgod~=0.8.2 plotly>=4.0 diff --git a/package/test_requirements.txt b/package/test_requirements.txt index e9b39a7950..52a1cabc1b 100644 --- a/package/test_requirements.txt +++ b/package/test_requirements.txt @@ -8,7 +8,7 @@ behave~=1.2 black~=23.3 boto3~=1.26 flake8~=5.0 -fastapi[all]>=0.73.0, <0.96.0 +fastapi[all]>=0.73.0, <0.104.0 isort~=5.11 matplotlib~=3.5 mypy~=1.0