Skip to content

Commit

Permalink
Fix task_instance and dag_run links from list views (#42138) (#42143)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Jeambrun <[email protected]>
  • Loading branch information
2 people authored and ephraimbuddy committed Sep 13, 2024
1 parent 6b02182 commit d9eb420
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
13 changes: 11 additions & 2 deletions airflow/www/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -529,21 +533,26 @@ def json_(attr):
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)


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",
)
Expand Down
24 changes: 15 additions & 9 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -3490,9 +3494,11 @@ def next_run_datasets(self, dag_id):
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,
)
Expand Down

0 comments on commit d9eb420

Please sign in to comment.