Skip to content

Commit 4c3b2f7

Browse files
committed
fixup! fix: use Dag form when materializing asset
1 parent 4ce0078 commit 4c3b2f7

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

airflow-core/src/airflow/api_fastapi/core_api/datamodels/assets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from datetime import datetime
2222
from typing import TYPE_CHECKING
2323

24-
from pydantic import AliasPath, ConfigDict, Field, JsonValue, NonNegativeInt, field_validator
24+
from pydantic import AliasPath, AwareDatetime, ConfigDict, Field, JsonValue, NonNegativeInt, field_validator
2525

2626
from airflow._shared.secrets_masker import redact
2727
from airflow._shared.timezones import timezone
@@ -197,7 +197,7 @@ def set_from_rest_api(cls, v: dict) -> dict:
197197
class MaterializeAssetBody(TriggerDAGRunPostBody):
198198
"""Materialize asset request."""
199199

200-
logical_date: datetime | None = None
200+
logical_date: AwareDatetime | None = None
201201

202202
def validate_context(self, dag: SerializedDAG) -> dict:
203203
params = super().validate_context(dag)

airflow-core/src/airflow/ui/src/components/TriggerDag/TriggerDAGForm.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ const TriggerDAGForm = ({
104104
// Pre-fill form when prefillConfig is provided (priority over conf)
105105
// Only restore 'conf' (parameters), not logicalDate, runId, or partitionKey to avoid 409 conflicts
106106
useEffect(() => {
107-
// Also update the param store to keep it in sync.
108-
// Wait until we have the initial params so section ordering stays consistent.
109107
if (prefillConfig && open) {
110108
const confString = prefillConfig.conf ? JSON.stringify(prefillConfig.conf, undefined, 2) : "";
111109

@@ -119,6 +117,8 @@ const TriggerDAGForm = ({
119117
note: "",
120118
partitionKey: undefined,
121119
});
120+
// Also update the param store to keep it in sync.
121+
// Wait until we have the initial params so section ordering stays consistent.
122122
if (confString && Object.keys(initialParamsDict.paramsDict).length > 0) {
123123
if (Object.keys(initialParamDict).length === 0) {
124124
setInitialParamDict(initialParamsDict.paramsDict);
@@ -137,13 +137,10 @@ const TriggerDAGForm = ({
137137
isPartitioned,
138138
]);
139139

140+
// Automatically reset form when conf is fetched (only if no prefillConfig)
140141
useEffect(() => {
141-
// Automatically reset form when conf is fetched (only if no prefillConfig)
142142
if (conf && !prefillConfig && open) {
143-
reset((prevValues) => ({
144-
...prevValues,
145-
conf,
146-
}));
143+
reset((prevValues) => ({ ...prevValues, conf }));
147144
}
148145
}, [conf, prefillConfig, open, reset]);
149146

airflow-ctl/src/airflowctl/api/datamodels/generated.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,24 @@ class LastAssetEventResponse(BaseModel):
620620
timestamp: Annotated[datetime | None, Field(title="Timestamp")] = None
621621

622622

623+
class MaterializeAssetBody(BaseModel):
624+
"""
625+
Materialize asset request.
626+
"""
627+
628+
model_config = ConfigDict(
629+
extra="forbid",
630+
)
631+
dag_run_id: Annotated[str | None, Field(title="Dag Run Id")] = None
632+
data_interval_start: Annotated[datetime | None, Field(title="Data Interval Start")] = None
633+
data_interval_end: Annotated[datetime | None, Field(title="Data Interval End")] = None
634+
logical_date: Annotated[datetime | None, Field(title="Logical Date")] = None
635+
run_after: Annotated[datetime | None, Field(title="Run After")] = None
636+
conf: Annotated[dict[str, Any] | None, Field(title="Conf")] = None
637+
note: Annotated[str | None, Field(title="Note")] = None
638+
partition_key: Annotated[str | None, Field(title="Partition Key")] = None
639+
640+
623641
class PluginImportErrorResponse(BaseModel):
624642
"""
625643
Plugin Import Error serializer for responses.

0 commit comments

Comments
 (0)