Gunicorn SyntaxError в сборке Heroku - PullRequest
0 голосов
/ 11 марта 2019

Я получаю следующую ошибку синтаксиса в моей сборке Heroku, есть какие-либо идеи о том, в чем может быть проблема?Использование Gunicorn 19.9.0

2019-03-10T21:11:24.936875+00:00 heroku[web.1]: Starting process with command `gunicorn main: app.server`
2019-03-10T21:11:27.137010+00:00 heroku[web.1]: State changed from starting to up
2019-03-10T21:11:26.929950+00:00 app[web.1]: [2019-03-10 21:11:26 +0000] [4] [INFO] Starting gunicorn 19.9.0
2019-03-10T21:11:26.930979+00:00 app[web.1]: [2019-03-10 21:11:26 +0000] [4] [INFO] Listening at: http://0.0.0.0:32580 (4)
2019-03-10T21:11:26.931151+00:00 app[web.1]: [2019-03-10 21:11:26 +0000] [4] [INFO] Using worker: sync
2019-03-10T21:11:26.935311+00:00 app[web.1]: [2019-03-10 21:11:26 +0000] [9] [INFO] Booting worker with pid: 9
2019-03-10T21:11:36.572657+00:00 app[web.1]: [2019-03-10 21:11:36 +0000] [9] [ERROR] Exception in worker process
2019-03-10T21:11:36.572690+00:00 app[web.1]: Traceback (most recent call last):
2019-03-10T21:11:36.572693+00:00 app[web.1]: File "/app/.heroku/miniconda/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-03-10T21:11:36.572695+00:00 app[web.1]: worker.init_process()
2019-03-10T21:11:36.572697+00:00 app[web.1]: File "/app/.heroku/miniconda/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-03-10T21:11:36.572699+00:00 app[web.1]: self.load_wsgi()
2019-03-10T21:11:36.572701+00:00 app[web.1]: File "/app/.heroku/miniconda/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-03-10T21:11:36.572702+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-03-10T21:11:36.572704+00:00 app[web.1]: File "/app/.heroku/miniconda/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-03-10T21:11:36.572705+00:00 app[web.1]: self.callable = self.load()
2019-03-10T21:11:36.572707+00:00 app[web.1]: File "/app/.heroku/miniconda/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-03-10T21:11:36.572709+00:00 app[web.1]: return self.load_wsgiapp()
2019-03-10T21:11:36.572710+00:00 app[web.1]: File "/app/.heroku/miniconda/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-03-10T21:11:36.572712+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-03-10T21:11:36.572714+00:00 app[web.1]: File "/app/.heroku/miniconda/lib/python3.6/site-packages/gunicorn/util.py", line 362, in import_app
2019-03-10T21:11:36.572715+00:00 app[web.1]: app = eval(obj, vars(mod))
2019-03-10T21:11:36.572717+00:00 app[web.1]: File "<string>", line 0
2019-03-10T21:11:36.572719+00:00 app[web.1]: 
2019-03-10T21:11:36.572721+00:00 app[web.1]: ^
2019-03-10T21:11:36.572723+00:00 app[web.1]: SyntaxError: unexpected EOF while parsing
2019-03-10T21:11:36.575629+00:00 app[web.1]: [2019-03-10 21:11:36 +0000] [9] [INFO] Worker exiting (pid: 9)
2019-03-10T21:11:36.946391+00:00 app[web.1]: [2019-03-10 21:11:36 +0000] [4] [INFO] Shutting down: Master
2019-03-10T21:11:36.946455+00:00 app[web.1]: [2019-03-10 21:11:36 +0000] [4] [INFO] Reason: Worker failed to boot.
2019-03-10T21:11:37.037342+00:00 heroku[web.1]: State changed from up to crashed
2019-03-10T21:11:37.020575+00:00 heroku[web.1]: Process exited with status 3

Мне нужно matplotlib.use("Agg") для всех matplotlib применений в моем приложении, эта ошибка появляется при добавлении этого в мой код, в противном случае я сталкиваюсь с проблемами, описанными здесь: https://github.com/matplotlib/matplotlib/issues/9954/

РЕДАКТИРОВАТЬ:

Код (main.py):

import dash_core_components as dcc
import dash_html_components as html
import matplotlib
from dash.dependencies import Input, Output

matplotlib.use("Agg")

from app import app
from parameters import material, geometry, settings, mesh_tallies_xsections, runtime, postprocessing

app.layout = html.Div([
    dcc.Location(id='url', refresh=False, pathname='/parameters/material'),

    # TODO: Storage data not persist through pathname change -> storage_type to 'memory' has no effect
    # Materials
    dcc.Store(id='material-stores', storage_type='session'),
    # Geometry
    dcc.Store(id='color-stores', storage_type='session'),
    dcc.Store(id='cell-stores', storage_type='session'),
    dcc.Store(id='injection-stores', storage_type='session'),
    dcc.Store(id='temp-assembly-stores', storage_type='session'),
    dcc.Store(id='assembly-stores', storage_type='session'),
    dcc.Store(id='boundary-stores', storage_type='session'),
    # Mesh
    dcc.Store(id='mesh-stores', storage_type='session'),
    # Scores
    dcc.Store(id='mesh-score-stores', storage_type='session'),
    # Cross-Sections
    dcc.Store(id='xsection-stores', storage_type='session'),
    # Settings
    dcc.Store(id='settings-stores', storage_type='session'),

    dcc.Link('Materials', href='/parameters/material'), html.Br(),
    dcc.Link('Geometry', href='/parameters/geometry'), html.Br(),
    dcc.Link('Mesh, Tallies/Scoring, Cross-sections', href='/parameters/mesh_tallies_xsections'), html.Br(),
    dcc.Link('Settings', href='/parameters/settings'), html.Br(),
    dcc.Link('Verification & Run', href='/parameters/runtime'), html.Br(),
    dcc.Link('Postprocessing', href='/parameters/postprocessing'), html.Br(),

    html.Div(id='page-content'),
])


@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == '/parameters/material':
        return material.layout

    elif pathname == '/parameters/geometry':
        return geometry.layout

    elif pathname == '/parameters/settings':
        return settings.layout

    elif pathname == '/parameters/mesh_tallies_xsections':
        return mesh_tallies_xsections.layout

    elif pathname == '/parameters/runtime':
        return runtime.layout

    elif pathname == '/parameters/postprocessing':
        return postprocessing.layout

    else:
        return '404 Page not Found'


if __name__ == '__main__':
    app.run_server(debug=True)

Код (app.py):

import dash

    external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

    app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
    server = app.server
    app.config.suppress_callback_exceptions = True

* Обратите внимание, что ниже приведены все импорты на уровне модуля: from app import app from parameters import material, geometry, settings, mesh_tallies_xsections, runtime, postprocessing

runtime содержит импорт пакета, который использует matplotlib, что вызывает другую ошибку, не опубликованную здесь.Приложение Dash создает сервер на основе колбы

1 Ответ

0 голосов
/ 11 марта 2019

Не понял, что в web: gunicorn main:app.server нет места жизненно важным, т. Е.

НЕПРАВИЛЬНО: web: gunicorn main: app.server

ПРАВИЛЬНО: web: gunicorn main:app.server

...