Skip to content

Commit

Permalink
[KF-1471] fix: add default value for pipelines (#221)
Browse files Browse the repository at this point in the history
* fix: add default value for pipelines
canonical/kfp-operators#159

Fixes #159 

Summary of changes:
- Added back default value for pipelines access.
- Added tests for default values of pipelines access and images for 1.7
  release.
- Modified code to check for mindspore image only not version.

---------

Co-authored-by: Andrew Scribner <[email protected]>
  • Loading branch information
i-chvets and ca-scribner authored Mar 28, 2023
1 parent ceca1b0 commit d3e6d39
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion charms/jupyter-ui/src/spawner_ui_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,11 @@ spawnerFormDefaults:
# value:
# - add-gcp-secret
# - default-editor
value: []
value:
# Added from https://github.com/kubeflow/kubeflow/pull/6160 to fix
# https://github.com/canonical/bundle-kubeflow/issues/423. This was not yet in
# upstream and if they go with something different we should consider syncing with
# upstream.
# Auto-selects "Allow access to Kubeflow Pipelines" button in Notebook spawner UI
- access-ml-pipeline
readOnly: false
22 changes: 22 additions & 0 deletions charms/jupyter-ui/tests/unit/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

"""Unit tests for JupyterUI Charm."""

from pathlib import Path
from unittest.mock import MagicMock, patch

import pytest
Expand All @@ -28,6 +29,27 @@ def harness() -> Harness:
class TestCharm:
"""Test class for JupyterUI."""

def test_spawner_ui(self):
"""Test spawner UI.
spawner_ui_config.yaml contains a number of changes that were done for Charmed
Kubeflow. This test is to validate those. If it fails, spawner_ui_config.yaml
should be reviewed and changes to this tests should be made, if required.
"""
spawner_ui_config = yaml.safe_load(Path("./src/spawner_ui_config.yaml").read_text())

# test for default configurations
# only single configuration value is currently set in the list of values
config_value = spawner_ui_config["spawnerFormDefaults"]["configurations"]["value"]
assert config_value == ["access-ml-pipeline"]

# test for images added in addition to upstream
image_list = spawner_ui_config["spawnerFormDefaults"]["image"]["options"]
assert any(
"swr.cn-south-1.myhuaweicloud.com/mindspore/jupyter-mindspore" in image
for image in image_list
)

@patch("charm.KubernetesServicePatch", lambda x, y, service_name: None)
@patch("charm.JupyterUI.k8s_resource_handler")
def test_not_leader(self, k8s_resource_handler: MagicMock, harness: Harness):
Expand Down

0 comments on commit d3e6d39

Please sign in to comment.