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

Support @task.bash with Task SDK #45639

Closed
kaxil opened this issue Jan 14, 2025 · 0 comments · Fixed by #48060
Closed

Support @task.bash with Task SDK #45639

kaxil opened this issue Jan 14, 2025 · 0 comments · Fixed by #48060
Assignees
Labels
area:core area:core-operators Operators, Sensors and hooks within Core Airflow area:task-execution-interface-aip72 AIP-72: Task Execution Interface (TEI) aka Task SDK

Comments

@kaxil
Copy link
Member

kaxil commented Jan 14, 2025

@task.bash code currently requires DB interaction as below, we need to remove that and use Task SDK somehow

# TODO: This should be replaced with Task SDK API call
@staticmethod
@provide_session
def refresh_bash_command(ti: TaskInstance, session: SASession = NEW_SESSION) -> None:
"""
Rewrite the underlying rendered bash_command value for a task instance in the metadatabase.
TaskInstance.get_rendered_template_fields() cannot be used because this will retrieve the
RenderedTaskInstanceFields from the metadatabase which doesn't have the runtime-evaluated bash_command
value.
:meta private:
"""
from airflow.models.renderedtifields import RenderedTaskInstanceFields
"""Update rendered task instance fields for cases where runtime evaluated, not templated."""
# Note: Need lazy import to break the partly loaded class loop
from airflow.models.taskinstance import TaskInstance
# If called via remote API the DAG needs to be re-loaded
TaskInstance.ensure_dag(ti, session=session)
rtif = RenderedTaskInstanceFields(ti)
RenderedTaskInstanceFields.write(rtif, session=session)
RenderedTaskInstanceFields.delete_old_records(ti.task_id, ti.dag_id, session=session)

@dosubot dosubot bot added area:core area:core-operators Operators, Sensors and hooks within Core Airflow labels Jan 14, 2025
@vikramkoka vikramkoka added the area:task-execution-interface-aip72 AIP-72: Task Execution Interface (TEI) aka Task SDK label Feb 5, 2025
kaxil added a commit to astronomer/airflow that referenced this issue Mar 21, 2025
kaxil added a commit to astronomer/airflow that referenced this issue Mar 21, 2025
@kaxil kaxil self-assigned this Mar 21, 2025
kaxil added a commit to astronomer/airflow that referenced this issue Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core area:core-operators Operators, Sensors and hooks within Core Airflow area:task-execution-interface-aip72 AIP-72: Task Execution Interface (TEI) aka Task SDK
3 participants