Skip to content

Commit

Permalink
Merge branch 'main' into upload-catalog-from-url
Browse files Browse the repository at this point in the history
  • Loading branch information
JAulet authored Nov 11, 2021
2 parents b3b4b65 + aca026e commit 6e6b466
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
# 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 import download_file_content_from_url
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


Expand Down Expand Up @@ -109,6 +109,11 @@ def upload_multiple_assets(body: ApiCatalogUpload): # noqa: E501


def _upload_multiple_assets(body: ApiCatalogUpload): # 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 []:
Expand Down Expand Up @@ -161,6 +166,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 \
Expand Down
4 changes: 3 additions & 1 deletion quickstart/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6e6b466

Please sign in to comment.