Lee-W commented on code in PR #67725:
URL: https://github.com/apache/airflow/pull/67725#discussion_r3479917372
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/assets.py:
##########
@@ -147,7 +147,8 @@ def next_run_assets(
)
for row in raw_rows
]
- return
NextRunAssetsResponse(asset_expression=dag_model.asset_expression,
events=events)
+ model_data: dict[str, Any] = {"asset_expression":
dag_model.asset_expression, "events": events}
+ return NextRunAssetsResponse.model_validate(model_data)
Review Comment:
```suggestion
model_data: dict[str, Any] =
return NextRunAssetsResponse.model_validate(
{
"asset_expression": dag_model.asset_expression,
"events": events
}
)
```
nit: probably don't need an extra variable for it.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/assets.py:
##########
@@ -180,11 +181,12 @@ def next_run_assets(
)
for row in raw_rows
]
- return NextRunAssetsResponse(
- asset_expression=dag_model.asset_expression,
- events=events,
- pending_partition_count=pending_partition_count,
- )
+ model_data = {
+ "asset_expression": dag_model.asset_expression,
+ "events": events,
+ "pending_partition_count": pending_partition_count,
+ }
+ return NextRunAssetsResponse.model_validate(model_data)
Review Comment:
```suggestion
model_data =
return NextRunAssetsResponse.model_validate(
{
"asset_expression": dag_model.asset_expression,
"events": events,
"pending_partition_count": pending_partition_count,
}
)
```
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/partitioned_dag_runs.py:
##########
@@ -334,11 +334,12 @@ def get_partitioned_dag_runs(
if dag_id.value is None:
asset_expressions = {dm.dag_id: dm.asset_expression for dm in
dag_models.values()}
- return PartitionedDagRunCollectionResponse(
- partitioned_dag_runs=results,
- total=len(results),
- asset_expressions=asset_expressions,
- )
+ model_data: dict[str, Any] = {
+ "partitioned_dag_runs": results,
+ "total": len(results),
+ "asset_expressions": asset_expressions,
+ }
+ return PartitionedDagRunCollectionResponse.model_validate(model_data)
Review Comment:
```suggestion
return PartitionedDagRunCollectionResponse.model_validate(
{
"partitioned_dag_runs": results,
"total": len(results),
"asset_expressions": asset_expressions,
}
)
```
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/assets.py:
##########
@@ -253,8 +255,9 @@ def next_run_assets(
)
)
- return NextRunAssetsResponse(
- asset_expression=dag_model.asset_expression,
- events=events,
- pending_partition_count=pending_partition_count,
- )
+ model_data = {
+ "asset_expression": dag_model.asset_expression,
+ "events": events,
+ "pending_partition_count": pending_partition_count,
+ }
+ return NextRunAssetsResponse.model_validate(model_data)
Review Comment:
```suggestion
model_data =
return NextRunAssetsResponse.model_validate(
{
"asset_expression": dag_model.asset_expression,
"events": events,
"pending_partition_count": pending_partition_count,
}
)
```
##########
airflow-core/src/airflow/ui/src/components/AssetExpression/AssetNode.tsx:
##########
@@ -20,18 +20,21 @@ import { Box, HStack, Text } from "@chakra-ui/react";
import { FiDatabase } from "react-icons/fi";
import { PiRectangleDashed } from "react-icons/pi";
-import type { NextRunAssetEventResponse } from "openapi/requests/types.gen";
+import type {
+ AssetExpressionAlias,
+ AssetExpressionAsset,
+ NextRunAssetEventResponse,
+} from "openapi/requests/types.gen";
import { RollupKeyChecklistPopover } from "src/components/RollupKeyChecklist";
import { RouterLink } from "src/components/ui";
import Time from "../Time";
-import type { AssetSummary } from "./types";
export const AssetNode = ({
asset,
event,
}: {
- readonly asset: AssetSummary;
+ readonly asset: AssetExpressionAlias | AssetExpressionAsset;
Review Comment:
should we make `AssetExpressionAlias | AssetExpressionAsset` the new
`AssetSummary`? or will it produce new issues?
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/partitioned_dag_runs.py:
##########
@@ -463,15 +464,16 @@ def get_pending_partitioned_dag_run(
total_required = sum(a.required_count for a in assets)
asset_expression = dag_model.asset_expression if dag_model is not None
else None
- return PartitionedDagRunDetailResponse(
- id=partitioned_dag_run.id,
- dag_id=dag_id,
- partition_key=partition_key,
- created_at=partitioned_dag_run.created_at.isoformat() if
partitioned_dag_run.created_at else None,
- updated_at=partitioned_dag_run.updated_at.isoformat() if
partitioned_dag_run.updated_at else None,
- created_dag_run_id=partitioned_dag_run.created_dag_run_id,
- assets=assets,
- total_required=total_required,
- total_received=total_received,
- asset_expression=asset_expression,
- )
+ model_data: dict[str, Any] = {
+ "id": partitioned_dag_run.id,
+ "dag_id": dag_id,
+ "partition_key": partition_key,
+ "created_at": partitioned_dag_run.created_at.isoformat() if
partitioned_dag_run.created_at else None,
+ "updated_at": partitioned_dag_run.updated_at.isoformat() if
partitioned_dag_run.updated_at else None,
+ "created_dag_run_id": partitioned_dag_run.created_dag_run_id,
+ "assets": assets,
+ "total_required": total_required,
+ "total_received": total_received,
+ "asset_expression": asset_expression,
+ }
+ return PartitionedDagRunDetailResponse.model_validate(model_data)
Review Comment:
```suggestion
return PartitionedDagRunDetailResponse.model_validate(
{
"id": partitioned_dag_run.id,
"dag_id": dag_id,
"partition_key": partition_key,
"created_at": partitioned_dag_run.created_at.isoformat() if
partitioned_dag_run.created_at else None,
"updated_at": partitioned_dag_run.updated_at.isoformat() if
partitioned_dag_run.updated_at else None,
"created_dag_run_id": partitioned_dag_run.created_dag_run_id,
"assets": assets,
"total_required": total_required,
"total_received": total_received,
"asset_expression": asset_expression,
}
)
```
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py:
##########
@@ -137,7 +137,17 @@ def _create_asset_test_data(self, session=None):
is_stale=False,
is_paused=False,
owners="airflow",
- asset_expression={"any": [{"uri": "test://scheduled_asset"}]},
Review Comment:
Should we have a test case that covers the legacy cases?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]