Hi,

I would also like to help. I took a stab at it and want to share something. We
Need to Be Careful about SQLAlchemy 2.0 Typing

The Problem in Simple Terms :

We're upgrading our SQLAlchemy models to use modern typing, but it's not as
simple as changing a few lines of code. Here's why:

*Old style (what we have now):*

my_date = Column(DateTime)  # Type checker sees this as Column[Any], not
datetime

*New style (where we need to go):*

my_date: Mapped[datetime | None] = mapped_column(DateTime)  # Type checker
understands this correctly

When we mix old and new styles during migration (say TaskInstance is mapped
and DagRun is not) Our type checker (mypy) gets confused and reports errors
in code that actually works fine.

We can:

   -

   Ignore the error checks (do selective type checking)
   -

   Do a casting (Temporarily tells mypy to treat a legacy `Column[Any]` as
   the correct type)
   -

   Make some interface class, perhaps?


Thanks,
- Avi

On Wed, May 7, 2025 at 9:13 AM Ankit Chaurasia <sunank...@gmail.com> wrote:

> Hi Jarek, I would like to help with the migration work as well.
>
> Regards
> *Ankit Chaurasia*
>
>
>
>
>
> On Wed, May 7, 2025 at 2:51 PM Jarek Potiuk <ja...@potiuk.com> wrote:
>
> > Fantastic - thanks Ephraim - I might wait for Vincents' ok and we can
> form
> > a small task force to do it :)
> >
> > wt., 6 maj 2025, 13:10 użytkownik Ephraim Anierobi <
> > ephraimanier...@gmail.com> napisał:
> >
> > > Hi Jarek, I can help with the migration
> > >
> > > On Tue, 6 May 2025 at 11:02, Avi <a...@astronomer.io.invalid> wrote:
> > >
> > > > I think it is a good time to revisit
> > > > https://github.com/apache/airflow/issues/28723
> > > > - Avi
> > > >
> > > > On Tue, May 6, 2025 at 8:17 AM Jarek Potiuk <ja...@potiuk.com>
> wrote:
> > > >
> > > > > Just copying it from the Slack message - devlist seems to be more
> > > > > appropriate :).
> > > > >
> > > > > We got informed by Daniel Gaspar from Superset that he is gearing
> for
> > > > > release of FAB 5.0.0 - and asked us to test a8 release
> > > > > https://pypi.org/project/Flask-AppBuilder/5.0.0a8/ - which should
> -
> > in
> > > > > principle - unblock us from migrating to SQLAlchemy 2.
> > > > >
> > > > > I looked at what is needed and we need to do it in two steps.
> > > > >
> > > > > Step 1: Migrate to 4.6.2 version of FAB -> FAB 4.6.2 added Group
> > > support
> > > > > (which generally is something that might be useful for us as well -
> > and
> > > > > highly requested feature
> > > > >
> > > > > Step 2: Test and migrate to SQLAlchemy 2
> > > > >
> > > > > And I think it's best it's done with Vincent and maybe someone from
> > > > > Astronomer who knows more about Sqlalchemy and data migration than
> me
> > > - I
> > > > > am happy to participate and review, but I do not feel competent to
> > > > > implement the changes - I've never added any migration or
> SQLAlchemy
> > > > model.
> > > > > Unfortunately this requires far more than copy & pasting pieces of
> > > > > vendored-in FAB security manager.
> > > > >
> > > > > Years ago a decision was made that we vendor-in part of the code of
> > > FAB -
> > > > > and part of it is vendoring in models and migration and we need to
> > > follow
> > > > > that - unfortunately.
> > > > > It does not seem a lot of work, but I am afraid I only know
> > SQLalchemy
> > > > on a
> > > > > very surface - there is literally one model (Group) to add and some
> > > code
> > > > to
> > > > > handle it - including migrations, but also testing the new group
> > > feature
> > > > of
> > > > > FAB and how it integrates with Airflow is a bit more complex than
> > just
> > > > "new
> > > > > FAB version migration".
> > > > >
> > > > > I created a small task for it - without too many details - but I
> > think
> > > we
> > > > > need a small team (I guess Vincent is the most natural candidate +
> > > > someone
> > > > > from Astro about migrations and SQLAlchemy) who could implement and
> > > test
> > > > > this change. I am happy to review, help to make decisions and
> discuss
> > > it
> > > > > and get the dependencies sorted out.
> > > > >
> > > > > https://github.com/apache/airflow/issues/50186
> > > > >
> > > > > One of the things it will unblock finally if we get to 5.0.0 is PRs
> > > like
> > > > > that https://github.com/apache/airflow/pull/50221 where we cannot
> > bump
> > > > the
> > > > > min version of sendgrid because it conflicts with the infamous
> > Werkzeug
> > > > > versions that old FAB depends on.
> > > > >
> > > > > WDYT? Can we get a small group of people around that task to do it
> > > > > "properly"? It would be great to have it as a 3.1.0 deliverable to
> > > > finally
> > > > > cut all our ties with the old FAB things.
> > > > >
> > > > > J
> > > > >
> > > >
> > >
> >
>

Reply via email to