def _upload_model_yaml(yaml_file_content: AnyStr, name=None, existing_id=None): model_def = yaml.load(yaml_file_content, Loader=yaml.FullLoader) api_model = ApiModel( id=existing_id or model_def.get("model_identifier") or generate_id(name=name or model_def["name"]), created_at=datetime.now(), name=name or model_def["name"], description=model_def["description"].strip(), domain=model_def.get("domain") or "", labels=model_def.get("labels") or dict(), framework=model_def["framework"], filter_categories=model_def.get("filter_categories") or dict(), trainable=model_def.get("train", {}).get("trainable") or False, trainable_tested_platforms=model_def.get( "train", {}).get("tested_platforms") or [], trainable_credentials_required=model_def.get( "train", {}).get("credentials_required") or False, trainable_parameters=model_def.get("train", {}).get("input_params") or [], servable=model_def.get("serve", {}).get("servable") or False, servable_tested_platforms=model_def.get( "serve", {}).get("tested_platforms") or [], servable_credentials_required=model_def.get( "serve", {}).get("credentials_required") or False, servable_parameters=model_def.get("serve", {}).get("input_params") or []) # convert comma-separate strings to lists if type(api_model.trainable_tested_platforms) == str: api_model.trainable_tested_platforms = api_model.trainable_tested_platforms.replace( ", ", ",").split(",") if type(api_model.servable_tested_platforms) == str: api_model.servable_tested_platforms = api_model.servable_tested_platforms.replace( ", ", ",").split(",") uuid = store_data(api_model) api_model.id = uuid store_file(bucket_name="mlpipeline", prefix=f"models/{api_model.id}/", file_name="template.yaml", file_content=yaml_file_content, content_type="text/yaml") enable_anonymous_read_access(bucket_name="mlpipeline", prefix="models/*") return api_model, 201
def test_create_model(self): """Test case for create_model """ body = ApiModel() response = self.client.open('/apis/v1alpha1/models', method='POST', data=json.dumps(body), content_type='application/json') self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
def create_model(body): # noqa: E501 """create_model # noqa: E501 :param body: :type body: dict | bytes :rtype: ApiModel """ if connexion.request.is_json: body = ApiModel.from_dict(connexion.request.get_json()) # noqa: E501 return util.invoke_controller_impl()
def create_model(body): # noqa: E501 """create_model :param body: :type body: dict | bytes :rtype: ApiModel """ if connexion.request.is_json: body = ApiModel.from_dict(connexion.request.get_json()) # noqa: E501 api_model = body error = store_data(api_model) if error: return error, 400 return api_model, 200 # TODO: return 201