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

App fails with error "Passing keyword arguments to inject is no longer supported" #3

Open
evndean opened this issue Oct 10, 2017 · 4 comments

Comments

@evndean
Copy link

evndean commented Oct 10, 2017

I'm getting the following error when trying to run docker-compose up:

Attaching to pythonflaskmicroservice_elasticsearch_1, pythonflaskmicroservice_rabbitmq_1, pythonflaskmicroservice_our-app_1
our-app_1        | Failed to add operation for POST /1.0/room/
our-app_1        | Traceback (most recent call last):
our-app_1        |   File "/code/app.py", line 31, in <module>
our-app_1        |     app.add_api('indexer.yaml', resolver=RestyResolver('api'))
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/apps/flask_app.py", line 54, in add_api
our-app_1        |     api = super(FlaskApp, self).add_api(specification, **kwargs)
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/apps/abstract.py", line 159, in add_api
our-app_1        |     options=api_options.as_dict())
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 131, in __init__
our-app_1        |     self.add_paths()
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 252, in add_paths
our-app_1        |     self._handle_add_operation_error(path, method, sys.exc_info())
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 263, in _handle_add_operation_error
our-app_1        |     six.reraise(*exc_info)
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
our-app_1        |     raise value
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 242, in add_paths
our-app_1        |     self.add_operation(method, path, endpoint, path_parameters)
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 195, in add_operation
our-app_1        |     pythonic_params=self.pythonic_params)
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/operation.py", line 215, in __init__
our-app_1        |     resolution = resolver.resolve(self)
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 40, in resolve
our-app_1        |     return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 62, in resolve_function_from_operation_id
our-app_1        |     return self.function_resolver(operation_id)
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/connexion/utils.py", line 34, in get_function_from_name
our-app_1        |     module = importlib.import_module(module_name)
our-app_1        |   File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
our-app_1        |     return _bootstrap._gcd_import(name[level:], package, level)
our-app_1        |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
our-app_1        |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
our-app_1        |   File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
our-app_1        |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
our-app_1        |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
our-app_1        |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
our-app_1        |   File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
our-app_1        |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
our-app_1        |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
our-app_1        |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
our-app_1        |   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
our-app_1        |   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
our-app_1        |   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
our-app_1        |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
our-app_1        |   File "/code/api/__init__.py", line 1, in <module>
our-app_1        |     from api.room import Room
our-app_1        |   File "/code/api/room.py", line 8, in <module>
our-app_1        |     class Room(object):
our-app_1        |   File "/code/api/room.py", line 9, in Room
our-app_1        |     @inject(indexer=ElasticSearchIndex)
our-app_1        |   File "/usr/local/lib/python3.6/site-packages/injector.py", line 1015, in inject
our-app_1        |     'Passing keyword arguments to inject is no longer supported. '
our-app_1        | AssertionError: Passing keyword arguments to inject is no longer supported. Use inject in combination with parameter annotations to declare dependencies. See documentation for details
pythonflaskmicroservice_our-app_1 exited with code 1
@evndean
Copy link
Author

evndean commented Oct 10, 2017

This is an issue with version Injector, which removed support for passing keyword arguments to @Inject in version 0.13.0 (changelog).

Injector seems to be a dependency of Flask-Injector:

Collecting injector>=0.10.0 (from Flask-Injector->-r requirements.txt (line 3))
  Downloading injector-0.13.1-py2.py3-none-any.whl

I've tried specifying different versions of Flask-Injector in requirements.txt, but the most recent version of Injector always gets installed.

@evndean
Copy link
Author

evndean commented Oct 10, 2017

I was able to resolve this by specifying injector==0.12.0 in requirements.txt.

Attaching to pythonflaskmicroservice_rabbitmq_1, pythonflaskmicroservice_elasticsearch_1, pythonflaskmicroservice_our-app_1
our-app_1        |  * Running on http://0.0.0.0:9090/ (Press CTRL+C to quit)

However, because of #2, I can't verify that any of the routes work.

$ curl http://localhost:9091
{
  "detail": "The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.",
  "status": 404,
  "title": "Not Found",
  "type": "about:blank"
}
$ curl http://localhost:9091/ui
{
  "detail": "The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.",
  "status": 404,
  "title": "Not Found",
  "type": "about:blank"
}
$ curl http://localhost:9091/room
{
  "detail": "The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.",
  "status": 404,
  "title": "Not Found",
  "type": "about:blank"
}

@ssola
Copy link
Owner

ssola commented Oct 24, 2017

Sorry for the delay and thanks for the issue, I will fix it right away!

@JonnyDaenen
Copy link

PR #4 should fix the inject error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants