Skip to content

Commit

Permalink
Replace ti.xcom_pull() in extra link example
Browse files Browse the repository at this point in the history
We don't want to expose TaskInstance(execution_date=...) anymore, but
the extra link interface still relies on execution date, so we need an
alternative.
  • Loading branch information
uranusjr authored and kaxil committed Sep 17, 2021
1 parent c08db80 commit 08c1f51
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/apache-airflow/howto/define_extra_link.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Console, but if we wanted to change that link we could:
from airflow.plugins_manager import AirflowPlugin
from airflow.models.baseoperator import BaseOperatorLink
from airflow.models.xcom import XCom
from airflow.providers.google.cloud.operators.bigquery import BigQueryOperator
# Change from https to http just to display the override
Expand All @@ -136,8 +137,11 @@ Console, but if we wanted to change that link we could:
operators = [BigQueryOperator]
def get_link(self, operator, dttm):
ti = TaskInstance(task=operator, execution_date=dttm)
job_id = ti.xcom_pull(task_ids=operator.task_id, key="job_id")
job_id = XCom.get_one(
execution_date=dttm,
task_id=operator.task_id,
key="job_id",
)
return BIGQUERY_JOB_DETAILS_LINK_FMT.format(job_id=job_id) if job_id else ""
Expand Down

0 comments on commit 08c1f51

Please sign in to comment.