openfisca / openfisca-core

OpenFisca core engine. See other repositories for countries-specific code & data.
https://openfisca.org
GNU Affero General Public License v3.0
170 stars 75 forks source link

`openfisca serve` not working in repl.it #1082

Open liamdmccann opened 3 years ago

liamdmccann commented 3 years ago

Hi there!

I really enjoy OpenFisca, but I recently encountered an issue.

Here is what I did:

I've got an openfisca instance, openfisca_nsw_safeguard, hosted in a repl.it instance. After make installing the instance, I

  1. ran the command openfisca serve, and then
  2. when that failed, ran the command openfisca serve --country-package openfisca_nsw_safeguard.

Here is what I expected to happen:

I expected openfisca-serve to provide the functionality detailed on the openfisca-serve page on the OF wiki.

As openfisca_nsw_safeguard has (thousands of!) variables in it, I was expecting this to work no issue.

Here is what actually happened:

For 1. ran the command openfisca serve I received the following error:

openfisca serve
[2021-11-03 08:35:32 +0000] [112] [INFO] Starting gunicorn 20.1.0
[2021-11-03 08:35:32 +0000] [112] [INFO] Listening at: http://127.0.0.1:5000 (112)
[2021-11-03 08:35:32 +0000] [112] [INFO] Using worker: sync
[2021-11-03 08:35:32 +0000] [120] [INFO] Booting worker with pid: 120
[2021-11-03 08:35:32 +0000] [121] [INFO] Booting worker with pid: 121
Several country packages detected : `openfisca_nsw_base, openfisca_nsw_safeguard`. Using `openfisca_nsw_base` by default. To use another package, please use the --country-package option.
[2021-11-03 08:35:32 +0000] [122] [INFO] Booting worker with pid: 122
Several country packages detected : `openfisca_nsw_base, openfisca_nsw_safeguard`. Using `openfisca_nsw_base` by default. To use another package, please use the --country-package option.
[2021-11-03 08:35:32 +0000] [120] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/scripts/serve.py", line 80, in load
    return create_app(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/app.py", line 63, in create_app
    data = build_data(tax_benefit_system)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/__init__.py", line 22, in build_data
    data['openAPI_spec'] = build_openAPI_specification(data)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/spec.py", line 50, in build_openAPI_specification
    variable_example = next(iter(api_data['variables'].values()))
StopIteration
[2021-11-03 08:35:32 +0000] [120] [INFO] Worker exiting (pid: 120)
Several country packages detected : `openfisca_nsw_base, openfisca_nsw_safeguard`. Using `openfisca_nsw_base` by default. To use another package, please use the --country-package option.
[2021-11-03 08:35:33 +0000] [121] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/scripts/serve.py", line 80, in load
    return create_app(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/app.py", line 63, in create_app
    data = build_data(tax_benefit_system)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/__init__.py", line 22, in build_data
    data['openAPI_spec'] = build_openAPI_specification(data)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/spec.py", line 50, in build_openAPI_specification
    variable_example = next(iter(api_data['variables'].values()))
StopIteration
[2021-11-03 08:35:33 +0000] [121] [INFO] Worker exiting (pid: 121)
[2021-11-03 08:35:33 +0000] [112] [WARNING] Worker with pid 121 was terminated due to signal 15
[2021-11-03 08:35:33 +0000] [122] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/scripts/serve.py", line 80, in load
    return create_app(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/app.py", line 63, in create_app
    data = build_data(tax_benefit_system)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/__init__.py", line 22, in build_data
    data['openAPI_spec'] = build_openAPI_specification(data)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/spec.py", line 50, in build_openAPI_specification
    variable_example = next(iter(api_data['variables'].values()))
StopIteration
[2021-11-03 08:35:33 +0000] [122] [INFO] Worker exiting (pid: 122)
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 209, in run
    self.sleep()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 357, in sleep
    ready = select.select([self.PIPE[0]], [], [], 1.0)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
    self.reap_workers()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, 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 "/opt/virtualenvs/python3/bin/openfisca", line 8, in <module>
    sys.exit(main())
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_core/scripts/openfisca_command.py", line 65, in main
    return sys.exit(main(parser))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/scripts/serve.py", line 97, in main
    OpenFiscaWebAPIApplication(configuration).run()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 229, in run
    self.halt(reason=inst.reason, exit_status=inst.exit_status)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 342, in halt
    self.stop()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 393, in stop
    time.sleep(0.1)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
    self.reap_workers()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

_For 2. ran the command openfisca serve --country-package openfisca_nswsafeguard.

 openfisca serve --country-package openfisca_nsw_safeguard
[2021-11-03 08:36:51 +0000] [165] [INFO] Starting gunicorn 20.1.0
[2021-11-03 08:36:51 +0000] [165] [INFO] Listening at: http://127.0.0.1:5000 (165)
[2021-11-03 08:36:51 +0000] [165] [INFO] Using worker: sync
[2021-11-03 08:36:51 +0000] [173] [INFO] Booting worker with pid: 173
[2021-11-03 08:36:51 +0000] [174] [INFO] Booting worker with pid: 174
[2021-11-03 08:36:51 +0000] [175] [INFO] Booting worker with pid: 175
[2021-11-03 08:37:11 +0000] [173] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/scripts/serve.py", line 80, in load
    return create_app(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/app.py", line 63, in create_app
    data = build_data(tax_benefit_system)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/__init__.py", line 22, in build_data
    data['openAPI_spec'] = build_openAPI_specification(data)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/spec.py", line 42, in build_openAPI_specification
    parameter_example = api_data['parameters'][parameter_path]
KeyError: 'active_kids/min_age'
[2021-11-03 08:37:11 +0000] [173] [INFO] Worker exiting (pid: 173)
[2021-11-03 08:37:11 +0000] [175] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/scripts/serve.py", line 80, in load
    return create_app(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/app.py", line 63, in create_app
    data = build_data(tax_benefit_system)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/__init__.py", line 22, in build_data
    data['openAPI_spec'] = build_openAPI_specification(data)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/spec.py", line 42, in build_openAPI_specification
    parameter_example = api_data['parameters'][parameter_path]
KeyError: 'active_kids/min_age'
[2021-11-03 08:37:11 +0000] [175] [INFO] Worker exiting (pid: 175)
[2021-11-03 08:37:12 +0000] [165] [WARNING] Worker with pid 175 was terminated due to signal 15
[2021-11-03 08:37:12 +0000] [174] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/scripts/serve.py", line 80, in load
    return create_app(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/app.py", line 63, in create_app
    data = build_data(tax_benefit_system)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/__init__.py", line 22, in build_data
    data['openAPI_spec'] = build_openAPI_specification(data)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/loader/spec.py", line 42, in build_openAPI_specification
    parameter_example = api_data['parameters'][parameter_path]
KeyError: 'active_kids/min_age'
[2021-11-03 08:37:12 +0000] [174] [INFO] Worker exiting (pid: 174)
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 209, in run
    self.sleep()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 357, in sleep
    ready = select.select([self.PIPE[0]], [], [], 1.0)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
    self.reap_workers()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, 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 "/opt/virtualenvs/python3/bin/openfisca", line 8, in <module>
    sys.exit(main())
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_core/scripts/openfisca_command.py", line 65, in main
    return sys.exit(main(parser))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/openfisca_web_api/scripts/serve.py", line 97, in main
    OpenFiscaWebAPIApplication(configuration).run()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 229, in run
    self.halt(reason=inst.reason, exit_status=inst.exit_status)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 342, in halt
    self.stop()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 393, in stop
    time.sleep(0.1)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
    self.reap_workers()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

Here is data (or links to it) that can help you reproduce this issue:

The openfisca_nsw_safeguard repo is available here.

This repo pulls from openfisca_nsw_base, available here.

For your convenience, a multiplayer repl with the Safeguard repo is available here.

Let me know if you need any additional information. Thanks!

Context

I identify more as a:

(remove this line as well as all items in the list that don't fit your situation)

MattiSG commented 3 years ago

Thanks @liamdmccann for this issue!

Do you confirm that you get the same setup working locally, and that this failure happens only when you use repl.it? 🙂