diff --git a/components/crud-web-apps/jupyter/backend/apps/common/utils.py b/components/crud-web-apps/jupyter/backend/apps/common/utils.py index 0ff73505e6d..df4d6d9da15 100644 --- a/components/crud-web-apps/jupyter/backend/apps/common/utils.py +++ b/components/crud-web-apps/jupyter/backend/apps/common/utils.py @@ -2,11 +2,11 @@ import random import string +from cachetools.func import ttl_cache +from kubeflow.kubeflow.crud_backend import helpers, logging from kubernetes import client from werkzeug import exceptions -from kubeflow.kubeflow.crud_backend import helpers, logging - from . import status log = logging.getLogger(__name__) @@ -41,6 +41,7 @@ def load_notebook_template(**kwargs): return helpers.load_param_yaml(NOTEBOOK_TEMPLATE_YAML, **kwargs) +@ttl_cache(ttl=60) def load_spawner_ui_config(): for config in CONFIGS: config_dict = helpers.load_yaml(config) @@ -90,13 +91,15 @@ def pvc_from_dict(vol, namespace): return None return client.V1PersistentVolumeClaim( - metadata=client.V1ObjectMeta(name=vol["name"], namespace=namespace,), + metadata=client.V1ObjectMeta( + name=vol["name"], + namespace=namespace, + ), spec=client.V1PersistentVolumeClaimSpec( access_modes=[vol["mode"]], storage_class_name=get_storage_class(vol), resources=client.V1ResourceRequirements( - requests={"storage": vol["size"]} - ), + requests={"storage": vol["size"]}), ), ) @@ -139,5 +142,5 @@ def notebook_dict_from_k8s_obj(notebook): "memory": cntr["resources"]["requests"]["memory"], "volumes": [v["name"] for v in cntr["volumeMounts"]], "status": status.process_status(notebook), - "metadata": notebook["metadata"] + "metadata": notebook["metadata"], }