From 15ab3e860cc8c3e867733d850faa51adfc24b744 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Fri, 17 Jan 2025 01:18:03 +0700 Subject: [PATCH 01/12] set up rest for getversion Signed-off-by: Huong Nguyen --- .../kedro_viz/api/rest/responses/version.py | 39 +++++++++++++++++++ package/kedro_viz/api/rest/router.py | 12 ++++++ src/components/wrapper/wrapper.js | 28 +++++++++++-- src/utils/index.js | 10 +++++ 4 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 package/kedro_viz/api/rest/responses/version.py diff --git a/package/kedro_viz/api/rest/responses/version.py b/package/kedro_viz/api/rest/responses/version.py new file mode 100644 index 000000000..552b7902e --- /dev/null +++ b/package/kedro_viz/api/rest/responses/version.py @@ -0,0 +1,39 @@ +"""`kedro_viz.api.rest.responses.version` contains response classes +and utility functions for the `/version` REST endpoint""" + +from kedro_viz import __version__ +from pydantic import BaseModel, ConfigDict +from kedro_viz.api.rest.responses.base import BaseAPIResponse + +class VersionAPIResponse(BaseAPIResponse): + """ + VersionAPIResponse is a subclass of BaseAPIResponse that represents the response structure for version API. + + Attributes: + installed (str): The installed version of the Kedro Viz package. + isOutdated (bool): Whether the installed version is outdated. + latest (str): The latest available version of the Kedro Viz package. + """ + + installed: str + isOutdated: bool + latest: str + model_config = ConfigDict( + json_schema_extra={ + "installed": __version__, + "isOutdated": False, + "latest": "0.5.0" # how do i check the latest version? + } + ) + +def get_version_response(): + """API response for `/api/version`.""" + installed_version = __version__ + latest_version = "0.5.0" # how do i check the latest version? + is_outdated = installed_version != latest_version + + return VersionAPIResponse( + installed=installed_version, + isOutdated=is_outdated, + latest=latest_version + ) \ No newline at end of file diff --git a/package/kedro_viz/api/rest/router.py b/package/kedro_viz/api/rest/router.py index 2a743239f..349cca456 100644 --- a/package/kedro_viz/api/rest/router.py +++ b/package/kedro_viz/api/rest/router.py @@ -19,6 +19,10 @@ GraphAPIResponse, get_pipeline_response, ) +from kedro_viz.api.rest.responses.version import ( + VersionAPIResponse, + get_version_response, +) logger = logging.getLogger(__name__) @@ -49,6 +53,14 @@ async def get_single_node_metadata(node_id: str): async def get_single_pipeline_data(registered_pipeline_id: str): return get_pipeline_response(registered_pipeline_id) +@router.get( + "/version", + response_model=VersionAPIResponse, +) + +asyn def get_version(): + return get_version_response() + @router.post("/deploy") async def deploy_kedro_viz(input_values: DeployerConfiguration): diff --git a/src/components/wrapper/wrapper.js b/src/components/wrapper/wrapper.js index f37d7927f..cab4977d7 100644 --- a/src/components/wrapper/wrapper.js +++ b/src/components/wrapper/wrapper.js @@ -7,6 +7,7 @@ import { useApolloQuery } from '../../apollo/utils'; import { client } from '../../apollo/config'; import { GraphQLProvider } from '../provider/provider'; import { GET_VERSIONS } from '../../apollo/queries'; +import { getVersion } from '../../utils'; import FeatureHints from '../feature-hints'; import GlobalToolbar from '../global-toolbar'; @@ -29,11 +30,30 @@ export const Wrapper = ({ displayGlobalNavigation, theme }) => { const [latestVersion, setLatestVersion] = useState(null); useEffect(() => { - if (versionData) { - setIsOutdated(versionData.version.isOutdated); - setLatestVersion(versionData.version.latest); + async function checkKedroVizVersion() { + try { + debugger; + const request = await getVersion(); + const response = await request.json(); + + if (request.ok) { + setIsOutdated(response.isOutdated); + setLatestVersion(response.latest); + } + } catch (error) { + console.error('Error fetching Kedro-Viz version:', error); + } } - }, [versionData]); + + checkKedroVizVersion(); + }, []); + + // useEffect(() => { + // if (versionData) { + // setIsOutdated(versionData.version.isOutdated); + // setLatestVersion(versionData.version.latest); + // } + // }, [versionData]); return (
Date: Fri, 17 Jan 2025 16:13:58 +0700 Subject: [PATCH 02/12] include get_latest_version, is_running_outdated_version Signed-off-by: Huong Nguyen --- package/kedro_viz/api/rest/responses/version.py | 9 +++++---- package/kedro_viz/api/rest/router.py | 2 +- src/components/wrapper/wrapper.js | 7 ------- src/utils/index.js | 2 +- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/package/kedro_viz/api/rest/responses/version.py b/package/kedro_viz/api/rest/responses/version.py index 552b7902e..b165f0b40 100644 --- a/package/kedro_viz/api/rest/responses/version.py +++ b/package/kedro_viz/api/rest/responses/version.py @@ -2,7 +2,8 @@ and utility functions for the `/version` REST endpoint""" from kedro_viz import __version__ -from pydantic import BaseModel, ConfigDict +from kedro_viz.integrations.pypi import get_latest_version, is_running_outdated_version +from pydantic import ConfigDict from kedro_viz.api.rest.responses.base import BaseAPIResponse class VersionAPIResponse(BaseAPIResponse): @@ -22,15 +23,15 @@ class VersionAPIResponse(BaseAPIResponse): json_schema_extra={ "installed": __version__, "isOutdated": False, - "latest": "0.5.0" # how do i check the latest version? + "latest": "0.0.0" } ) def get_version_response(): """API response for `/api/version`.""" installed_version = __version__ - latest_version = "0.5.0" # how do i check the latest version? - is_outdated = installed_version != latest_version + latest_version = get_latest_version() + is_outdated = is_running_outdated_version(installed_version, latest_version) return VersionAPIResponse( installed=installed_version, diff --git a/package/kedro_viz/api/rest/router.py b/package/kedro_viz/api/rest/router.py index 349cca456..9c8965ab9 100644 --- a/package/kedro_viz/api/rest/router.py +++ b/package/kedro_viz/api/rest/router.py @@ -58,7 +58,7 @@ async def get_single_pipeline_data(registered_pipeline_id: str): response_model=VersionAPIResponse, ) -asyn def get_version(): +async def get_version(): return get_version_response() diff --git a/src/components/wrapper/wrapper.js b/src/components/wrapper/wrapper.js index cab4977d7..dccc353b8 100644 --- a/src/components/wrapper/wrapper.js +++ b/src/components/wrapper/wrapper.js @@ -48,13 +48,6 @@ export const Wrapper = ({ displayGlobalNavigation, theme }) => { checkKedroVizVersion(); }, []); - // useEffect(() => { - // if (versionData) { - // setIsOutdated(versionData.version.isOutdated); - // setLatestVersion(versionData.version.latest); - // } - // }, [versionData]); - return (
Date: Fri, 17 Jan 2025 17:14:01 +0700 Subject: [PATCH 03/12] fixing the error Signed-off-by: Huong Nguyen --- package/kedro_viz/api/rest/responses/version.py | 6 +++--- src/components/wrapper/wrapper.js | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package/kedro_viz/api/rest/responses/version.py b/package/kedro_viz/api/rest/responses/version.py index b165f0b40..8232707a1 100644 --- a/package/kedro_viz/api/rest/responses/version.py +++ b/package/kedro_viz/api/rest/responses/version.py @@ -29,12 +29,12 @@ class VersionAPIResponse(BaseAPIResponse): def get_version_response(): """API response for `/api/version`.""" - installed_version = __version__ - latest_version = get_latest_version() + installed_version = str(__version__) + latest_version = str(get_latest_version()) is_outdated = is_running_outdated_version(installed_version, latest_version) return VersionAPIResponse( installed=installed_version, isOutdated=is_outdated, - latest=latest_version + latest=latest_version, ) \ No newline at end of file diff --git a/src/components/wrapper/wrapper.js b/src/components/wrapper/wrapper.js index dccc353b8..c56e5e723 100644 --- a/src/components/wrapper/wrapper.js +++ b/src/components/wrapper/wrapper.js @@ -32,7 +32,6 @@ export const Wrapper = ({ displayGlobalNavigation, theme }) => { useEffect(() => { async function checkKedroVizVersion() { try { - debugger; const request = await getVersion(); const response = await request.json(); From 54f512cdea2660e18c0a7a8f690a28fb5718d723 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Fri, 17 Jan 2025 17:24:08 +0700 Subject: [PATCH 04/12] remove graphql Signed-off-by: Huong Nguyen --- package/kedro_viz/api/apps.py | 2 -- package/kedro_viz/api/graphql/__init__.py | 1 - package/kedro_viz/api/graphql/router.py | 18 ----------- package/kedro_viz/api/graphql/schema.py | 39 ----------------------- package/kedro_viz/api/graphql/types.py | 12 ------- 5 files changed, 72 deletions(-) delete mode 100644 package/kedro_viz/api/graphql/__init__.py delete mode 100644 package/kedro_viz/api/graphql/router.py delete mode 100644 package/kedro_viz/api/graphql/schema.py delete mode 100644 package/kedro_viz/api/graphql/types.py diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index 1f57a26b7..4628b94ef 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -18,7 +18,6 @@ from kedro_viz.api.rest.responses.utils import EnhancedORJSONResponse from kedro_viz.integrations.kedro import telemetry as kedro_telemetry -from .graphql.router import router as graphql_router from .rest.router import router as rest_router _HTML_DIR = Path(__file__).parent.parent.absolute() / "html" @@ -63,7 +62,6 @@ def create_api_app_from_project( """ app = _create_base_api_app() app.include_router(rest_router) - app.include_router(graphql_router) # Check for html directory existence. if Path(_HTML_DIR).is_dir(): diff --git a/package/kedro_viz/api/graphql/__init__.py b/package/kedro_viz/api/graphql/__init__.py deleted file mode 100644 index a7f4533f8..000000000 --- a/package/kedro_viz/api/graphql/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""`kedro_viz.api.graphql` defines the GraphQL API.""" diff --git a/package/kedro_viz/api/graphql/router.py b/package/kedro_viz/api/graphql/router.py deleted file mode 100644 index 803a5b752..000000000 --- a/package/kedro_viz/api/graphql/router.py +++ /dev/null @@ -1,18 +0,0 @@ -"""`kedro_viz.api.graphql.router` defines GraphQL routes.""" - -# mypy: ignore-errors -from fastapi import APIRouter -from strawberry.asgi import GraphQL - -from .schema import schema - -router = APIRouter() - -# graphiql=False can be removed if you wish to use the graphiql playground locally -graphql_app: GraphQL = GraphQL(schema, graphiql=False) -router.add_route("/graphql", graphql_app) -router.add_websocket_route("/graphql", graphql_app) - -# {subpath:path} is to handle urls with subpath e.g. demo.kedro.org/web -router.add_route("/{subpath:path}/graphql", graphql_app) -router.add_websocket_route("/{subpath:path}/graphql", graphql_app) diff --git a/package/kedro_viz/api/graphql/schema.py b/package/kedro_viz/api/graphql/schema.py deleted file mode 100644 index f2dc246fc..000000000 --- a/package/kedro_viz/api/graphql/schema.py +++ /dev/null @@ -1,39 +0,0 @@ -"""`kedro_viz.api.graphql.schema` defines the GraphQL schema: queries and mutations.""" - -from __future__ import annotations - -import logging - -import strawberry -from graphql.validation import NoSchemaIntrospectionCustomRule -from packaging.version import parse -from strawberry.extensions import AddValidationRules -from strawberry.tools import merge_types - -from kedro_viz import __version__ -from kedro_viz.integrations.pypi import get_latest_version, is_running_outdated_version - -from .types import Version - -logger = logging.getLogger(__name__) - - -@strawberry.type -class VersionQuery: - @strawberry.field(description="Get the installed and latest Kedro-Viz versions") - def version(self) -> Version: - installed_version = parse(__version__) - latest_version = get_latest_version() - return Version( - installed=str(installed_version), - is_outdated=is_running_outdated_version(installed_version, latest_version), - latest=str(latest_version) or "", - ) - - -schema = strawberry.Schema( - query=merge_types("Query", (VersionQuery,)), - extensions=[ - AddValidationRules([NoSchemaIntrospectionCustomRule]), - ], -) diff --git a/package/kedro_viz/api/graphql/types.py b/package/kedro_viz/api/graphql/types.py deleted file mode 100644 index 56fef78ff..000000000 --- a/package/kedro_viz/api/graphql/types.py +++ /dev/null @@ -1,12 +0,0 @@ -"""`kedro_viz.api.graphql.types` defines strawberry types.""" - -from __future__ import annotations - -import strawberry - - -@strawberry.type(description="Installed and latest Kedro-Viz versions") -class Version: - installed: str - is_outdated: bool - latest: str From 2aae1dc59a041d95c04da59b6c048974c309759c Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Fri, 17 Jan 2025 17:29:57 +0700 Subject: [PATCH 05/12] include test for getting version Signed-off-by: Huong Nguyen --- package/tests/test_api/test_rest/test_router.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/package/tests/test_api/test_rest/test_router.py b/package/tests/test_api/test_rest/test_router.py index 523043d96..6d29f3996 100644 --- a/package/tests/test_api/test_rest/test_router.py +++ b/package/tests/test_api/test_rest/test_router.py @@ -90,3 +90,16 @@ def test_metadata( mock_get_metadata_response.assert_called_once() assert response.status_code == expected_status_code assert response.json() == expected_response + +def test_version(client): + response = client.get("/api/version") + assert response.status_code == 200 + + json_response = response.json() + assert "installed" in json_response + assert "isOutdated" in json_response + assert "latest" in json_response + + assert isinstance(json_response["installed"], str) + assert isinstance(json_response["isOutdated"], bool) + assert isinstance(json_response["latest"], str) From 51045063a33a8cebb8081a457163b6c3a64bce6a Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Fri, 17 Jan 2025 17:30:09 +0700 Subject: [PATCH 06/12] remove check schema in lint Signed-off-by: Huong Nguyen --- .github/workflows/lint.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 02489d36d..b7945eb33 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,8 +38,5 @@ jobs: - name: Run security scan run: make security-scan - - name: Verify GraphQL schema is up to date - run: make schema-check - - name: Run Python formatters and linters run: make format-check lint-check From 00bce4b1e897d1f561785b45e199c85f5129fe2e Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Fri, 17 Jan 2025 17:38:50 +0700 Subject: [PATCH 07/12] fix lint format error Signed-off-by: Huong Nguyen --- .../kedro_viz/api/rest/responses/version.py | 19 +++++++++++-------- package/kedro_viz/api/rest/router.py | 2 +- .../tests/test_api/test_rest/test_router.py | 5 +++-- src/components/wrapper/wrapper.js | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) mode change 100644 => 100755 package/kedro_viz/api/rest/responses/version.py diff --git a/package/kedro_viz/api/rest/responses/version.py b/package/kedro_viz/api/rest/responses/version.py old mode 100644 new mode 100755 index 8232707a1..612ac3f5b --- a/package/kedro_viz/api/rest/responses/version.py +++ b/package/kedro_viz/api/rest/responses/version.py @@ -1,10 +1,12 @@ """`kedro_viz.api.rest.responses.version` contains response classes and utility functions for the `/version` REST endpoint""" -from kedro_viz import __version__ -from kedro_viz.integrations.pypi import get_latest_version, is_running_outdated_version from pydantic import ConfigDict + +from kedro_viz import __version__ from kedro_viz.api.rest.responses.base import BaseAPIResponse +from kedro_viz.integrations.pypi import get_latest_version, is_running_outdated_version + class VersionAPIResponse(BaseAPIResponse): """ @@ -12,21 +14,22 @@ class VersionAPIResponse(BaseAPIResponse): Attributes: installed (str): The installed version of the Kedro Viz package. - isOutdated (bool): Whether the installed version is outdated. + is_outdated (bool): Whether the installed version is outdated. latest (str): The latest available version of the Kedro Viz package. """ installed: str - isOutdated: bool + is_outdated: bool latest: str model_config = ConfigDict( json_schema_extra={ "installed": __version__, - "isOutdated": False, - "latest": "0.0.0" + "is_outdated": False, + "latest": "0.0.0", } ) + def get_version_response(): """API response for `/api/version`.""" installed_version = str(__version__) @@ -35,6 +38,6 @@ def get_version_response(): return VersionAPIResponse( installed=installed_version, - isOutdated=is_outdated, + is_outdated=is_outdated, latest=latest_version, - ) \ No newline at end of file + ) diff --git a/package/kedro_viz/api/rest/router.py b/package/kedro_viz/api/rest/router.py index 9c8965ab9..c1de2bce9 100644 --- a/package/kedro_viz/api/rest/router.py +++ b/package/kedro_viz/api/rest/router.py @@ -53,11 +53,11 @@ async def get_single_node_metadata(node_id: str): async def get_single_pipeline_data(registered_pipeline_id: str): return get_pipeline_response(registered_pipeline_id) + @router.get( "/version", response_model=VersionAPIResponse, ) - async def get_version(): return get_version_response() diff --git a/package/tests/test_api/test_rest/test_router.py b/package/tests/test_api/test_rest/test_router.py index 6d29f3996..033e2dc49 100644 --- a/package/tests/test_api/test_rest/test_router.py +++ b/package/tests/test_api/test_rest/test_router.py @@ -91,15 +91,16 @@ def test_metadata( assert response.status_code == expected_status_code assert response.json() == expected_response + def test_version(client): response = client.get("/api/version") assert response.status_code == 200 json_response = response.json() assert "installed" in json_response - assert "isOutdated" in json_response + assert "is_outdated " in json_response assert "latest" in json_response assert isinstance(json_response["installed"], str) - assert isinstance(json_response["isOutdated"], bool) + assert isinstance(json_response["is_outdated "], bool) assert isinstance(json_response["latest"], str) diff --git a/src/components/wrapper/wrapper.js b/src/components/wrapper/wrapper.js index c56e5e723..e04c5af2b 100644 --- a/src/components/wrapper/wrapper.js +++ b/src/components/wrapper/wrapper.js @@ -36,7 +36,7 @@ export const Wrapper = ({ displayGlobalNavigation, theme }) => { const response = await request.json(); if (request.ok) { - setIsOutdated(response.isOutdated); + setIsOutdated(response.is_outdated); setLatestVersion(response.latest); } } catch (error) { From 90feefeef2b0766f873db46ecc15b4c31d2bf36a Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Fri, 17 Jan 2025 17:44:49 +0700 Subject: [PATCH 08/12] remove test for graphql Signed-off-by: Huong Nguyen --- .../test_api/test_graphql/test_queries.py | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 package/tests/test_api/test_graphql/test_queries.py diff --git a/package/tests/test_api/test_graphql/test_queries.py b/package/tests/test_api/test_graphql/test_queries.py deleted file mode 100644 index 1bb0dea7d..000000000 --- a/package/tests/test_api/test_graphql/test_queries.py +++ /dev/null @@ -1,25 +0,0 @@ -import pytest -from packaging.version import parse - -from kedro_viz import __version__ - - -class TestQueryVersion: - def test_graphql_version_endpoint(self, client, mocker): - mocker.patch( - "kedro_viz.api.graphql.schema.get_latest_version", - return_value=parse("1.0.0"), - ) - response = client.post( - "/graphql", - json={"query": "{version {installed isOutdated latest}}"}, - ) - assert response.json() == { - "data": { - "version": { - "installed": __version__, - "isOutdated": False, - "latest": "1.0.0", - } - } - } From 44117eb4e1ba73e40c167e0eff10861db1ddebb0 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Fri, 17 Jan 2025 17:55:56 +0700 Subject: [PATCH 09/12] fix syntax error Signed-off-by: Huong Nguyen --- package/tests/test_api/test_rest/test_router.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/tests/test_api/test_rest/test_router.py b/package/tests/test_api/test_rest/test_router.py index 033e2dc49..4e4518261 100644 --- a/package/tests/test_api/test_rest/test_router.py +++ b/package/tests/test_api/test_rest/test_router.py @@ -98,9 +98,9 @@ def test_version(client): json_response = response.json() assert "installed" in json_response - assert "is_outdated " in json_response + assert "is_outdated" in json_response assert "latest" in json_response assert isinstance(json_response["installed"], str) - assert isinstance(json_response["is_outdated "], bool) + assert isinstance(json_response["is_outdated"], bool) assert isinstance(json_response["latest"], str) From f3e7b135c632ec395c75217ef68dceca71692c63 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Mon, 20 Jan 2025 16:23:17 +0700 Subject: [PATCH 10/12] remove apollo Signed-off-by: Huong Nguyen --- cypress/support/commands.js | 26 ---------- src/apollo/config.js | 77 ----------------------------- src/apollo/queries.js | 12 ----- src/apollo/schema.graphql | 11 ----- src/apollo/utils.js | 20 -------- src/components/provider/provider.js | 11 ----- src/components/wrapper/wrapper.js | 22 +++------ 7 files changed, 6 insertions(+), 173 deletions(-) delete mode 100644 src/apollo/config.js delete mode 100644 src/apollo/queries.js delete mode 100644 src/apollo/schema.graphql delete mode 100644 src/apollo/utils.js delete mode 100644 src/components/provider/provider.js diff --git a/cypress/support/commands.js b/cypress/support/commands.js index d57261b55..de8f12d13 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -1,32 +1,6 @@ // Add any reusable custom commands here import { join } from 'path'; -/** - * Custom command for intercepting network requests using fixtures for GraphQL - * @param {String} operationName - * @returns {Object} The mock/fixtured json response - */ -Cypress.Commands.add('__interceptGql__', (operationName, mutationFor) => { - // Assign an alias to the intercept based on the graphql request (mutation or query). - const interceptAlias = mutationFor ? mutationFor : operationName; - - cy.intercept('POST', '/graphql', (req) => { - const requestBody = req.body; - - // check for the operation name match in the graphql request body - if (requestBody?.operationName === operationName) { - // Assign a fixture path based on the graphql request (mutation or query). - const fixturePath = mutationFor - ? `graphql/${mutationFor}.json` - : `graphql/${operationName}.json`; - - // Stub the server response (request will never reach the origin server, instead the response is - // served from the fixture) - req.reply({ fixture: fixturePath }); - } - }).as(interceptAlias); -}); - /** * Custom command for intercepting network requests for REST * @param {String} url diff --git a/src/apollo/config.js b/src/apollo/config.js deleted file mode 100644 index 9d95d36c4..000000000 --- a/src/apollo/config.js +++ /dev/null @@ -1,77 +0,0 @@ -import fetch from 'cross-fetch'; -import { - ApolloClient, - InMemoryCache, - HttpLink, - ApolloLink, - Observable, -} from '@apollo/client'; -import { onError } from '@apollo/client/link/error'; -import loadJsonData from '../store/load-data'; - -const apiBaseUrl = `/graphql`; - -// HTTP link for GraphQL API calls -const httpLink = new HttpLink({ - uri: apiBaseUrl, - fetch, -}); - -// Error handling link -const errorLink = onError( - ({ graphQLErrors, networkError, operation, forward, response }) => { - if (networkError) { - console.error(`[Network error]: ${networkError}`); - - // Try reading from static file if network error occurs - return new Observable((observer) => { - (async () => { - const { operationName, variables } = operation; - let staticFilePath = `${apiBaseUrl}/${operationName}.json`; - - if (variables?.runIds) { - staticFilePath = `${apiBaseUrl}/${operationName}/${variables.runIds}.json`; - } - - try { - const staticData = await loadJsonData(staticFilePath, null); - if (staticData) { - observer.next({ data: staticData }); - observer.complete(); - } else { - observer.error(networkError); - } - } catch (error) { - observer.error(networkError); - } - })(); - }); - } - - if (graphQLErrors) { - graphQLErrors.forEach(({ message, locations, path }) => - console.error( - `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}` - ) - ); - } - } -); - -// Combine the links -const link = ApolloLink.from([errorLink, httpLink]); - -// Create the Apollo Client -export const client = new ApolloClient({ - connectToDevTools: true, - link, - cache: new InMemoryCache(), - defaultOptions: { - query: { - errorPolicy: 'all', - }, - mutate: { - errorPolicy: 'all', - }, - }, -}); diff --git a/src/apollo/queries.js b/src/apollo/queries.js deleted file mode 100644 index 138d8a3a4..000000000 --- a/src/apollo/queries.js +++ /dev/null @@ -1,12 +0,0 @@ -import gql from 'graphql-tag'; - -/** query for obtaining installed and latest Kedro-Viz versions */ -export const GET_VERSIONS = gql` - query getVersion { - version { - installed - isOutdated - latest - } - } -`; diff --git a/src/apollo/schema.graphql b/src/apollo/schema.graphql deleted file mode 100644 index 3aa405737..000000000 --- a/src/apollo/schema.graphql +++ /dev/null @@ -1,11 +0,0 @@ -type Query { - """Get the installed and latest Kedro-Viz versions""" - version: Version! -} - -"""Installed and latest Kedro-Viz versions""" -type Version { - installed: String! - isOutdated: Boolean! - latest: String! -} diff --git a/src/apollo/utils.js b/src/apollo/utils.js deleted file mode 100644 index 5236db08b..000000000 --- a/src/apollo/utils.js +++ /dev/null @@ -1,20 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useQuery } from '@apollo/client'; - -/** - * @param {Apollo query Object} query - * @param {Apollo query options Object} options - * @returns The data from the query, including error and loading states - */ -export const useApolloQuery = (query, options) => { - const [data, setData] = useState(undefined); - const { data: queryData, error, loading } = useQuery(query, options); - - useEffect(() => { - if (queryData !== undefined) { - setData(queryData); - } - }, [queryData]); - - return { data, error, loading }; -}; diff --git a/src/components/provider/provider.js b/src/components/provider/provider.js deleted file mode 100644 index b4de89980..000000000 --- a/src/components/provider/provider.js +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; -import { ApolloProvider } from '@apollo/client'; -import { client } from '../../apollo/config'; - -export const GraphQLProvider = ({ children }) => { - return ( - - <>{children} - - ); -}; diff --git a/src/components/wrapper/wrapper.js b/src/components/wrapper/wrapper.js index e04c5af2b..d7eb64fa3 100644 --- a/src/components/wrapper/wrapper.js +++ b/src/components/wrapper/wrapper.js @@ -3,12 +3,7 @@ import { connect } from 'react-redux'; import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'; import classnames from 'classnames'; import { isRunningLocally } from '../../utils'; -import { useApolloQuery } from '../../apollo/utils'; -import { client } from '../../apollo/config'; -import { GraphQLProvider } from '../provider/provider'; -import { GET_VERSIONS } from '../../apollo/queries'; import { getVersion } from '../../utils'; - import FeatureHints from '../feature-hints'; import GlobalToolbar from '../global-toolbar'; import FlowChartWrapper from '../flowchart-wrapper'; @@ -22,12 +17,9 @@ import './wrapper.scss'; * Main app container. Handles showing/hiding the sidebar nav, and theme classes. */ export const Wrapper = ({ displayGlobalNavigation, theme }) => { - const { data: versionData } = useApolloQuery(GET_VERSIONS, { - client, - skip: !displayGlobalNavigation || !isRunningLocally(), - }); const [isOutdated, setIsOutdated] = useState(false); const [latestVersion, setLatestVersion] = useState(null); + const [versions, setVersions] = useState(null); useEffect(() => { async function checkKedroVizVersion() { @@ -38,6 +30,7 @@ export const Wrapper = ({ displayGlobalNavigation, theme }) => { if (request.ok) { setIsOutdated(response.is_outdated); setLatestVersion(response.latest); + setVersions(response); } } catch (error) { console.error('Error fetching Kedro-Viz version:', error); @@ -57,18 +50,15 @@ export const Wrapper = ({ displayGlobalNavigation, theme }) => {

Kedro-Viz

{displayGlobalNavigation ? ( - + <> {isRunningLocally() ? : null} - {versionData && ( - + {versions && ( + )} @@ -76,7 +66,7 @@ export const Wrapper = ({ displayGlobalNavigation, theme }) => { - + ) : ( )} From 09306f4ee983a72ae791580ec6297f5654a94d10 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Mon, 20 Jan 2025 20:44:49 +0700 Subject: [PATCH 11/12] update libasound2 to libasound2t64 with the lates ubutun Signed-off-by: Huong Nguyen --- .github/workflows/javascript-lint-and-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/javascript-lint-and-tests.yml b/.github/workflows/javascript-lint-and-tests.yml index ca880da94..bb3f52b58 100644 --- a/.github/workflows/javascript-lint-and-tests.yml +++ b/.github/workflows/javascript-lint-and-tests.yml @@ -43,7 +43,7 @@ jobs: run: |- sudo sed -i 's/archive.ubuntu.com/us-east-1.ec2.archive.ubuntu.com/g' /etc/apt/sources.list sudo apt-get update - sudo apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb + sudo apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2t64 libxtst6 xauth xvfb - name: Test lib transpilation run: npm run lib From 55d98fc0794cfabb65d63a5fd319a2edd196dea4 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Mon, 20 Jan 2025 20:51:13 +0700 Subject: [PATCH 12/12] update libgconf-2-4 Signed-off-by: Huong Nguyen --- .github/workflows/javascript-lint-and-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/javascript-lint-and-tests.yml b/.github/workflows/javascript-lint-and-tests.yml index bb3f52b58..89d4a4a5b 100644 --- a/.github/workflows/javascript-lint-and-tests.yml +++ b/.github/workflows/javascript-lint-and-tests.yml @@ -43,7 +43,7 @@ jobs: run: |- sudo sed -i 's/archive.ubuntu.com/us-east-1.ec2.archive.ubuntu.com/g' /etc/apt/sources.list sudo apt-get update - sudo apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2t64 libxtst6 xauth xvfb + sudo apt-get install libgtk2.0-0t64 libgtk-3-0t64 libgbm-dev libnotify-dev libnss3 libxss1 libasound2t64 libxtst6 xauth xvfb - name: Test lib transpilation run: npm run lib