Skip to content

Commit

Permalink
Enable/disable preview for all the datasets when publishing Kedro-Viz…
Browse files Browse the repository at this point in the history
… from UI (#1895)

* Add options for cli common with disable preview of datasets

Signed-off-by: Jitendra Gundaniya <[email protected]>

* New approach for disable preview

Signed-off-by: <>

* Disable preview for cli and lint fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* deploy api with preview

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Removing UI changes

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Removing UI changes

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Disable preview from UI

Signed-off-by: <>

* Code review suggestions

Signed-off-by: Jitendra Gundaniya <[email protected]>

* temp code removed

Signed-off-by: Jitendra Gundaniya <[email protected]>

* refactor disable preview cli

Signed-off-by: ravi-kumar-pilla <[email protected]>

* fix lint

Signed-off-by: ravi-kumar-pilla <[email protected]>

* fix lint

Signed-off-by: ravi-kumar-pilla <[email protected]>

* testing 1

Signed-off-by: ravi-kumar-pilla <[email protected]>

* change help text

Signed-off-by: ravi-kumar-pilla <[email protected]>

* change help text

Signed-off-by: ravi-kumar-pilla <[email protected]>

* update tests

Signed-off-by: ravi-kumar-pilla <[email protected]>

* format help text

Signed-off-by: ravi-kumar-pilla <[email protected]>

* change default preview for run

Signed-off-by: ravi-kumar-pilla <[email protected]>

* update release note

Signed-off-by: ravi-kumar-pilla <[email protected]>

* address vale suggestion

Signed-off-by: ravi-kumar-pilla <[email protected]>

* fix lint

Signed-off-by: ravi-kumar-pilla <[email protected]>

* fix pytests and linter

Signed-off-by: ravi-kumar-pilla <[email protected]>

* adjust file permission

Signed-off-by: ravi-kumar-pilla <[email protected]>

* update tests

Signed-off-by: ravi-kumar-pilla <[email protected]>

* update release note

Signed-off-by: ravi-kumar-pilla <[email protected]>

* update release note

Signed-off-by: ravi-kumar-pilla <[email protected]>

* --include-preview flag added for CLI

Signed-off-by: Jitendra Gundaniya <[email protected]>

* are_datasets_previewable renamed to  is_all_previews_enabled

Signed-off-by: Jitendra Gundaniya <[email protected]>

* lint fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* are_datasets_previewable renamed to is_all_previews_enabled

Signed-off-by: Jitendra Gundaniya <[email protected]>

* type ignore add for TRANSCODING_SEPARATOR

Signed-off-by: Jitendra Gundaniya <[email protected]>

* File permissions updated

Signed-off-by: Jitendra Gundaniya <[email protected]>

* fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* All dataset preview toggle works with deploy api

Signed-off-by: Jitendra Gundaniya <[email protected]>

* CLI flag renamed to --include-previews

Signed-off-by: Jitendra Gundaniya <[email protected]>

---------

Signed-off-by: Jitendra Gundaniya <[email protected]>
Signed-off-by: <>
Signed-off-by: ravi-kumar-pilla <[email protected]>
Co-authored-by: ravi-kumar-pilla <[email protected]>
  • Loading branch information
jitu5 and ravi-kumar-pilla authored Jun 12, 2024
1 parent 7733896 commit 497a128
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 22 deletions.
10 changes: 7 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ Please follow the established format:
- Use present tense (e.g. 'Add new feature')
- Include the ID number for the related PR (or PRs) in parentheses
-->
# Next release
# Release 9.2.0

## Major features and improvements
- Enable/disable preview for all the datasets when publishing Kedro-Viz from CLI. (#1894)
- Enable/disable preview for all the datasets when publishing Kedro-Viz from UI. (#1895)

## Bug fixes and other changes

## Major features and improvements
- Display published URLs. (#1907)
Expand All @@ -18,8 +24,6 @@ Please follow the established format:
- Introduce the toggle to expand and collapse all pipelines button in the utility bar. (#1858)
- Allow Kedro-Viz commands to run from any sub directory within Kedro project. (#1871)

- Enable/disable preview for all the datasets when publishing Kedro-Viz from CLI. (#1894)

## Bug fixes and other changes
- Fix broken URL when active pipeline name changes on initial load. (#1914)
- Fix bug related to tag filtering and sharing with stateful URL. (#1878)
Expand Down
1 change: 1 addition & 0 deletions package/kedro_viz/api/rest/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ class DeployerConfiguration(BaseModel):
"""Credentials for Deployers."""

platform: str
is_all_previews_enabled: bool = False
endpoint: str
bucket_name: str
2 changes: 1 addition & 1 deletion package/kedro_viz/api/rest/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def deploy_kedro_viz(input_values: DeployerConfiguration):
deployer = DeployerFactory.create_deployer(
input_values.platform, input_values.endpoint, input_values.bucket_name
)
deployer.deploy()
deployer.deploy(input_values.is_all_previews_enabled)
response = {
"message": "Website deployed on "
f"{input_values.platform and input_values.platform.upper()}",
Expand Down
16 changes: 8 additions & 8 deletions package/kedro_viz/launchers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ def run(
help="A flag to include all registered hooks in your Kedro Project",
)
@click.option(
"--include-preview",
"--include-previews",
is_flag=True,
help="Enable/disable preview for all the datasets.",
help="A flag to include preview for all the datasets",
)
def deploy(platform, endpoint, bucket_name, include_hooks, include_preview):
def deploy(platform, endpoint, bucket_name, include_hooks, include_previews):
"""Deploy and host Kedro Viz on provided platform"""
if not platform or platform.lower() not in SHAREABLEVIZ_SUPPORTED_PLATFORMS:
display_cli_message(
Expand All @@ -259,7 +259,7 @@ def deploy(platform, endpoint, bucket_name, include_hooks, include_preview):

create_shareableviz_process(
platform,
include_preview,
include_previews,
endpoint,
bucket_name,
include_hooks,
Expand All @@ -273,14 +273,14 @@ def deploy(platform, endpoint, bucket_name, include_hooks, include_preview):
help="A flag to include all registered hooks in your Kedro Project",
)
@click.option(
"--include-preview",
"--include-previews",
is_flag=True,
help="Enable/disable preview for all the datasets.",
help="A flag to include preview for all the datasets",
)
def build(include_hooks, include_preview):
def build(include_hooks, include_previews):
"""Create build directory of local Kedro Viz instance with Kedro project data"""

create_shareableviz_process("local", include_preview, include_hooks=include_hooks)
create_shareableviz_process("local", include_previews, include_hooks=include_hooks)


def create_shareableviz_process(
Expand Down
19 changes: 13 additions & 6 deletions package/tests/test_api/test_rest/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,32 @@ class MockDeployer:
def __init__(self, platform, endpoint, bucket_name):
pass

def deploy(self):
def deploy(self, is_all_previews_enabled):
pass


@pytest.mark.parametrize(
"platform, endpoint, bucket_name",
"platform, endpoint, bucket_name, is_all_previews_enabled",
[
("aws", "http://mocked-url.com", "s3://shareableviz"),
("azure", "http://mocked-url.com", "abfs://shareableviz"),
("aws", "http://mocked-url.com", "s3://shareableviz", True),
("azure", "http://mocked-url.com", "abfs://shareableviz", False),
],
)
def test_deploy_kedro_viz(client, platform, endpoint, bucket_name, mocker):
def test_deploy_kedro_viz(
client, platform, endpoint, bucket_name, is_all_previews_enabled, mocker
):
mocker.patch(
"kedro_viz.api.rest.router.DeployerFactory.create_deployer",
return_value=MockDeployer(platform, endpoint, bucket_name),
)
response = client.post(
"/api/deploy",
json={"platform": platform, "endpoint": endpoint, "bucket_name": bucket_name},
json={
"platform": platform,
"endpoint": endpoint,
"bucket_name": bucket_name,
"is_all_previews_enabled": is_all_previews_enabled,
},
)

assert response.status_code == 200
Expand Down
4 changes: 2 additions & 2 deletions package/tests/test_launchers/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def test_viz_command_group(mocker, mock_click_echo):
"http://example-bucket.s3-website.us-east-2.amazonaws.com/",
"--bucket-name",
"example-bucket",
"--include-preview",
"--include-previews",
],
{
"platform": "aws",
Expand Down Expand Up @@ -560,7 +560,7 @@ def test_viz_deploy_invalid_endpoint(mocker, mock_click_echo):
{"platform": "local", "include_hooks": True},
),
(
["viz", "build", "--include-preview"],
["viz", "build", "--include-previews"],
{"platform": "local", "preview": True},
),
],
Expand Down
8 changes: 6 additions & 2 deletions src/components/shareable-url-modal/shareable-url-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ShareableUrlModal = ({ onToggleModal, visible }) => {
const [hostingPlatformLocalStorageVal, setHostingPlatformLocalStorageVal] =
useState(loadLocalStorage(localStorageShareableUrl) || {});
const [publishedPlatformKey, setPublishedPlatformKey] = useState(undefined);
const [isPreviewEnabled, setIsPreviewEnabled] = useState(true);
const [isPreviewEnabled, setIsPreviewEnabled] = useState(false);

useEffect(() => {
async function fetchPackageCompatibility() {
Expand Down Expand Up @@ -171,7 +171,10 @@ const ShareableUrlModal = ({ onToggleModal, visible }) => {
setShowPublishedView(false);

try {
const request = await deployViz(inputValues);
const request = await deployViz({
...inputValues,
is_all_previews_enabled: isPreviewEnabled,
});
const response = await request.json();

if (request.ok) {
Expand Down Expand Up @@ -223,6 +226,7 @@ const ShareableUrlModal = ({ onToggleModal, visible }) => {
hasPlatform: false,
hasEndpoint: false,
});
setIsPreviewEnabled(false);
};

const { platform } = inputValues || {};
Expand Down

0 comments on commit 497a128

Please sign in to comment.