Flask-AppBuilder icon indicating copy to clipboard operation
Flask-AppBuilder copied to clipboard

Add support for marshmallow-sqlalchemy 1.0.0

Open AlphaJack opened this issue 1 year ago • 4 comments

Environment

pip-freeze:

Flask==2.3.3
Flask-AppBuilder==4.3.11
flask-babel==3.1.0
Flask-Caching==2.0.2
Flask-Compress==1.14
Flask-JWT-Extended==4.5.3
Flask-Limiter==3.5.0
Flask-Login==0.6.3
Flask-Migrate==4.0.5
Flask-OpenID==1.3.0
Flask-Session==0.6.0
Flask-Sockets==0.2.1
Flask-SQLAlchemy==2.5.1
flask-talisman==1.1.0
Flask-WTF==1.1.1
marshmallow==3.20.0
marshmallow-sqlalchemy==1.0.0

Describe the expected results

I am getting a TypeError during the initialization of an app that loads Flask-AppBuilder (see below).

I have tried both marshmallow-sqlalchemy 1.0.0, 0.30 and 0.26, but all of them returns the same results.

I am not sure the error involves Flask-AppBuilder directly, but I wanted to check why there is no support for the latest version of marshmallow-sqlalchemy.

Describe the actual results

When launching the app, I get

Traceback (most recent call last):
  File "/usr/bin/superset", line 5, in <module>
    from superset.cli.main import superset
  File "/usr/lib/python3.11/site-packages/superset/__init__.py", line 21, in <module>
    from superset.app import create_app
  File "/usr/lib/python3.11/site-packages/superset/app.py", line 24, in <module>
    from superset.initialization import SupersetAppInitializer
  File "/usr/lib/python3.11/site-packages/superset/initialization/__init__.py", line 28, in <module>
    from flask_appbuilder import expose, IndexView
  File "/usr/lib/python3.11/site-packages/flask_appbuilder/__init__.py", line 5, in <module>
    from .api import ModelRestApi  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/flask_appbuilder/api/__init__.py", line 29, in <module>
    from marshmallow_sqlalchemy.fields import Related, RelatedList
  File "/usr/lib/python3.11/site-packages/marshmallow_sqlalchemy/__init__.py", line 1, in <module>
    from .schema import (
  File "/usr/lib/python3.11/site-packages/marshmallow_sqlalchemy/schema.py", line 143, in <module>
    class SQLAlchemySchema(
  File "/usr/lib/python3.11/site-packages/marshmallow/schema.py", line 116, in __new__
    klass._declared_fields = mcs.get_declared_fields(
                             ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: SQLAlchemySchemaMeta.get_declared_fields() missing 1 required positional argument: 'dict_cls'

Steps to reproduce

on Arch Linux/Manjaro: yay -S superset && superset --help

AlphaJack avatar Feb 09 '24 17:02 AlphaJack

This also prevents Flask-Appbuilder from being compatible with marshmallow>=3.24.0, which caused a regression in Airflow. See https://github.com/apache/airflow/pull/45442#issuecomment-2578324005

sloria avatar Jan 08 '25 19:01 sloria

@AlphaJack actually, the error you're seeing was fixed in marshmallow 3.20.1. so you should be able to update your marshmallow version to resolve that.

Flask-Appbuilder should still support newer versions of marshmallow-sqlalchemy (this will fix the Airflow issue), which i think is just a matter of relaxing the version constraint here: https://github.com/dpgaspar/Flask-AppBuilder/blob/418ab8a93907669be4ccbb99d7aefa5283f3e013/setup.py#L61

that should be changed to either "marshmallow-sqlalchemy>=0.22.0, <2.0.0" or "marshmallow-sqlalchemy>=0.22.0".

@dpgaspar can you please make this change? i was going to send a PR but i've been having issues getting my development environment working (pip-compile isn't cooperating 😕 )

sloria avatar Jan 08 '25 19:01 sloria

sent #2298

sloria avatar Jan 08 '25 20:01 sloria

Nice one !

potiuk avatar Jan 08 '25 22:01 potiuk