Description
- When the user installs the generated api_client package (in this case
mlp_client), the user will want to DescribeModel or RegisterModel which are both POST APIs
- Note: Both of the components' schemas (RegisterModelRequest & DescribeModelRequest) are objects
- For this issue, I am sharing just the spec for
DescribeModel, but can share the spec for RegisterModel if required
- When the user follows the generated instructions (docs), they will use the following Python code:
import mlp_client
from mlp_client.configurations import api_configuration
from mlp_client.apis.tags import model_api
from mlp_client.components.schema import describe_model_request
used_configuration = api_configuration.ApiConfiguration()
api_client = mlp_client.ApiClient(used_configuration)
api_instance = model_api.ModelApi(api_client)
body = describe_model_request.DescribeModelRequest({
"id": "MG:mlp:test-mlp:v1"
})
api_response = api_instance.describe_model(
body=body,
)
However, this is the response:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mlp_client/paths/v1_models_describe/post/operation.py", line 92, in _describe_model
fields, serialized_body = self._get_fields_and_body(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mlp_client/api_client.py", line 1255, in _get_fields_and_body
serialized_data = request_body.serialize(body, content_type, configuration=self.api_client.schema_configuration)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mlp_client/api_client.py", line 1398, in serialize
cast_in_data = schema.validate_base(in_data, configuration=used_configuration)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mlp_client/schemas/schema.py", line 549, in validate_base
cast_arg = cast_to_allowed_types(
^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mlp_client/schemas/schema.py", line 277, in cast_to_allowed_types
raise exceptions.ApiTypeError('Invalid type passed in got input={} type={}'.format(arg, type(arg)))
mlp_client.exceptions.ApiTypeError: Invalid type passed in got input=DescribeModelRequest(types={'id': 'MG:mlp:mlp-sdk-charles-demo:v1'}, properties={'id': <class 'mlp_client.schemas.schemas.StrSchema'>, 'name': <class 'mlp_client.schemas.schemas.StrSchema'>, 'variant': <class 'mlp_client.schemas.schemas.StrSchema'>, 'owner_team': <class 'mlp_client.schemas.schemas.StrSchema'>, 'omd_business_service': <class 'mlp_client.schemas.schemas.StrSchema'>}, type_to_output_cls={<class 'mlp_client.schemas.original_immutabledict.immutabledict'>: <class 'mlp_client.components.schema.describe_model_request.DescribeModelRequestDict'>}) type=<class 'mlp_client.components.schema.describe_model_request.DescribeModelRequest'>
This is what the spec looks like for DescribeModel:
openapi: 3.0.0
info:
title: MLP [ML Platform SDK] - OpenAPI 3.0
description: "This SDK produces Model Registration based on the OpenAPI 3.0 specification"
termsOfService: http://swagger.io/terms/
contact:
email: wbd_ml_platform@wbd.com
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 0.0.22
servers:
- url: http://127.0.0.1:4011
description: Local test server (using Prism - https://github.com/stoplightio/prism)
tags:
- name: model
description: API for Model Describe
paths:
/v1/models/describe:
post:
tags:
- model
summary: Describe a registered model
description: Return a model based on id or name, variant, owner_team & omd_business_service
operationId: DescribeModel
requestBody:
description: Describe a model in the model server
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DescribeModelRequest'
responses:
'201':
description: Successful operation
'400':
description: Invalid ID supplied
components:
schemas:
DescribeModelRequest:
type: object
properties:
id:
type: string
example: 'MG:mlp:test-mlp:v1'
name:
type: string
example: 'test-mlp'
variant:
type: string
example: 'v1'
owner_team:
type: string
example: 'mlp'
omd_business_service:
type: string
example: 'ml-and-growth'
securitySchemes:
api_key:
type: apiKey
name: api_key
in: header
Question: Is this an issue related to immutabledict? Is there something I will need to modify in order to pass in the object as the request?
openapi-generator version
v3.0.0
Generation Details
executed:
java -jar openapi-json-schema-generator-cli.jar generate \
-i openapi.yaml \
-g python \
-o mlp_client \
--package-name mlp_client
Steps to reproduce
Run the generator, add an empty __init__.py file under mlp_client/ output, pip install the package on my local machine, run the Python code and return the described error above ⬆️ (no pun intended).
Description
mlp_client), the user will want toDescribeModelorRegisterModelwhich are both POST APIsDescribeModel, but can share the spec forRegisterModelif requiredHowever, this is the response:
This is what the spec looks like for DescribeModel:
Question: Is this an issue related to
immutabledict? Is there something I will need to modify in order to pass in the object as the request?openapi-generator version
v3.0.0
Generation Details
executed:
Steps to reproduce
Run the generator, add an empty
__init__.pyfile undermlp_client/output, pip install the package on my local machine, run the Python code and return the described error above ⬆️ (no pun intended).