[ 
https://issues.apache.org/jira/browse/BEAM-5621?focusedWorklogId=152593&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-152593
 ]

ASF GitHub Bot logged work on BEAM-5621:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Oct/18 08:47
            Start Date: 09/Oct/18 08:47
    Worklog Time Spent: 10m 
      Work Description: robertwb commented on a change in pull request #6602: 
[BEAM-5621] Fix unorderable types in python 3
URL: https://github.com/apache/beam/pull/6602#discussion_r223609509
 
 

 ##########
 File path: sdks/python/apache_beam/testing/util.py
 ##########
 @@ -112,8 +112,8 @@ def equal_to(expected):
   expected = list(expected)
 
   def _equal(actual):
-    sorted_expected = sorted(expected)
-    sorted_actual = sorted(actual)
+    sorted_expected = sorted(expected, key=str)
 
 Review comment:
   Simply setting key=str is the wrong thing to do here. The contract is that 
using assert_that(..., equal_to(...)) can only be used on fully orderable 
PCollections. Likely collections with heterogeneous types are in error, but if 
we do want to support this we must change the algorithm here. 
   
   One hack would be to partition by type and then sort each bucket. A cheap 
way to (almost) do this is letting `key=lambda x: (hash(type(x)), type(x), x)`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 152593)
    Time Spent: 1h  (was: 50m)

> Several tests fail on Python 3 with TypeError: unorderable types: str() < 
> int()
> -------------------------------------------------------------------------------
>
>                 Key: BEAM-5621
>                 URL: https://issues.apache.org/jira/browse/BEAM-5621
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-py-core
>            Reporter: Valentyn Tymofieiev
>            Assignee: Juta Staes
>            Priority: Major
>             Fix For: Not applicable
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> ======================================================================
> ERROR: test_remove_duplicates 
> (apache_beam.transforms.ptransform_test.PTransformTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File 
> "/usr/local/google/home/valentyn/projects/beam/clean_head/beam/sdks/python/apache_beam/runners/common.py",
>  line 677, in process
>     self.do_fn_invoker.invoke_process(windowed_value)
>   File 
> "/usr/local/google/home/valentyn/projects/beam/clean_head/beam/sdks/python/apache_beam/runners/common.py",
>  line 414, in invoke_process
>     windowed_value, self.process_method(windowed_value.value))
>   File 
> "/usr/local/google/home/valentyn/projects/beam/clean_head/beam/sdks/python/apache_beam/transforms/core.py",
>  line 1068, in <lambda>
>     wrapper = lambda x: [fn(x)]
>   File 
> "/usr/local/google/home/valentyn/projects/beam/clean_head/beam/sdks/python/apache_beam/testing/util.py",
>  line 115, in _equal
>     sorted_expected = sorted(expected)
> TypeError: unorderable types: str() < int()



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to