Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid value type in api response ['received_data']['status'] #7293

Closed
66li opened this issue Nov 29, 2021 · 11 comments · Fixed by #7500
Closed

Invalid value type in api response ['received_data']['status'] #7293

66li opened this issue Nov 29, 2021 · 11 comments · Fixed by #7500
Labels
area/sdks solution/workaround There's a workaround, might not be great, but exists type/bug

Comments

@66li
Copy link
Contributor

66li commented Nov 29, 2021

Summary

I tried to run the python-client example. used kubectl port-forward to forward the workflow port to the local. When I ran the following code, the workflow was successfully created but I got some errors.

from pprint import pprint

import requests
import yaml

import openapi_client
from openapi_client.api import workflow_service_api
from openapi_client.model.io_argoproj_workflow_v1alpha1_workflow_create_request import \
    IoArgoprojWorkflowV1alpha1WorkflowCreateRequest

Token = "Bearer eyJhbGciOiJSUzI1NiIs.."
configuration = openapi_client.Configuration(host="http://127.0.0.1:2746")

configuration.verify_ssl = False

resp = requests.get('https://raw.githubusercontent.com/argoproj/argo-workflows/master/examples/hello-world.yaml')
manifest = yaml.safe_load(resp.text)
#manifest['spec']['serviceAccountName'] = 'argo'


api_client = openapi_client.ApiClient(configuration,"Authorization",Token)
api_instance = workflow_service_api.WorkflowServiceApi(api_client)
print("test")
api_response = api_instance.workflow_service_create_workflow(
	namespace='argo',
	body=IoArgoprojWorkflowV1alpha1WorkflowCreateRequest(
		workflow=manifest, _check_type=False))
pprint(api_response)




Traceback (most recent call last):
  File "/Users/cwcw/feishu-bot/oprate.py", line 24, in <module>
    api_response = api_instance.workflow_service_create_workflow(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/api_client.py", line 771, in __call__
    return self.callable(self, *args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/api/workflow_service_api.py", line 121, in __workflow_service_create_workflow
    return self.call_with_http_info(**kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/api_client.py", line 833, in call_with_http_info
    return self.api_client.call_api(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/api_client.py", line 408, in call_api
    return self.__call_api(resource_path, method,
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/api_client.py", line 223, in __call_api
    return_data = self.deserialize(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/api_client.py", line 324, in deserialize
    deserialized_data = validate_and_convert_types(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1540, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1436, in attempt_convert_item
    raise conversion_exc
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1427, in attempt_convert_item
    return deserialize_model(input_value, valid_class,
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1347, in deserialize_model
    return model_class._new_from_openapi_data(**kw_args)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 44, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 343, in _new_from_openapi_data
    return cls._from_openapi_data(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 44, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model/io_argoproj_workflow_v1alpha1_workflow.py", line 198, in _from_openapi_data
    setattr(self, var_name, var_value)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 183, in __setattr__
    self[attr] = value
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 483, in __setitem__
    self.set_attribute(name, value)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 155, in set_attribute
    value = validate_and_convert_types(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1540, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1436, in attempt_convert_item
    raise conversion_exc
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1427, in attempt_convert_item
    return deserialize_model(input_value, valid_class,
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1347, in deserialize_model
    return model_class._new_from_openapi_data(**kw_args)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 44, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 343, in _new_from_openapi_data
    return cls._from_openapi_data(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 44, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model/io_argoproj_workflow_v1alpha1_workflow_status.py", line 240, in _from_openapi_data
    setattr(self, var_name, var_value)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 183, in __setattr__
    self[attr] = value
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 483, in __setitem__
    self.set_attribute(name, value)
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 155, in set_attribute
    value = validate_and_convert_types(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1540, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/opt/homebrew/lib/python3.9/site-packages/openapi_client/model_utils.py", line 1422, in attempt_convert_item
    raise get_type_error(input_value, path_to_item, valid_classes,
openapi_client.exceptions.ApiTypeError: Invalid type for variable 'started_at'. Required value type is datetime and passed type was NoneType at ['received_data']['status']['started_at']
@terrytangyuan
Copy link
Member

Thanks for reporting. Yes this is a known issue and I haven't got a chance to fix it yet. Feel free to submit a PR if you can locate that root cause.

@terrytangyuan terrytangyuan added good first issue Good for newcomers help wanted and removed triage good first issue Good for newcomers labels Nov 29, 2021
@terrytangyuan
Copy link
Member

cc @flaviuvadan since you have fixed a similar issue in Hera.

@terrytangyuan terrytangyuan changed the title use python client run example Invalid value type in api response ['received_data']['status'] Dec 9, 2021
@flaviuvadan
Copy link
Contributor

@66li try to submit it with:

api_response = api_instance.workflow_service_create_workflow(
	namespace='argo',
	body=IoArgoprojWorkflowV1alpha1WorkflowCreateRequest(
		workflow=manifest, _check_return_type=False))

@terrytangyuan terrytangyuan added the solution/workaround There's a workaround, might not be great, but exists label Dec 15, 2021
sarabala1979 pushed a commit that referenced this issue Jan 6, 2022
@dixon1e
Copy link

dixon1e commented Jan 28, 2022

Just a quick heads up. I was demonstrating to someone and decided to run this code again, including the line:

body=IoArgoprojWorkflowV1alpha1WorkflowCreateRequest(workflow=manifest, _check_return_type=False, _check_type=False))

But I received the same error as the original reporter. This is the example code from the repo:

#!/usr/bin/env python
#import json
from pprint import pprint

import argo_workflows
from argo_workflows.api import workflow_service_api
from argo_workflows.model.io_argoproj_workflow_v1alpha1_workflow_create_request import \
    IoArgoprojWorkflowV1alpha1WorkflowCreateRequest
import requests
import yaml

configuration = argo_workflows.Configuration(host="https://127.0.0.1:2746")
configuration.verify_ssl = False

resp = requests.get('https://raw.githubusercontent.com/argoproj/argo-workflows/master/examples/hello-world.yaml')
manifest = yaml.safe_load(resp.text)
# print(json.dumps(manifest, indent=4))

api_client = argo_workflows.ApiClient(configuration)
api_instance = workflow_service_api.WorkflowServiceApi(api_client)

api_response = api_instance.create_workflow(
    namespace='argo',
    body=IoArgoprojWorkflowV1alpha1WorkflowCreateRequest(workflow=manifest, _check_return_type=False, _check_type=False))
pprint(api_response)

To recreate, perhaps this script can help do it quickly:

#!/bin/bash
python3 -m venv venv3
. ./venv3/bin/activate
pip install -U pip
pip install \
    wheel \
    requests \
    pyyaml \
    git+https://github.com/argoproj/argo-workflows@master#subdirectory=sdks/python/client
#
python example.py

I am hopeful there is simply a step I missed somewhere.

@terrytangyuan
Copy link
Member

@flaviuvadan Could you double-check on this when you start migrating to the new SDK?

@flaviuvadan
Copy link
Contributor

Hey @dixon1e! I think the call should be:

api_response = api_instance.create_workflow(
    namespace='argo',
    body=IoArgoprojWorkflowV1alpha1WorkflowCreateRequest(workflow=manifest, _check_type=False), _check_return_type=False)

The _check_return_type=False goes on the create_workflow call rather than the body specification.

@dixon1e
Copy link

dixon1e commented Feb 2, 2022

@flaviuvadan I will check ASAP.

@terrytangyuan
Copy link
Member

Great catch! I am fixing the examples in #7731.

@dixon1e
Copy link

dixon1e commented Feb 2, 2022

Confirmed moving the parameters to the correct call removes the error. The code we (@66li and I) used is the example code in the README, specifically argo-workflows/sdks/python/README.md.

EDIT: I see @terrytangyuan has fixed the doco, well done.

@terrytangyuan
Copy link
Member

Great to hear. Thanks for spotting it @dixon1e and @flaviuvadan for taking a quick look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdks solution/workaround There's a workaround, might not be great, but exists type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants