potiuk commented on code in PR #39513:
URL: https://github.com/apache/airflow/pull/39513#discussion_r1597429528


##########
tests/providers/amazon/aws/links/test_base_aws.py:
##########
@@ -203,7 +204,10 @@ def test_link_serialize(self):
         """Test: Operator links should exist for serialized DAG."""
         self.create_op_and_ti(self.link_class, dag_id="test_link_serialize", 
task_id=self.task_id)
         serialized_dag = self.dag_maker.get_serialized_data()
-        operator_extra_link = 
serialized_dag["dag"]["tasks"][0]["__var"]["_operator_extra_links"]
+        if AIRFLOW_V_2_10_PLUS:
+            operator_extra_link = 
serialized_dag["dag"]["tasks"][0]["__var"]["_operator_extra_links"]
+        else:
+            operator_extra_link = 
serialized_dag["dag"]["tasks"][0]["_operator_extra_links"]

Review Comment:
   This is where things go strange :) :
   
   ```python
       def 
test_operator_extra_links_mapped_with_applicationui_enabled_at_partial(
           self,
       ):
           operator = EmrServerlessStartJobOperator.partial(
               task_id=task_id,
               application_id=application_id,
               execution_role_arn=execution_role_arn,
               job_driver=spark_job_driver,
               enable_application_ui_links=True,
           ).expand(
               configuration_overrides=[s3_configuration_overrides, 
cloudwatch_configuration_overrides],
           )
       
           ser_operator = BaseSerialization.serialize(operator)
   >       deser_operator = BaseSerialization.deserialize(ser_operator)
   
   tests/providers/amazon/aws/operators/test_emr_serverless.py:1143: 
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
   
   cls = <class 'airflow.serialization.serialized_objects.BaseSerialization'>
   encoded_var = {'_disallow_kwargs_override': False, '_expand_input_attr': 
'expand_input', '_is_empty': False, '_is_mapped': True, ...}
   use_pydantic_models = False
   
       @classmethod
       def deserialize(cls, encoded_var: Any, use_pydantic_models=False) -> Any:
           """
           Deserialize an object; helper function of depth first search for 
deserialization.
       
           :meta private:
           """
           # JSON primitives (except for dict) are not encoded.
           if use_pydantic_models and not _ENABLE_AIP_44:
               raise RuntimeError(
                   "Setting use_pydantic_models = True requires AIP-44 (in 
progress) feature flag to be true. "
                   "This parameter will be removed eventually when new 
serialization is used by AIP-44"
               )
           if cls._is_primitive(encoded_var):
               return encoded_var
           elif isinstance(encoded_var, list):
               return [cls.deserialize(v, use_pydantic_models) for v in 
encoded_var]
       
           if not isinstance(encoded_var, dict):
               raise ValueError(f"The encoded_var should be dict and is 
{type(encoded_var)}")
   >       var = encoded_var[Encoding.VAR]
   E       KeyError: <Encoding.VAR: '__var'>
   ```
   



-- 
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]

Reply via email to