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

Make _get_ti compatible with RPC #38570

Merged

Conversation

dstandish
Copy link
Contributor

@dstandish dstandish commented Mar 27, 2024

Ok, taking yet another approach with this.

It turns out there was a non-obvious 4th usage of session in this function, so I went back to trying to make it an RPC call.

The problem is, we don't have a TaskPydantic model, and when you serialize an operator object it doesn't really do it properly because it doesn't "encode" it i.e. it doesn't add the TYPE var so the receiver has no idea what the object is. This, I assume, is because historically an operator was always only serialized as part of another object.

What I did to "fix" this is I make base serialization serialize operator objects "properly", i.e. running through _encode.

This necessitated a change to the way SerDag deserializes its tasks.

The other wonky thing here is that we expect (somewhere in the execution process) the task object on a TI to also have a dag, which, happens to get lost in serialization (and yeah, would be a bit reduntant perhaps to include that when serializing DAG for example... think the DAG ser'd on each task....), so what I do is add it back after the TI comes back through the RPC.... It's a bit of a mess but that's kind of where we're at.

Please give it a look when you can @uranusjr @potiuk and let me know what you think of the approach. I suspect there will be a test failure or two that I have to correct with this change.

Orig:
The only usages of the provided session in this function are calls to other funcs which are also decorated with provide_session, and which are already RPC calls. There does not seem to be a reason that they all need to be in the same session. So we should be able to simply remove this decorator, thus making this function AIP-44 compatible.

@eladkal eladkal added this to the Airflow 2.9.0 milestone Mar 28, 2024
Copy link
Collaborator

@dirrao dirrao left a comment

Choose a reason for hiding this comment

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

Some test cases are failing.

@dstandish dstandish force-pushed the remove-@provide_session-from-_get_ti branch from 7010ca5 to b317209 Compare April 1, 2024 22:20
@dstandish dstandish requested a review from XD-DENG as a code owner April 1, 2024 22:20
@dstandish dstandish force-pushed the remove-@provide_session-from-_get_ti branch 2 times, most recently from c9809df to 181c0fe Compare April 1, 2024 23:14
@dstandish dstandish changed the title Remove @provide_session from _get_ti Make _get_ti compatible with RPC Apr 1, 2024
@dstandish dstandish force-pushed the remove-@provide_session-from-_get_ti branch from 181c0fe to 942d63f Compare April 2, 2024 16:30
@dstandish dstandish force-pushed the remove-@provide_session-from-_get_ti branch 2 times, most recently from f0b1cbd to 22e9a5f Compare April 2, 2024 17:47
@dstandish dstandish force-pushed the remove-@provide_session-from-_get_ti branch from d88aa3f to b6fbc74 Compare April 4, 2024 20:57
@dstandish dstandish force-pushed the remove-@provide_session-from-_get_ti branch from b6fbc74 to 285cb7c Compare April 9, 2024 05:31
Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

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

If this works.

The only usages of the provided session in this function are calls to other funcs which are also decorated with provide_session, and which are already RPC calls. There does not seem to be a reason that they all need to be in the same session.  So we should be able to simply remove this decorator, thus making this function AIP-44 compatible.
@dstandish dstandish force-pushed the remove-@provide_session-from-_get_ti branch from 285cb7c to 0046643 Compare April 9, 2024 14:57
@dstandish dstandish merged commit 0af5d92 into apache:main Apr 9, 2024
41 checks passed
@dstandish dstandish deleted the remove-@provide_session-from-_get_ti branch April 9, 2024 23:34
utkarsharma2 pushed a commit to astronomer/airflow that referenced this pull request Apr 22, 2024
This is for AIP-44.  I had to pull out the "db access" parts from `_get_ti` and move them to RPC function `_get_ti_db_access`.  To make that work, I also had to ensure that "task" objects (a.k.a. instances of AbstractOperator) can properly be roundtripped with BaseSerialization.serialize.  Up to now they could not be, and they were "manually" serialized as part of SerializedDAG.  This changes a bit the way we serialize task objects and so we had to handle backcompat and update a fair amount of tests.
@utkarsharma2 utkarsharma2 added changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) type:improvement Changelog: Improvements and removed changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants