python-microservices / microservices-scaffold Goto Github PK
View Code? Open in Web Editor NEWBarebone Python Microservices with Flask
Home Page: https://python-microservices.github.io/scaffold/
License: GNU General Public License v3.0
Barebone Python Microservices with Flask
Home Page: https://python-microservices.github.io/scaffold/
License: GNU General Public License v3.0
Related to #218
Migrate tests.sh
#!/bin/sh
coverage erase
tox
coverage combine
coverage report -m
coverage html
pylint project/* > pylintReport.txt
to a Makefile, in example:
linter:
pylint project/* > pylintReport.txt
test:
export CONFIGMAP_FILE=tests/config-tests.yml
pytest
coverage:
coverage erase
pytest ...
coverage combine
Hi,
I'm trying to run your app in a docker container given your instructions, but it fails at run step.
The full run log is as below, you can see the error in the last line as well.
[2020-08-10 15:04:34 +0000] [1] [INFO] Starting gunicorn 19.7.1
[2020-08-10 15:04:34 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
[2020-08-10 15:04:34 +0000] [1] [INFO] Using worker: sync
[2020-08-10 15:04:34 +0000] [8] [INFO] Booting worker with pid: 8
[2020-08-10 15:04:34 +0000] [9] [INFO] Booting worker with pid: 9
[2020-08-10 15:04:34 +0000] [10] [INFO] Booting worker with pid: 10
[2020-08-10 15:04:34 +0000] [18] [INFO] Booting worker with pid: 18
[2020-08-10 15:04:34 +0000] [27] [INFO] Booting worker with pid: 27
[2020-08-10 15:04:34 +0000] [31] [INFO] Booting worker with pid: 31
[2020-08-10 15:04:34 +0000] [33] [INFO] Booting worker with pid: 33
[2020-08-10 15:04:34 +0000] [38] [INFO] Booting worker with pid: 38
ERROR:connexion.apis.abstract:Failed to add operation for POST /template/actors
[2020-08-10 15:04:38 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 209, in add_paths
self.add_operation(path, method)
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 173, in add_operation
pass_context_arg_name=self.pass_context_arg_name
File "/usr/local/lib/python3.6/site-packages/connexion/operations/__init__.py", line 8, in make_operation
return spec.operation_cls.from_spec(spec, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/connexion/operations/swagger2.py", line 137, in from_spec
**kwargs
File "/usr/local/lib/python3.6/site-packages/connexion/operations/swagger2.py", line 96, in __init__
pass_context_arg_name=pass_context_arg_name
File "/usr/local/lib/python3.6/site-packages/connexion/operations/abstract.py", line 96, in __init__
self._resolution = resolver.resolve(self)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 40, in resolve
return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 64, in resolve_function_from_operation_id
raise ResolverError(msg, sys.exc_info())
connexion.exceptions.ResolverError: <ResolverError: Cannot resolve operationId "project.actors.post"! Import error was "No module named 'project.actors'">
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
File "/microservice/manage.py", line 6, in <module>
app = create_app()
File "/microservice/project/app.py", line 82, in create_app
return ms.create_app()
File "/usr/local/lib/python3.6/site-packages/pyms/flask/app/create_app.py", line 214, in create_app
self.application = self.init_app()
File "/usr/local/lib/python3.6/site-packages/pyms/flask/app/create_app.py", line 179, in init_app
application = self.swagger.init_app(config=self.config.to_flask(), path=self.path)
File "/usr/local/lib/python3.6/site-packages/pyms/flask/services/swagger.py", line 76, in init_app
app.add_api(**params)
File "/usr/local/lib/python3.6/site-packages/connexion/apps/flask_app.py", line 57, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "/usr/local/lib/python3.6/site-packages/connexion/apps/abstract.py", line 156, in add_api
options=api_options.as_dict())
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 111, in __init__
self.add_paths()
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 216, in add_paths
self._handle_add_operation_error(path, method, err.exc_info)
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 231, in _handle_add_operation_error
raise value.with_traceback(traceback)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 61, in resolve_function_from_operation_id
return self.function_resolver(operation_id)
File "/usr/local/lib/python3.6/site-packages/connexion/utils.py", line 123, in get_function_from_name
raise last_import_error
File "/usr/local/lib/python3.6/site-packages/connexion/utils.py", line 111, in get_function_from_name
module = importlib.import_module(module_name)
File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'project.actors'
[2020-08-10 15:04:38 +0000] [8] [INFO] Worker exiting (pid: 8)
ERROR:connexion.apis.abstract:Failed to add operation for POST /template/actors
[2020-08-10 15:04:38 +0000] [9] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 209, in add_paths
self.add_operation(path, method)
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 173, in add_operation
pass_context_arg_name=self.pass_context_arg_name
File "/usr/local/lib/python3.6/site-packages/connexion/operations/__init__.py", line 8, in make_operation
return spec.operation_cls.from_spec(spec, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/connexion/operations/swagger2.py", line 137, in from_spec
**kwargs
File "/usr/local/lib/python3.6/site-packages/connexion/operations/swagger2.py", line 96, in __init__
pass_context_arg_name=pass_context_arg_name
File "/usr/local/lib/python3.6/site-packages/connexion/operations/abstract.py", line 96, in __init__
self._resolution = resolver.resolve(self)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 40, in resolve
return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 64, in resolve_function_from_operation_id
raise ResolverError(msg, sys.exc_info())
connexion.exceptions.ResolverError: <ResolverError: Cannot resolve operationId "project.actors.post"! Import error was "No module named 'project.actors'">
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
File "/microservice/manage.py", line 6, in <module>
app = create_app()
File "/microservice/project/app.py", line 82, in create_app
return ms.create_app()
File "/usr/local/lib/python3.6/site-packages/pyms/flask/app/create_app.py", line 214, in create_app
self.application = self.init_app()
File "/usr/local/lib/python3.6/site-packages/pyms/flask/app/create_app.py", line 179, in init_app
application = self.swagger.init_app(config=self.config.to_flask(), path=self.path)
File "/usr/local/lib/python3.6/site-packages/pyms/flask/services/swagger.py", line 76, in init_app
app.add_api(**params)
File "/usr/local/lib/python3.6/site-packages/connexion/apps/flask_app.py", line 57, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "/usr/local/lib/python3.6/site-packages/connexion/apps/abstract.py", line 156, in add_api
options=api_options.as_dict())
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 111, in __init__
self.add_paths()
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 216, in add_paths
self._handle_add_operation_error(path, method, err.exc_info)
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 231, in _handle_add_operation_error
raise value.with_traceback(traceback)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 61, in resolve_function_from_operation_id
return self.function_resolver(operation_id)
File "/usr/local/lib/python3.6/site-packages/connexion/utils.py", line 123, in get_function_from_name
raise last_import_error
File "/usr/local/lib/python3.6/site-packages/connexion/utils.py", line 111, in get_function_from_name
module = importlib.import_module(module_name)
File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'project.actors'
[2020-08-10 15:04:38 +0000] [9] [INFO] Worker exiting (pid: 9)
ERROR:connexion.apis.abstract:Failed to add operation for POST /template/actors
[2020-08-10 15:04:38 +0000] [10] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 209, in add_paths
self.add_operation(path, method)
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 173, in add_operation
pass_context_arg_name=self.pass_context_arg_name
File "/usr/local/lib/python3.6/site-packages/connexion/operations/__init__.py", line 8, in make_operation
return spec.operation_cls.from_spec(spec, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/connexion/operations/swagger2.py", line 137, in from_spec
**kwargs
File "/usr/local/lib/python3.6/site-packages/connexion/operations/swagger2.py", line 96, in __init__
pass_context_arg_name=pass_context_arg_name
File "/usr/local/lib/python3.6/site-packages/connexion/operations/abstract.py", line 96, in __init__
self._resolution = resolver.resolve(self)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 40, in resolve
return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 64, in resolve_function_from_operation_id
raise ResolverError(msg, sys.exc_info())
connexion.exceptions.ResolverError: <ResolverError: Cannot resolve operationId "project.actors.post"! Import error was "No module named 'project.actors'">
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
File "/microservice/manage.py", line 6, in <module>
app = create_app()
File "/microservice/project/app.py", line 82, in create_app
return ms.create_app()
File "/usr/local/lib/python3.6/site-packages/pyms/flask/app/create_app.py", line 214, in create_app
self.application = self.init_app()
File "/usr/local/lib/python3.6/site-packages/pyms/flask/app/create_app.py", line 179, in init_app
application = self.swagger.init_app(config=self.config.to_flask(), path=self.path)
File "/usr/local/lib/python3.6/site-packages/pyms/flask/services/swagger.py", line 76, in init_app
app.add_api(**params)
File "/usr/local/lib/python3.6/site-packages/connexion/apps/flask_app.py", line 57, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "/usr/local/lib/python3.6/site-packages/connexion/apps/abstract.py", line 156, in add_api
options=api_options.as_dict())
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 111, in __init__
self.add_paths()
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 216, in add_paths
self._handle_add_operation_error(path, method, err.exc_info)
File "/usr/local/lib/python3.6/site-packages/connexion/apis/abstract.py", line 231, in _handle_add_operation_error
raise value.with_traceback(traceback)
File "/usr/local/lib/python3.6/site-packages/connexion/resolver.py", line 61, in resolve_function_from_operation_id
return self.function_resolver(operation_id)
File "/usr/local/lib/python3.6/site-packages/connexion/utils.py", line 123, in get_function_from_name
raise last_import_error
File "/usr/local/lib/python3.6/site-packages/connexion/utils.py", line 111, in get_function_from_name
module = importlib.import_module(module_name)
File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'project.actors'
[2020-08-10 15:04:38 +0000] [10] [INFO] Worker exiting (pid: 10)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 209, in run
self.sleep()
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 359, in sleep
ready = select.select([self.PIPE[0]], [], [], 1.0)
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 244, in handle_chld
self.reap_workers()
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 524, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 8, in <module>
sys.exit(run())
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 203, in run
super(Application, self).run()
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 231, in run
self.halt(reason=inst.reason, exit_status=inst.exit_status)
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 344, in halt
self.stop()
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 393, in stop
time.sleep(0.1)
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 244, in handle_chld
self.reap_workers()
File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 524, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
Python and pip updated. Appreciate your help.
i couldn't find the requirements.txt file ?
Open discussion:
Describe the bug
There is a wrong DB connection string in the docker config resulting in an empty model (e.g [])
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expected output is a json containing a list of films but the list is empty.
Desktop (please complete the following information):
Related to #215
Describe the bug
Docker image keeps failing to build
To Reproduce
Steps to reproduce the behavior:
docker build .
or docker build ./
to build a docker imageRUN cd /tmp && pipenv install --system
: An error occurred while installing cryptography==3.4.7; python_version >= '3.6'...Expected behavior
Docker image should build without any errors
Desktop (please complete the following information):
Additional context
None.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.