apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
36.43k stars 14.11k forks source link

Enable setting pool in the expand method of a dynamic task #33657

Open filipe-alves-itech opened 1 year ago

filipe-alves-itech commented 1 year ago

Description

Allow pools to be set dynamically for each dynamic mapped task index via the expand method as opposed to being limited to the current behaviour that only allows a static definition for all mapped tasks via the partial method.

Use case/motivation

Pools are very useful for having control over resource usage on the backend systems that can oftentimes be overwhelmed by concurrent tasks triggered by Airflow. With dynamic mapped tasks, we can have a scenario where different mapped instances may trigger work in different backend servers and having the ability to set different pools comes in handy allowing control over the number of running tasks for each backend server separately. Dynamic tasks were a game changer allowing to dynamically define parts of the DAG, making it more like a first-class citizen that benefits from the other established Airflow features like pools is another step forward.

Related issues

No response

Are you willing to submit a PR?

Code of Conduct

boring-cyborg[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

potiuk commented 1 year ago

Not sure if that would be easy, but I think there is nothing fundamentally difficult here (I believe it should be quite possible.

potiuk commented 1 year ago

@uranusjr - do you see any fundamental problems with it ? If thera are no fundamental limits (I can't think of any) it could be even fairly easy - and we could mark it as "good first issue" maybe ?

uranusjr commented 1 year ago

I think this is possible in theory, but before this is possible we’d need to first make pool available via XCom without task mapping involved.