amoghrajesh commented on code in PR #53870:
URL: https://github.com/apache/airflow/pull/53870#discussion_r2268743960


##########
task-sdk/src/airflow/sdk/definitions/connection.py:
##########
@@ -160,6 +203,14 @@ def get(cls, conn_id: str) -> Any:
     @property
     def extra_dejson(self) -> dict:
         """Deserialize `extra` property to JSON."""
+        return self.get_extra_dejson()
+
+    def get_extra_dejson(self, nested: bool = False) -> dict:

Review Comment:
   Sorry don't follow. `extra_dejson` is a property on models/connection too



##########
airflow-core/src/airflow/models/connection.py:
##########
@@ -529,6 +529,18 @@ def to_dict(self, *, prune_empty: bool = False, validate: 
bool = True) -> dict[s
 
         :meta private:
         """
+        if hasattr(sys.modules.get("airflow.sdk.execution_time.task_runner"), 
"SUPERVISOR_COMMS"):

Review Comment:
   Oh fair point, we won't need it for instance methods. Only classmethods will 
do the trick



##########
task-sdk/src/airflow/sdk/definitions/connection.py:
##########
@@ -30,6 +30,49 @@
 log = logging.getLogger(__name__)
 
 
+def _prune_dict(val: Any, mode="strict"):
+    """
+    Given dict ``val``, returns new dict based on ``val`` with all empty 
elements removed.
+
+    What constitutes "empty" is controlled by the ``mode`` parameter.  If mode 
is 'strict'
+    then only ``None`` elements will be removed.  If mode is ``truthy``, then 
element ``x``
+    will be removed if ``bool(x) is False``.
+    """
+
+    def is_empty(x):
+        if mode == "strict":
+            return x is None
+        if mode == "truthy":
+            return bool(x) is False
+        raise ValueError("allowable values for `mode` include 'truthy' and 
'strict'")

Review Comment:
   Yeah I see it with hardcoded strict too. Lets keep it I guess for now



##########
airflow-core/src/airflow/models/connection.py:
##########
@@ -567,6 +591,18 @@ def from_json(cls, value, conn_id=None) -> Connection:
 
     def as_json(self) -> str:
         """Convert Connection to JSON-string object."""
+        if hasattr(sys.modules.get("airflow.sdk.execution_time.task_runner"), 
"SUPERVISOR_COMMS"):

Review Comment:
   Yeah agreed.



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