Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add argument include_xcom in method rsolve an optional value #41062

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions airflow/models/expandinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def iter_references(self) -> Iterable[tuple[Operator, str]]:
yield from self._input.iter_references()

@provide_session
def resolve(self, context: Context, *, include_xcom: bool, session: Session = NEW_SESSION) -> Any:
def resolve(self, context: Context, *, include_xcom: bool = True, session: Session = NEW_SESSION) -> Any:
data, _ = self._input.resolve(context, session=session, include_xcom=include_xcom)
return data[self._key]

Expand Down Expand Up @@ -206,7 +206,7 @@ def iter_references(self) -> Iterable[tuple[Operator, str]]:
yield from x.iter_references()

def resolve(
self, context: Context, session: Session, *, include_xcom: bool
self, context: Context, session: Session, *, include_xcom: bool = True
) -> tuple[Mapping[str, Any], set[int]]:
data = {
k: self._expand_mapped_field(k, v, context, session=session, include_xcom=include_xcom)
Expand Down Expand Up @@ -256,7 +256,7 @@ def iter_references(self) -> Iterable[tuple[Operator, str]]:
yield from x.iter_references()

def resolve(
self, context: Context, session: Session, *, include_xcom: bool
self, context: Context, session: Session, *, include_xcom: bool = True
) -> tuple[Mapping[str, Any], set[int]]:
map_index = context["ti"].map_index
if map_index < 0:
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def __init__(self, current_dag: DAG, name: str, default: Any = NOTSET):
def iter_references(self) -> Iterable[tuple[Operator, str]]:
return ()

def resolve(self, context: Context, *, include_xcom: bool) -> Any:
def resolve(self, context: Context, *, include_xcom: bool = True) -> Any:
"""Pull DagParam value from DagRun context. This method is run during ``op.execute()``."""
with contextlib.suppress(KeyError):
return context["dag_run"].conf[self._name]
Expand Down
10 changes: 5 additions & 5 deletions airflow/models/xcom_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def get_task_map_length(self, run_id: str, *, session: Session) -> int | None:
raise NotImplementedError()

@provide_session
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool) -> Any:
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool = True) -> Any:
"""
Pull XCom value.

Expand Down Expand Up @@ -437,7 +437,7 @@ def get_task_map_length(self, run_id: str, *, session: Session) -> int | None:
)

@provide_session
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool) -> Any:
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool = True) -> Any:
ti = context["ti"]
if TYPE_CHECKING:
assert isinstance(ti, TaskInstance)
Expand Down Expand Up @@ -551,7 +551,7 @@ def get_task_map_length(self, run_id: str, *, session: Session) -> int | None:
return self.arg.get_task_map_length(run_id, session=session)

@provide_session
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool) -> Any:
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool = True) -> Any:
value = self.arg.resolve(context, session=session, include_xcom=include_xcom)
if not isinstance(value, (Sequence, dict)):
raise ValueError(f"XCom map expects sequence or dict, not {type(value).__name__}")
Expand Down Expand Up @@ -632,7 +632,7 @@ def get_task_map_length(self, run_id: str, *, session: Session) -> int | None:
return max(ready_lengths)

@provide_session
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool) -> Any:
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool = True) -> Any:
values = [arg.resolve(context, session=session, include_xcom=include_xcom) for arg in self.args]
for value in values:
if not isinstance(value, (Sequence, dict)):
Expand Down Expand Up @@ -707,7 +707,7 @@ def get_task_map_length(self, run_id: str, *, session: Session) -> int | None:
return sum(ready_lengths)

@provide_session
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool) -> Any:
def resolve(self, context: Context, session: Session = NEW_SESSION, *, include_xcom: bool = True) -> Any:
values = [arg.resolve(context, session=session, include_xcom=include_xcom) for arg in self.args]
for value in values:
if not isinstance(value, (Sequence, dict)):
Expand Down
2 changes: 1 addition & 1 deletion airflow/template/templater.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LiteralValue(ResolveMixin):
def iter_references(self) -> Iterable[tuple[Operator, str]]:
return ()

def resolve(self, context: Context, *, include_xcom: bool) -> Any:
def resolve(self, context: Context, *, include_xcom: bool = True) -> Any:
return self.value


Expand Down
2 changes: 1 addition & 1 deletion airflow/utils/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def iter_references(self) -> typing.Iterable[tuple[Operator, str]]:
"""
raise NotImplementedError

def resolve(self, context: Context, *, include_xcom: bool) -> typing.Any:
def resolve(self, context: Context, *, include_xcom: bool = True) -> typing.Any:
"""
Resolve this value for runtime.

Expand Down