tatiana commented on code in PR #30943:
URL: https://github.com/apache/airflow/pull/30943#discussion_r1183660775
##########
tests/models/test_mappedoperator.py:
##########
@@ -57,6 +59,32 @@ def test_task_mapping_with_dag():
assert mapped.downstream_list == [finish]
+def test_task_mapping_with_dag_and_list_of_pandas_dataframe(caplog):
+ caplog.set_level(logging.INFO)
+
+ class UnrenderableClass:
+ def __non_zero__(self):
+ raise ValueError("Similar to Pandas DataFrames, this class does
not implement zero comparison.")
+
+ class CustomOperator(BaseOperator):
+ template_fields = ("arg",)
+
+ def __init__(self, arg, **kwargs):
+ super().__init__(**kwargs)
+ self.arg = arg
+
+ def execute(self, context: Context):
+ pass
+
+ with DAG("test-dag", start_date=DEFAULT_DATE) as dag:
+ task1 = CustomOperator(task_id="op1", arg=None)
+ unrenderable_values = [UnrenderableClass(), UnrenderableClass()]
+ mapped =
CustomOperator.partial(task_id="task_2").expand(arg=unrenderable_values)
+ task1 >> mapped
+ dag.test()
+ assert caplog.text.count("task_2 ran successfully") == 2
Review Comment:
Nice catch, @ephraimbuddy , I had missed this line:
https://github.com/pandas-dev/pandas/blob/main/pandas/core/generic.py#L1471
`__nonzero__` was Python 2 compatible - since Airflow only supports Python
3, I changed to `__bool__`! I re-run the tests without this change, and it
worked as expected.
--
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]