def get(self): # create an instance of the API class api, username = get_api(profile=self.profile) api_instance = modelcatalog.ModelApi(api_client=api) try: # List all Person entities api_response = api_instance.models_get(username=username) return api_response except ApiException as e: raise e
def post(self, request): api, username = get_api(profile=self.profile) api_instance = modelcatalog.ModelApi(api) model = Model(**request) if isinstance(request, dict) else request try: api_response = api_instance.models_post(username, model=model) return api_response except ApiException as e: logging.error("Exception when calling ModelConfigurationSetupApi->modelconfigurationsetups_post: %s\n" % e) raise e
def put(self, request): model_id = obtain_id(request.id) api, username = get_api(profile=self.profile) api_instance = modelcatalog.ModelApi(api) model = Model(**request) if isinstance(request, dict) else request try: # Update a Model return api_instance.models_id_put(model_id, username, model=model) except ApiException as e: print("Exception when calling ModelApi->models_id_put: %s\n" % e)
def get_by_label(self, label): api, username = get_api() api_instance = modelcatalog.ModelApi(api_client=api) try: api_response = api_instance.models_get(username=username, label=label[0]) return api_response except ApiException as e: logging.error("Exception when calling ModelApi->models_get: %s\n" % e) raise e
import json import typing import modelcatalog from modelcatalog import Model from mic._utils import get_api from modelcatalog import ApiException api, username = get_api() api_instance = modelcatalog.ModelApi(api_client=api) def test_1(): try: # List all Person entities api_response = api_instance.models_id_get("CYCLES", username=username) except ApiException as e: raise e response = api_response a = api_instance.models_post(username, model=response) with open("cycles.json", "w") as f: json.dump(a.to_dict(), f) def read_json(): with open("test.json", "r") as f: data = json.load(f) m = Model(**data) a = api_instance.models_post(username, model=m) return a