|
27 | 27 | from collections.abc import Callable, Collection, Iterable, Mapping, Sequence |
28 | 28 | from datetime import datetime, timedelta |
29 | 29 | from typing import TYPE_CHECKING, Any, NamedTuple |
30 | | -from urllib.parse import quote |
| 30 | +from urllib.parse import quote, urlencode |
31 | 31 | from uuid import UUID |
32 | 32 |
|
33 | 33 | import attrs |
@@ -1428,11 +1428,20 @@ def log_url(self) -> str: |
1428 | 1428 | """Log URL for TaskInstance.""" |
1429 | 1429 | run_id = quote(self.run_id) |
1430 | 1430 | base_url = conf.get("api", "base_url", fallback="http://localhost:8080/") |
1431 | | - map_index = f"/mapped/{self.region_index}" if self.region_index >= 0 else "" |
1432 | | - try_number = f"?try_number={self.try_number}" if self.try_number > 0 else "" |
1433 | | - _log_uri = f"{base_url.rstrip('/')}/dags/{self.dag_id}/runs/{run_id}/tasks/{self.task_id}{map_index}{try_number}" |
1434 | | - |
1435 | | - return _log_uri |
| 1431 | + _log_uri = f"{base_url.rstrip('/')}/dags/{self.dag_id}/runs/{run_id}/tasks/{self.task_id}" |
| 1432 | + query: dict[str, Any] = {} |
| 1433 | + if self.region_id == SENTINEL_REGION_ID: |
| 1434 | + if self.region_index >= 0: |
| 1435 | + _log_uri += f"/mapped/{self.region_index}" |
| 1436 | + else: |
| 1437 | + # In a region, region_index is a map index only for a mapped task (in a loop it is the iteration |
| 1438 | + # otherwise), and the UI selects the task instance by its region, which tells loop iterations apart |
| 1439 | + if (task := getattr(self, "task", None)) is not None and task.get_needs_expansion(): |
| 1440 | + _log_uri += f"/mapped/{self.region_index}" |
| 1441 | + query.update(region_id=self.region_id, region_index=self.region_index) |
| 1442 | + if self.try_number > 0: |
| 1443 | + query["try_number"] = self.try_number |
| 1444 | + return f"{_log_uri}?{urlencode(query)}" if query else _log_uri |
1436 | 1445 |
|
1437 | 1446 | @property |
1438 | 1447 | def mark_success_url(self) -> str: |
|
0 commit comments