runwayml / model-sdk

💥🐍 Runway Model SDK: port your own machine learning models to Runway

Home Page:https://sdk.runwayml.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

POSTing a missing value for a category data_type throws a 500

brannondorsey opened this issue · comments

POSTing a variable for a category data type that isn't in the choices list results in a bombed request. See code notes below.

import runway
from runway.data_types import category

# if no default value is specified, the first element in the choices
# list will be used
cat = category(choices=["rgb", "bgr", "rgba", "bgra"], default="rgba")
@runway.setup(options={ "pixel_order": cat })
def setup(opts):
    print("The selected pixel order is {}".format(opts["pixel_order"]))

runway.run()
curl -H "content-type: application/json" -d '{"pixel_order": "bgr"}' http://localhost:8000/setup # 200 OK
curl -H "content-type: application/json" -d '{"pixel_order": "not_found"}' # 500 Error
The selected pixel order is bgr
127.0.0.1 - - [2019-04-09 10:06:19] "POST /setup HTTP/1.1" 200 165 0.001573
[2019-04-09 10:06:28,616] ERROR in app: Exception on /setup [POST]
Traceback (most recent call last):
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask_Cors-3.0.7-py3.7.egg/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/_compat.py", line 35, in reraise
    raise value
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/Flask-1.0.2-py3.7.egg/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/runway_python-0.0.55-py3.7.egg/runway/model.py", line 44, in setup_route
    self.setup_model(opts)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/runway_python-0.0.55-py3.7.egg/runway/model.py", line 153, in setup_model
    deserialized_opts[name] = opt.deserialize(opts[name])
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/runway_python-0.0.55-py3.7.egg/runway/data_types.py", line 133, in deserialize
    raise InvalidInputError(self.name)
  File "/Users/brannon/Documents/code/runway/rw_python_sdk/venv/lib/python3.7/site-packages/runway_python-0.0.55-py3.7.egg/runway/exceptions.py", line 32, in __init__
    super(MissingInputError, self).__init__()
TypeError: super(type, obj): obj must be an instance or subtype of type
127.0.0.1 - - [2019-04-09 10:06:28] "POST /setup HTTP/1.1" 500 443 0.014482