Closed Bug 1642313 Opened 11 months ago Closed 10 months ago

TypeError: '<' not supported between instances of 'dict' and 'dict' in testing/mozbase/manifestparser/manifestparser/filters.py

Categories

(Testing :: Mozbase, defect)

defect

Tracking

(firefox79 fixed)

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: bc, Assigned: bc)

References

Details

Attachments

(1 file)

I hadn't seen this before but when working on bug 1642044, I started hitting

python3 ./mach reftest --this-chunk 1 --total-chunks 100
...
TypeError: '<' not supported between instances of 'dict' and 'dict'

  File "/home/bclary/mozilla/builds/autoland/mozilla/layout/tools/reftest/mach_commands.py", line 208, in run_reftest
    return self._run_reftest(**kwargs)
  File "/home/bclary/mozilla/builds/autoland/mozilla/layout/tools/reftest/mach_commands.py", line 242, in _run_reftest
    return reftest.run_desktop_test(**kwargs)
  File "/home/bclary/mozilla/builds/autoland/mozilla/layout/tools/reftest/mach_commands.py", line 87, in run_desktop_test
    rv = runreftest.run_test_harness(parser, args)
  File "/home/bclary/mozilla/builds/autoland/mozilla/layout/tools/reftest/runreftest.py", line 1035, in run_test_harness
    result = reftest.runTests(options.tests, options)
  File "/home/bclary/mozilla/builds/autoland/mozilla/layout/tools/reftest/runreftest.py", line 626, in runTests
    return self.runSerialTests(manifests, options, cmdargs)
  File "/home/bclary/mozilla/builds/autoland/mozilla/layout/tools/reftest/runreftest.py", line 968, in runSerialTests
    tests = self.getActiveTests(manifests, options)
  File "/home/bclary/mozilla/builds/autoland/mozilla/layout/tools/reftest/runreftest.py", line 925, in getActiveTests
    tests = mp.active_tests(exists=False, filters=filters)
  File "/home/bclary/mozilla/builds/autoland/mozilla/testing/mozbase/manifestparser/manifestparser/manifestparser.py", line 804, in active_tests
    tests = fn(tests, values)
  File "/home/bclary/mozilla/builds/autoland/mozilla/testing/mozbase/manifestparser/manifestparser/filters.py", line 298, in __call__
    tests_by_manifest.sort(reverse=True, key=lambda x: (len(x), x))

ahal, Do you have any suggestion on how to appropriately sort tests_by_manifest?

Flags: needinfo?
Flags: needinfo? → needinfo?(ahal)

Looks like Python 3 removed the ability to sort dicts. But this is a list of lists we're sorting. I think it's happening because of the second x in (len(x), x) as that value is a list of dicts?

Flags: needinfo?(ahal)

Yeah, confirmed with some manual test cases in python2/3. My main question is how to reproduce your expected behavior in python3. What about tests_by_manifest.sort(reverse=True, key=lambda x: (len(x), repr(x))) ? Would that be ok with your expectations of how the algorithm should chunk?

Assignee: nobody → bob
Status: NEW → ASSIGNED

I think that , x was just a fallback to "whatever the default way Python sorts stuff is when the lengths are equal". Apparently the way Python 2 sorted a list of dicts was undefined anyway, so maybe you can simply remove that clause:

key=lambda x: len(x)

Does that work?

Attachment #9153425 - Attachment description: Bug 1642313 - mozbase manifestparser chunk_by_manifest should convert dicts to str when using them as keys during sorting, r=ahal. → Bug 1642313 - mozbase manifestparser chunk_by_manifest should not use dicts in key comparison during sort, r=ahal.

yep. patch updated.

Pushed by bclary@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2211fe5d5e3e
mozbase manifestparser chunk_by_manifest should not use dicts in key comparison during sort, r=ahal.
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
You need to log in before you can comment on or make changes to this bug.