From ba7f1b5055adde17fd002767ec807e217a447557 Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 10:05:37 +0100 Subject: [PATCH 01/18] Fix: Adding favicon to Kedro Demo --- package/kedro_viz/api/apps.py | 3 +++ public/index.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index a9bb5d97b4..88e9d132b7 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -68,6 +68,9 @@ def create_api_app_from_project( # frontend e2e tests via Cypress app.mount("/static", StaticFiles(directory=_HTML_DIR / "static"), name="static") + # Mount the public directory for serving image files + app.mount("/images", StaticFiles(directory=_HTML_DIR), name="images") + # everytime the server reloads, a new app with a new timestamp will be created. # this is used as an etag embedded in the frontend for client to use when making requests. app_etag = _create_etag() diff --git a/public/index.html b/public/index.html index d9e92d68c6..d977c3e017 100644 --- a/public/index.html +++ b/public/index.html @@ -7,7 +7,7 @@ content="width=device-width, initial-scale=1, shrink-to-fit=no" /> - + Kedro-Viz Date: Wed, 30 Aug 2023 12:57:39 +0100 Subject: [PATCH 02/18] Fix: Change in approach for serving favicon --- package/kedro_viz/api/apps.py | 10 ++++++---- public/index.html | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index 88e9d132b7..780590cc42 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -8,7 +8,7 @@ import secure from fastapi import FastAPI, HTTPException from fastapi.requests import Request -from fastapi.responses import HTMLResponse, JSONResponse, Response +from fastapi.responses import HTMLResponse, JSONResponse, Response, FileResponse from fastapi.staticfiles import StaticFiles from jinja2 import Environment, FileSystemLoader @@ -68,13 +68,15 @@ def create_api_app_from_project( # frontend e2e tests via Cypress app.mount("/static", StaticFiles(directory=_HTML_DIR / "static"), name="static") - # Mount the public directory for serving image files - app.mount("/images", StaticFiles(directory=_HTML_DIR), name="images") - # everytime the server reloads, a new app with a new timestamp will be created. # this is used as an etag embedded in the frontend for client to use when making requests. app_etag = _create_etag() + # Serve the favicon.ico file from the "html" directory + @app.get('/favicon.ico', include_in_schema=False) + async def favicon(): + return FileResponse(_HTML_DIR / "favicon.ico") + @app.get("/") @app.get("/experiment-tracking") async def index(): diff --git a/public/index.html b/public/index.html index d977c3e017..d9e92d68c6 100644 --- a/public/index.html +++ b/public/index.html @@ -7,7 +7,7 @@ content="width=device-width, initial-scale=1, shrink-to-fit=no" /> - + Kedro-Viz Date: Wed, 30 Aug 2023 13:18:28 +0100 Subject: [PATCH 03/18] Lint error fix --- package/kedro_viz/api/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index 780590cc42..04a185b6d3 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -8,7 +8,7 @@ import secure from fastapi import FastAPI, HTTPException from fastapi.requests import Request -from fastapi.responses import HTMLResponse, JSONResponse, Response, FileResponse +from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, Response from fastapi.staticfiles import StaticFiles from jinja2 import Environment, FileSystemLoader From af086af2e5003e9916124d0b76d139432cdd96fb Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 16:06:20 +0100 Subject: [PATCH 04/18] Lint error fix --- package/kedro_viz/api/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index 04a185b6d3..e55c857f27 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -73,7 +73,7 @@ def create_api_app_from_project( app_etag = _create_etag() # Serve the favicon.ico file from the "html" directory - @app.get('/favicon.ico', include_in_schema=False) + @app.get("/favicon.ico", include_in_schema=False) async def favicon(): return FileResponse(_HTML_DIR / "favicon.ico") From a5861491225335bb6e7c3ff04748cc8bb06a70ee Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 16:54:59 +0100 Subject: [PATCH 05/18] Favicon endpoint test added --- package/tests/test_api/test_apps.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package/tests/test_api/test_apps.py b/package/tests/test_api/test_apps.py index 5174dbe22e..64b3305680 100644 --- a/package/tests/test_api/test_apps.py +++ b/package/tests/test_api/test_apps.py @@ -62,3 +62,10 @@ def test_reload_endpoint_return_304_when_content_has_not_changed( # when the etag has changed, the server will return a 200 response = client.get("/api/reload", headers={"If-None-Match": "new etag"}) assert response.status_code == 200 + + +class TestFaviconEndpoint: + def test_favicon_endpoint(client): + response = client.get("/favicon.ico") + assert response.status_code == 200 + assert response.headers["content-type"] == "image/x-icon" \ No newline at end of file From e8b9ba19e9ee0f1c67fe436b1fb0738cf5bd3013 Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 17:26:03 +0100 Subject: [PATCH 06/18] Favicon endpoint test added --- package/tests/test_api/test_apps.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/tests/test_api/test_apps.py b/package/tests/test_api/test_apps.py index 64b3305680..9f575e4a46 100644 --- a/package/tests/test_api/test_apps.py +++ b/package/tests/test_api/test_apps.py @@ -65,7 +65,13 @@ def test_reload_endpoint_return_304_when_content_has_not_changed( class TestFaviconEndpoint: - def test_favicon_endpoint(client): - response = client.get("/favicon.ico") + + @pytest.fixture + def test_client(self): + app = apps.create_api_app_from_project(mock.MagicMock(), autoreload=True) + return TestClient(app) + + def test_favicon_endpoint(self, test_client): + response = test_client.get("/favicon.ico") assert response.status_code == 200 assert response.headers["content-type"] == "image/x-icon" \ No newline at end of file From 2ad9a602f7c4ac5358d982a51cb1d327db959c29 Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 17:32:47 +0100 Subject: [PATCH 07/18] Lint error fixed --- package/tests/test_api/test_apps.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package/tests/test_api/test_apps.py b/package/tests/test_api/test_apps.py index 9f575e4a46..ec0447a72e 100644 --- a/package/tests/test_api/test_apps.py +++ b/package/tests/test_api/test_apps.py @@ -65,7 +65,6 @@ def test_reload_endpoint_return_304_when_content_has_not_changed( class TestFaviconEndpoint: - @pytest.fixture def test_client(self): app = apps.create_api_app_from_project(mock.MagicMock(), autoreload=True) @@ -74,4 +73,4 @@ def test_client(self): def test_favicon_endpoint(self, test_client): response = test_client.get("/favicon.ico") assert response.status_code == 200 - assert response.headers["content-type"] == "image/x-icon" \ No newline at end of file + assert response.headers["content-type"] == "image/x-icon" From 50d0d2ff06fb8abe713bd7f7ceb83dc658b3c2b8 Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 10:05:37 +0100 Subject: [PATCH 08/18] Fix: Adding favicon to Kedro Demo Signed-off-by: Jitendra Gundaniya --- package/kedro_viz/api/apps.py | 3 +++ public/index.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index a9bb5d97b4..88e9d132b7 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -68,6 +68,9 @@ def create_api_app_from_project( # frontend e2e tests via Cypress app.mount("/static", StaticFiles(directory=_HTML_DIR / "static"), name="static") + # Mount the public directory for serving image files + app.mount("/images", StaticFiles(directory=_HTML_DIR), name="images") + # everytime the server reloads, a new app with a new timestamp will be created. # this is used as an etag embedded in the frontend for client to use when making requests. app_etag = _create_etag() diff --git a/public/index.html b/public/index.html index d9e92d68c6..d977c3e017 100644 --- a/public/index.html +++ b/public/index.html @@ -7,7 +7,7 @@ content="width=device-width, initial-scale=1, shrink-to-fit=no" /> - + Kedro-Viz Date: Wed, 30 Aug 2023 12:57:39 +0100 Subject: [PATCH 09/18] Fix: Change in approach for serving favicon Signed-off-by: Jitendra Gundaniya --- package/kedro_viz/api/apps.py | 10 ++++++---- public/index.html | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index 88e9d132b7..780590cc42 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -8,7 +8,7 @@ import secure from fastapi import FastAPI, HTTPException from fastapi.requests import Request -from fastapi.responses import HTMLResponse, JSONResponse, Response +from fastapi.responses import HTMLResponse, JSONResponse, Response, FileResponse from fastapi.staticfiles import StaticFiles from jinja2 import Environment, FileSystemLoader @@ -68,13 +68,15 @@ def create_api_app_from_project( # frontend e2e tests via Cypress app.mount("/static", StaticFiles(directory=_HTML_DIR / "static"), name="static") - # Mount the public directory for serving image files - app.mount("/images", StaticFiles(directory=_HTML_DIR), name="images") - # everytime the server reloads, a new app with a new timestamp will be created. # this is used as an etag embedded in the frontend for client to use when making requests. app_etag = _create_etag() + # Serve the favicon.ico file from the "html" directory + @app.get('/favicon.ico', include_in_schema=False) + async def favicon(): + return FileResponse(_HTML_DIR / "favicon.ico") + @app.get("/") @app.get("/experiment-tracking") async def index(): diff --git a/public/index.html b/public/index.html index d977c3e017..d9e92d68c6 100644 --- a/public/index.html +++ b/public/index.html @@ -7,7 +7,7 @@ content="width=device-width, initial-scale=1, shrink-to-fit=no" /> - + Kedro-Viz Date: Wed, 30 Aug 2023 13:18:28 +0100 Subject: [PATCH 10/18] Lint error fix Signed-off-by: Jitendra Gundaniya --- package/kedro_viz/api/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index 780590cc42..04a185b6d3 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -8,7 +8,7 @@ import secure from fastapi import FastAPI, HTTPException from fastapi.requests import Request -from fastapi.responses import HTMLResponse, JSONResponse, Response, FileResponse +from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, Response from fastapi.staticfiles import StaticFiles from jinja2 import Environment, FileSystemLoader From b3184274e91b0944fbd12ad7bf7d3324267220fc Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 16:06:20 +0100 Subject: [PATCH 11/18] Lint error fix Signed-off-by: Jitendra Gundaniya --- package/kedro_viz/api/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kedro_viz/api/apps.py b/package/kedro_viz/api/apps.py index 04a185b6d3..e55c857f27 100644 --- a/package/kedro_viz/api/apps.py +++ b/package/kedro_viz/api/apps.py @@ -73,7 +73,7 @@ def create_api_app_from_project( app_etag = _create_etag() # Serve the favicon.ico file from the "html" directory - @app.get('/favicon.ico', include_in_schema=False) + @app.get("/favicon.ico", include_in_schema=False) async def favicon(): return FileResponse(_HTML_DIR / "favicon.ico") From 82508d47b6d24b9305fc97d32efe1676dbf08ec1 Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 16:54:59 +0100 Subject: [PATCH 12/18] Favicon endpoint test added Signed-off-by: Jitendra Gundaniya --- package/tests/test_api/test_apps.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package/tests/test_api/test_apps.py b/package/tests/test_api/test_apps.py index 5174dbe22e..64b3305680 100644 --- a/package/tests/test_api/test_apps.py +++ b/package/tests/test_api/test_apps.py @@ -62,3 +62,10 @@ def test_reload_endpoint_return_304_when_content_has_not_changed( # when the etag has changed, the server will return a 200 response = client.get("/api/reload", headers={"If-None-Match": "new etag"}) assert response.status_code == 200 + + +class TestFaviconEndpoint: + def test_favicon_endpoint(client): + response = client.get("/favicon.ico") + assert response.status_code == 200 + assert response.headers["content-type"] == "image/x-icon" \ No newline at end of file From cefb8f405cc846d44e0361c31813c7bd6ac8eba4 Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 17:26:03 +0100 Subject: [PATCH 13/18] Favicon endpoint test added Signed-off-by: Jitendra Gundaniya --- package/tests/test_api/test_apps.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/tests/test_api/test_apps.py b/package/tests/test_api/test_apps.py index 64b3305680..9f575e4a46 100644 --- a/package/tests/test_api/test_apps.py +++ b/package/tests/test_api/test_apps.py @@ -65,7 +65,13 @@ def test_reload_endpoint_return_304_when_content_has_not_changed( class TestFaviconEndpoint: - def test_favicon_endpoint(client): - response = client.get("/favicon.ico") + + @pytest.fixture + def test_client(self): + app = apps.create_api_app_from_project(mock.MagicMock(), autoreload=True) + return TestClient(app) + + def test_favicon_endpoint(self, test_client): + response = test_client.get("/favicon.ico") assert response.status_code == 200 assert response.headers["content-type"] == "image/x-icon" \ No newline at end of file From 02dc49d9ad6ed5b4bac308c017b6d59c0ff7fdfc Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 17:32:47 +0100 Subject: [PATCH 14/18] Lint error fixed Signed-off-by: Jitendra Gundaniya --- package/tests/test_api/test_apps.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package/tests/test_api/test_apps.py b/package/tests/test_api/test_apps.py index 9f575e4a46..ec0447a72e 100644 --- a/package/tests/test_api/test_apps.py +++ b/package/tests/test_api/test_apps.py @@ -65,7 +65,6 @@ def test_reload_endpoint_return_304_when_content_has_not_changed( class TestFaviconEndpoint: - @pytest.fixture def test_client(self): app = apps.create_api_app_from_project(mock.MagicMock(), autoreload=True) @@ -74,4 +73,4 @@ def test_client(self): def test_favicon_endpoint(self, test_client): response = test_client.get("/favicon.ico") assert response.status_code == 200 - assert response.headers["content-type"] == "image/x-icon" \ No newline at end of file + assert response.headers["content-type"] == "image/x-icon" From a48ab54c9b52191a26cfd4b24c5705d5864377c2 Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Wed, 30 Aug 2023 18:14:22 +0100 Subject: [PATCH 15/18] Fixed favicon endpoint test --- package/tests/test_api/test_apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/tests/test_api/test_apps.py b/package/tests/test_api/test_apps.py index ec0447a72e..ccfc9d4124 100644 --- a/package/tests/test_api/test_apps.py +++ b/package/tests/test_api/test_apps.py @@ -73,4 +73,4 @@ def test_client(self): def test_favicon_endpoint(self, test_client): response = test_client.get("/favicon.ico") assert response.status_code == 200 - assert response.headers["content-type"] == "image/x-icon" + assert response.headers["content-type"] in ["image/x-icon", "image/vnd.microsoft.icon"] From d620df3cb43c6309d2d244b9f65002ffbe3397d8 Mon Sep 17 00:00:00 2001 From: Jitendra Gundaniya Date: Thu, 31 Aug 2023 09:22:55 +0100 Subject: [PATCH 16/18] Release doc updated --- RELEASE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE.md b/RELEASE.md index 1990e9f633..d911058b8a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -13,6 +13,7 @@ Please follow the established format: ## Bug fixes and other changes - Fix to search for a ' Date: Thu, 31 Aug 2023 11:29:12 +0100 Subject: [PATCH 17/18] Update RELEASE.md Co-authored-by: rashidakanchwala <37628668+rashidakanchwala@users.noreply.github.com> --- RELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 6e38a9bfa4..781b8131e5 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -15,7 +15,7 @@ Please follow the established format: ## Bug fixes and other changes - Fix to search for a ' Date: Thu, 31 Aug 2023 12:02:29 +0100 Subject: [PATCH 18/18] Removed pytest.fixture as per review comment --- package/tests/test_api/test_apps.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/package/tests/test_api/test_apps.py b/package/tests/test_api/test_apps.py index fd7e446441..5c9550fae4 100644 --- a/package/tests/test_api/test_apps.py +++ b/package/tests/test_api/test_apps.py @@ -65,13 +65,8 @@ def test_reload_endpoint_return_304_when_content_has_not_changed( class TestFaviconEndpoint: - @pytest.fixture - def test_client(self): - app = apps.create_api_app_from_project(mock.MagicMock(), autoreload=True) - return TestClient(app) - - def test_favicon_endpoint(self, test_client): - response = test_client.get("/favicon.ico") + def test_favicon_endpoint(self, client): + response = client.get("/favicon.ico") assert response.status_code == 200 assert response.headers["content-type"] in [ "image/x-icon",