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

upgrade flask-sqlalchemy to 2.5.1 #1

Merged
merged 1 commit into from
Jun 22, 2021

Conversation

bertrandmartel
Copy link
Contributor

After following the instructions in the Readme, I've built and run the docker image. Hitting the API gave me this error:

2021-06-22 12:28:20,643 ERROR app.py:1890 - Exception on /api/v1.0/captcha [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/_collections.py", line 1008, in __call__
    return self.registry[key]
KeyError: <greenlet.greenlet object at 0x7f84bfe7fca0 (otid=0x7f84c100d140) current active started main>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.8/site-packages/flask_restx/api.py", line 375, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask_restx/resource.py", line 44, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/app/captcha_api/rest.py", line 62, in get
    db.session.add(new_captcha)
  File "<string>", line 2, in add
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/scoping.py", line 105, in _proxied
    return self.registry()
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/_collections.py", line 1010, in __call__
    return self.registry.setdefault(key, self.createfunc())
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 4101, in __call__
    return self.class_(**local_kw)
  File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 138, in __init__
    bind = options.pop('bind', None) or db.engine
  File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 943, in engine
    return self.get_engine()
  File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 962, in get_engine
    return connector.get_engine()
  File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 555, in get_engine
    options = self.get_options(sa_url, echo)
  File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 570, in get_options
    self._sa.apply_driver_hacks(self._app, sa_url, options)
  File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 914, in apply_driver_hacks
    sa_url.database = os.path.join(app.root_path, sa_url.database)
AttributeError: can't set attribute

I've found out this issue about sqlAlchemy. Upgrading flask-sqlalchemy to 2.5.1 fixes the error

@saibot94
Copy link
Contributor

Hi, thanks for the contribution!

Looking at things running on our production deployment of the service, I see the following versions:

Flask-SQLAlchemy==2.4.4
SQLAlchemy==1.3.19

According to what you added and the suggestions in the linked issue, I think for now it's safer to just pin the SQLAlchemy version to 1.3.x and not upgrade the Flask-SQLAlchemy.

Could you try it and confirm it's working?

Copy link
Contributor

@saibot94 saibot94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the comment on the PR.

@bertrandmartel
Copy link
Contributor Author

@saibot94 Thanks, yes it works as you suggested

Copy link
Contributor

@saibot94 saibot94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, merging it as such.

@saibot94 saibot94 merged commit 3be825d into CERN:master Jun 22, 2021
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

Successfully merging this pull request may close these issues.

2 participants