From 5ec3f216c3310d12f8cce1cfc34f0e82b95781f5 Mon Sep 17 00:00:00 2001 From: Christian Kadner Date: Tue, 9 Nov 2021 10:38:48 -0800 Subject: [PATCH 1/2] Disable UI cache in Quickstart (#257) With Docker Compose, the API and UI run locally and the API has caching for GET requests. So there is no real advantage in having yet another layer of caching in the UI. In fact, the UI cache is often getting in the way of testing the catalog by adding or deleting assets. Signed-off-by: Christian Kadner --- quickstart/docker-compose.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickstart/docker-compose.yaml b/quickstart/docker-compose.yaml index 21fa41d1..362a9a6f 100644 --- a/quickstart/docker-compose.yaml +++ b/quickstart/docker-compose.yaml @@ -79,13 +79,15 @@ services: - "80:3000" environment: REACT_APP_BRAND: "Machine Learning Exchange" - REACT_APP_RUN: "false" REACT_APP_UPLOAD: "true" + REACT_APP_RUN: "false" REACT_APP_BASE_PATH: "" REACT_APP_API: "${DOCKER_HOST_IP:-localhost}:8080" REACT_APP_KFP: "" REACT_APP_DISABLE_LOGIN: "true" REACT_APP_GTM_ID: "${GTM_ID}" + REACT_APP_TTL: "0" + REACT_APP_CACHE_INTERVAL: "0" catalog: image: curlimages/curl From aca026e772502bfbdbc9549b1b6544c2aa013db1 Mon Sep 17 00:00:00 2001 From: Christian Kadner Date: Tue, 9 Nov 2021 10:39:49 -0800 Subject: [PATCH 2/2] Feature all assets from catalog upload (#256) This removes the need to toggle both the Published and Featured checkboxes for each of the (46) uploaded assets. Since uploading a curated catalog can only be done by admins, we assume that all the uploaded assets are to be published and featured. Resolves #237 Signed-off-by: Christian Kadner --- .../catalog_service_controller_impl.py | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/api/server/swagger_server/controllers_impl/catalog_service_controller_impl.py b/api/server/swagger_server/controllers_impl/catalog_service_controller_impl.py index 9d632044..e36b6dc7 100644 --- a/api/server/swagger_server/controllers_impl/catalog_service_controller_impl.py +++ b/api/server/swagger_server/controllers_impl/catalog_service_controller_impl.py @@ -3,20 +3,20 @@ # SPDX-License-Identifier: Apache-2.0 import connexion -import json import traceback -from swagger_server.models import ApiCatalogUploadError -from swagger_server.models.api_catalog_upload import ApiCatalogUpload # noqa: E501 -from swagger_server.models.api_catalog_upload_response import ApiCatalogUploadResponse -from swagger_server.models.api_catalog_upload_item import ApiCatalogUploadItem -from swagger_server.models.api_list_catalog_items_response import ApiListCatalogItemsResponse # noqa: E501 +from swagger_server.data_access.mysql_client import update_multiple + +from swagger_server.models import ApiCatalogUpload, ApiCatalogUploadError +from swagger_server.models import ApiCatalogUploadResponse, ApiListCatalogItemsResponse +from swagger_server.models import ApiComponent, ApiDataset, ApiModel, ApiNotebook, ApiPipelineExtension from swagger_server.controllers_impl.component_service_controller_impl import list_components, upload_component_from_url from swagger_server.controllers_impl.dataset_service_controller_impl import list_datasets, upload_dataset_from_url from swagger_server.controllers_impl.model_service_controller_impl import list_models, upload_model_from_url from swagger_server.controllers_impl.notebook_service_controller_impl import list_notebooks, upload_notebook_from_url from swagger_server.controllers_impl.pipeline_service_controller_impl import list_pipelines, upload_pipeline_from_url + from swagger_server.util import ApiError @@ -82,6 +82,12 @@ def upload_multiple_assets(body: ApiCatalogUpload): # noqa: E501 if connexion.request.is_json: body = ApiCatalogUpload.from_dict(connexion.request.get_json()) # noqa: E501 + # TODO: parameterize `publish_all` and `feature_all` flags, maybe? Although + # uploading a whole catalog is an admin activity, who most likely wants to + # register a curated list of assets that are to be published and featured + publish_all = True + feature_all = True + def get_access_token_for_url(url: str) -> str: for api_access_token in body.api_access_tokens or []: if api_access_token.url_host in url: @@ -133,6 +139,20 @@ def get_access_token_for_url(url: str) -> str: api_response.total_errors = len(api_response.errors) + if publish_all or feature_all: + api_classes = { + "components": ApiComponent, + "datasets": ApiDataset, + "models": ApiModel, + "notebooks": ApiNotebook, + "pipelines": ApiPipelineExtension + } + for asset_type, api_class in api_classes.items(): + asset_list = api_response.__getattribute__(asset_type) + asset_ids = [asset.id for asset in asset_list] + update_multiple(api_class, asset_ids, "publish_approved", publish_all) + update_multiple(api_class, asset_ids, "featured", feature_all) + response_status = \ 201 if api_response.total_created > 0 and api_response.total_errors == 0 else \ 207 if api_response.total_created > 0 and api_response.total_errors > 0 else \