Example #1
0
 def get_link(self, operator, dttm):
     ti = TaskInstance(task=operator, execution_date=dttm)
     operator.render_template_fields(ti.get_template_context())
     query = {
         "dag_id": operator.external_dag_id,
         "execution_date": dttm.isoformat()
     }
     return build_airflow_url_with_query(query)
Example #2
0
    def get_link(self, operator, dttm):
        # Fetch the correct execution date for the triggerED dag which is
        # stored in xcom during execution of the triggerING task.
        trigger_execution_date_iso = XCom.get_one(
            execution_date=dttm, key=XCOM_EXECUTION_DATE_ISO, task_id=operator.task_id, dag_id=operator.dag_id
        )

        query = {"dag_id": operator.trigger_dag_id, "base_date": trigger_execution_date_iso}
        return build_airflow_url_with_query(query)
Example #3
0
    def test_build_airflow_url_with_query(self):
        """
        Test query generated with dag_id and params
        """
        query = {"dag_id": "test_dag", "param": "key/to.encode"}
        expected_url = "/graph?dag_id=test_dag&param=key%2Fto.encode"

        from airflow.www.app import cached_app

        with cached_app(testing=True).test_request_context():
            assert build_airflow_url_with_query(query) == expected_url
Example #4
0
 def get_link(
     self,
     operator: "AbstractOperator",
     *,
     ti_key: "TaskInstanceKey",
 ) -> str:
     # Fetch the correct execution date for the triggerED dag which is
     # stored in xcom during execution of the triggerING task.
     when = XCom.get_value(ti_key=ti_key, key=XCOM_EXECUTION_DATE_ISO)
     query = {
         "dag_id": cast(TriggerDagRunOperator, operator).trigger_dag_id,
         "base_date": when
     }
     return build_airflow_url_with_query(query)
 def test_build_airflow_url_with_query(self):
     query = {"dag_id": "test_dag", "param": "key/to.encode"}
     url = build_airflow_url_with_query(query)
     assert url == "/custom?dag_id=test_dag&param=key%2Fto.encode"
Example #6
0
 def get_link(self, operator, dttm):
     query = {
         "dag_id": operator.trigger_dag_id,
         "execution_date": dttm.isoformat()
     }
     return build_airflow_url_with_query(query)