This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch sync_v2_10_test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit d9eb420bb6693bdc920b1df56048c8fc0753e387 Author: Brent Bovenzi <[email protected]> AuthorDate: Tue Sep 10 18:32:27 2024 -0400 Fix task_instance and dag_run links from list views (#42138) (#42143) Co-authored-by: Pierre Jeambrun <[email protected]> --- airflow/www/utils.py | 13 +++++++++++-- airflow/www/views.py | 24 +++++++++++++++--------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/airflow/www/utils.py b/airflow/www/utils.py index 413d9fe2b6..70e942329c 100644 --- a/airflow/www/utils.py +++ b/airflow/www/utils.py @@ -432,6 +432,8 @@ def task_instance_link(attr): task_id = attr.get("task_id") run_id = attr.get("run_id") map_index = attr.get("map_index", None) + execution_date = attr.get("execution_date") or attr.get("dag_run.execution_date") + if map_index == -1: map_index = None @@ -441,6 +443,7 @@ def task_instance_link(attr): task_id=task_id, dag_run_id=run_id, map_index=map_index, + execution_date=execution_date, tab="graph", ) url_root = url_for( @@ -450,6 +453,7 @@ def task_instance_link(attr): root=task_id, dag_run_id=run_id, map_index=map_index, + execution_date=execution_date, tab="graph", ) return Markup( @@ -529,10 +533,10 @@ def json_f(attr_name): def dag_link(attr): """Generate a URL to the Graph view for a Dag.""" dag_id = attr.get("dag_id") - execution_date = attr.get("execution_date") + execution_date = attr.get("execution_date") or attr.get("dag_run.execution_date") if not dag_id: return Markup("None") - url = url_for("Airflow.graph", dag_id=dag_id, execution_date=execution_date) + url = url_for("Airflow.grid", dag_id=dag_id, execution_date=execution_date) return Markup('<a href="{}">{}</a>').format(url, dag_id) @@ -540,10 +544,15 @@ def dag_run_link(attr): """Generate a URL to the Graph view for a DagRun.""" dag_id = attr.get("dag_id") run_id = attr.get("run_id") + execution_date = attr.get("execution_date") or attr.get("dag_run.execution_date") + + if not dag_id: + return Markup("None") url = url_for( "Airflow.grid", dag_id=dag_id, + execution_date=execution_date, dag_run_id=run_id, tab="graph", ) diff --git a/airflow/www/views.py b/airflow/www/views.py index cd470807a9..a3e3b03a1b 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -708,12 +708,16 @@ def show_traceback(error): "airflow/traceback.html", python_version=sys.version.split(" ")[0] if is_logged_in else "redacted", airflow_version=version if is_logged_in else "redacted", - hostname=get_hostname() - if conf.getboolean("webserver", "EXPOSE_HOSTNAME") and is_logged_in - else "redacted", - info=traceback.format_exc() - if conf.getboolean("webserver", "EXPOSE_STACKTRACE") and is_logged_in - else "Error! Please contact server admin.", + hostname=( + get_hostname() + if conf.getboolean("webserver", "EXPOSE_HOSTNAME") and is_logged_in + else "redacted" + ), + info=( + traceback.format_exc() + if conf.getboolean("webserver", "EXPOSE_STACKTRACE") and is_logged_in + else "Error! Please contact server admin." + ), ), 500, ) @@ -3490,9 +3494,11 @@ class Airflow(AirflowBaseView): DatasetEvent, and_( DatasetEvent.dataset_id == DatasetModel.id, - DatasetEvent.timestamp >= latest_run.execution_date - if latest_run and latest_run.execution_date - else True, + ( + DatasetEvent.timestamp >= latest_run.execution_date + if latest_run and latest_run.execution_date + else True + ), ), isouter=True, )
