You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/07/15 23:28:35 UTC

[GitHub] [airflow] tatiana opened a new pull request #9847: Support for set in XCom serialization (fix #8703)

tatiana opened a new pull request #9847:
URL: https://github.com/apache/airflow/pull/9847


   This PR aims to fix the issue #8703.
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Target Github ISSUE in description if exists
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tatiana commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
tatiana commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-659389946


   Thanks, @potiuk ! I'll solve those later today, sorry - I'll make sure the CI is happy.
   Do you have any comments on the implementation itself? Anything you'd like me to change with the strategy?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
kaxil commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-689083911


   any updates?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tatiana commented on a change in pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
tatiana commented on a change in pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#discussion_r457766691



##########
File path: airflow/serialization/json.py
##########
@@ -0,0 +1,125 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Any
+
+from airflow.serialization.enums import DagAttributeTypes as DAT, Encoding
+
+
+def encode(value: Any, type_: Any) -> dict:
+    """Encode value and type into a JSON-friendly dict."""
+    return {Encoding.VAR: value, Encoding.TYPE: type_}
+
+
+_return_primitive = lambda value: value
+
+
+def _serialize_list(list_: list) -> list:
+    return [serialize(item) for item in list_]
+
+
+def _serialize_dict(dict_: dict) -> dict:
+    value = {k: serialize(v) for k, v in dict_.items()}
+    return encode(value=value, type_=DAT.DICT)
+
+
+def _serialize_set(set_: set) -> dict:
+    value = [serialize(item) for item in set_]
+    return encode(value=value, type_=DAT.SET)
+
+
+def _serialize_tuple(tuple_: tuple) -> dict:
+    value = [serialize(item) for item in tuple_]
+    return encode(value=value, type_=DAT.TUPLE)
+
+
+def serialize(value):
+    """Serialize a value so it can be stored as JSON.
+
+    The serialization protocol is:
+
+    (1) keep JSON supported types: primitives, dict, list;
+    (2) encode other types such as tuples and sets as
+       ``{TYPE: 'foo', VAR: 'bar'}``
+    """
+    serialization_function_by_type = {
+        int: _return_primitive,
+        bool: _return_primitive,
+        float: _return_primitive,
+        str: _return_primitive,
+        list: _serialize_list,
+        dict: _serialize_dict,
+        set: _serialize_set,
+        tuple: _serialize_tuple
+    }
+    try:
+        function = serialization_function_by_type[type(value)]

Review comment:
       Thanks, @turbaszek, for pointing this out - I just added a test & support for `None`.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
kaxil commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-661832804


   > @kaxil I'm ok with a proposed approach as long as pylint is happy. General speaking we will introduce cyclic dependency but a working one by adding
   > 
   > ```
   > from airflow.serialization.serialized_objects import BaseSerialization
   > ```
   > 
   > in Xcom serialize and deserialize methods.
   
   We previously had base_serialization, serialized_operator and serialized_dag in 3 separate files but that suffered from some cyclic dependencies. We logically grouped them to avoid it but since serialization touches almost most of the models it gets tricky.
   
   Check https://github.com/apache/airflow/pull/6718 where that was fixed. If just moving BaseSerialization to a separate module helps fix the cyclic dependencies I would be happy but please do check that removes 1 cyclic dependency doesn't introduce other cyclic dependency


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-661817614


   @kaxil I'm ok with a proposed approach as long as pylint is happy. General speaking we will introduce cyclic dependency but a working one by adding
   ```
   from airflow.serialization.serialized_objects import BaseSerialization
   ```
   in Xcom serialize and deserialize methods.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-660857275


   Hm, let me take a look at the failing lineage tests...


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tatiana commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
tatiana commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-661513183


   > Hm, let me take a look at the failing lineage tests...
   
   Thanks, @turbaszek, I'm struggling to reproduce the issues from the CI locally. I tried to run `./breeze --python 3.6  --backend mysql` but had issues ("mysql db could not be reached!"). I'll re-watch the breeze video and make sure I'm not missing any step.
   
   Do you have any ideas on why the quarantine tests might be currently be killed? Usually, the exit code 137 relates to high memory consumption, but it isn't clear to me why the changes I introduced had this side effect πŸ€” Do you have any advice?
   
   * Quarantined:Pg9.6,Py3.6
   ```
   tests/jobs/test_backfill_job.py::TestBackfillJob::test_trigger_controller_dag 
   ##[error]Process completed with exit code 137.
   ```
   The other issues I've seen in the Core tests seemed to relate to views. I'll try a bit more reproducing them using Breeze!


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tatiana edited a comment on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
tatiana edited a comment on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-661513183


   > Hm, let me take a look at the failing lineage tests...
   
   Thanks, @turbaszek, I'm struggling to reproduce the issues from the CI locally. I tried to run `./breeze --python 3.6  --backend mysql` but had issues ("mysql db could not be reached!"). I'll re-watch the breeze video and make sure I'm not missing any step.
   
   Do you have any ideas on why the quarantine tests might be currently be killed? Usually, the exit code 137 relates to high memory consumption, but it isn't clear to me why the changes I introduced had this side effect πŸ€” Do you have any advice?
   
   * Quarantined:Pg9.6,Py3.6
   ```
   tests/jobs/test_backfill_job.py::TestBackfillJob::test_trigger_controller_dag 
   ##[error]Process completed with exit code 137.
   ```
   Previously there were some view Core tests failing, but it seems they are now passing. Perhaps they were related to the `NoneType` support.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-661758407


   > Usually, the exit code 137 relates to high memory consumption
   
   That's usually the problem. The quarantined tests often use multiprocessing and mixing this with flaky tests results in unstable builds. I usually try to re-run quarantined tests locally if I have suspicion that my change may impact those tests.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-659387302


   @tatiana  There is a test failing which is likely related to XCom Serialization change..


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] github-actions[bot] commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-800704566


   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-660863664


   > What are your thoughts on isolating the JSON serialization logic in a separate "lightweight" module?
   
   I think it's a good idea. @kaxil you are our serialization expert, what do you think? 


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#discussion_r457138804



##########
File path: airflow/serialization/json.py
##########
@@ -0,0 +1,125 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Any
+
+from airflow.serialization.enums import DagAttributeTypes as DAT, Encoding
+
+
+def encode(value: Any, type_: Any) -> dict:
+    """Encode value and type into a JSON-friendly dict."""
+    return {Encoding.VAR: value, Encoding.TYPE: type_}
+
+
+_return_primitive = lambda value: value
+
+
+def _serialize_list(list_: list) -> list:
+    return [serialize(item) for item in list_]
+
+
+def _serialize_dict(dict_: dict) -> dict:
+    value = {k: serialize(v) for k, v in dict_.items()}
+    return encode(value=value, type_=DAT.DICT)
+
+
+def _serialize_set(set_: set) -> dict:
+    value = [serialize(item) for item in set_]
+    return encode(value=value, type_=DAT.SET)
+
+
+def _serialize_tuple(tuple_: tuple) -> dict:
+    value = [serialize(item) for item in tuple_]
+    return encode(value=value, type_=DAT.TUPLE)
+
+
+def serialize(value):
+    """Serialize a value so it can be stored as JSON.
+
+    The serialization protocol is:
+
+    (1) keep JSON supported types: primitives, dict, list;
+    (2) encode other types such as tuples and sets as
+       ``{TYPE: 'foo', VAR: 'bar'}``
+    """
+    serialization_function_by_type = {
+        int: _return_primitive,
+        bool: _return_primitive,
+        float: _return_primitive,
+        str: _return_primitive,
+        list: _serialize_list,
+        dict: _serialize_dict,
+        set: _serialize_set,
+        tuple: _serialize_tuple
+    }
+    try:
+        function = serialization_function_by_type[type(value)]

Review comment:
       We should support `None` as possible return value for XCom




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] boring-cyborg[bot] commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-659066868


   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (flake8, pylint and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/master/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/master/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/master/BREEZE.rst) for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#coding-style-and-best-practices).
   Apache Airflow is a community-driven project and together we are making it better πŸš€.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://apache-airflow-slack.herokuapp.com/
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tatiana commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
tatiana commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-659105059


   Hey, @turbaszek @potiuk thank you very much for the Workshop yesterday. It was great!
   If you have any suggestions, it would be great! It took me a bit longer than the original 45min estimate to have this first draft ;) 
    
   
    


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-661840232


   @tatiana let's check if Kaxil proposition is accepted by pylint. If yes let's use it to solve this issue. After that, we can think about extracting this logic.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-659404289


   I did not yet have time to take a deeper look - and a little busy today :(. I will take a look tomorrow I think! Nothing to be sorry about :). Tests are there to catch all those things that are not obvious :)


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] github-actions[bot] closed pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #9847:
URL: https://github.com/apache/airflow/pull/9847


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#discussion_r457140769



##########
File path: airflow/serialization/json.py
##########
@@ -0,0 +1,125 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Any
+
+from airflow.serialization.enums import DagAttributeTypes as DAT, Encoding
+
+
+def encode(value: Any, type_: Any) -> dict:
+    """Encode value and type into a JSON-friendly dict."""
+    return {Encoding.VAR: value, Encoding.TYPE: type_}
+
+
+_return_primitive = lambda value: value

Review comment:
       Do we use it somewhere?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#discussion_r457155557



##########
File path: airflow/serialization/json.py
##########
@@ -0,0 +1,125 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Any
+
+from airflow.serialization.enums import DagAttributeTypes as DAT, Encoding
+
+
+def encode(value: Any, type_: Any) -> dict:
+    """Encode value and type into a JSON-friendly dict."""
+    return {Encoding.VAR: value, Encoding.TYPE: type_}
+
+
+_return_primitive = lambda value: value

Review comment:
       Oh, I see! My bad, I missed the usage of this function 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-739790213


   @tatiana - we would love to merge it before 2.0.0rc1 this week. Would it be possible you rebase it and add the last fix from @kaxil ?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] stale[bot] commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
stale[bot] commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-687656998


   This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tatiana commented on a change in pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
tatiana commented on a change in pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#discussion_r457150260



##########
File path: airflow/serialization/json.py
##########
@@ -0,0 +1,125 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Any
+
+from airflow.serialization.enums import DagAttributeTypes as DAT, Encoding
+
+
+def encode(value: Any, type_: Any) -> dict:
+    """Encode value and type into a JSON-friendly dict."""
+    return {Encoding.VAR: value, Encoding.TYPE: type_}
+
+
+_return_primitive = lambda value: value

Review comment:
       Yes, those were a way of treating parsing as a method in all cases...! From one hand, it allows us to have a smaller piece of code, using a dictionary opposed to several "ifs". On the other hand, it does add the overhead of a function call. If you prefer, I could keep the initial strategy of having "primitive_types" defined as a set and to check the values against those primitive types - falling back to a function just in case it isn't a primitive type.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tatiana edited a comment on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
tatiana edited a comment on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-661829786


   Thank you both for taking the time to review and give feedback.
   
   @kaxil as mentioned by @turbaszek, it would be great if we could avoid introducing this cyclic dependency.
   
   I fully agree with avoiding duplicating the code as well.
   
   How would you both feel if I try to extract the `BaseSerialization` - keeping its current interfaces - to another module, which would be used both by `xcom.py` and `serialized_objects.py`? If you like this possibility, how would you like name this file which would contain the `BaseSerialization` class?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tatiana commented on pull request #9847: Support for set in XCom serialization (fix #8703)

Posted by GitBox <gi...@apache.org>.
tatiana commented on pull request #9847:
URL: https://github.com/apache/airflow/pull/9847#issuecomment-661829786


   @kaxil as mentioned by @turbaszek, it would be great if we could avoid introducing this cyclic dependency.
   
   I fully agree with avoiding duplicating the code as well.
   
   How would you both feel if I try to extract the `BaseSerialization` - keeping its current interfaces - to another module, which would be used both by `xcom.py` and `serialized_objects.py`?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org