Repository: dwavesystems/dwave-system

Issue:
Fix version filter in hybrid samplers
Both `LeapHybridDQMSampler` and `LeapHybridSampler`/`LeapHybridBQMSampler` encode the intent of preferring the latest solver (by version), but the exact order_by expression is wrong.

Discussion:

Patch:
diff --git a/dwave/system/samplers/leap_hybrid_sampler.py b/dwave/system/samplers/leap_hybrid_sampler.py
index b6ac546..91473e5 100644
--- a/dwave/system/samplers/leap_hybrid_sampler.py
+++ b/dwave/system/samplers/leap_hybrid_sampler.py
@@ -93,7 +93,7 @@ class LeapHybridSampler(dimod.Sampler):
                 raise ValueError("the only problem type this sampler supports is 'bqm'")
 
             # prefer the latest version, but allow kwarg override
-            solver.setdefault('order_by', '-version')
+            solver.setdefault('order_by', '-properties.version')
 
         self.client = Client.from_config(
             solver=solver, connection_close=connection_close, **config)
@@ -331,7 +331,7 @@ class LeapHybridDQMSampler:
                 raise ValueError("the only problem type this sampler supports is 'dqm'")
 
             # prefer the latest version, but allow kwarg override
-            solver.setdefault('order_by', '-version')
+            solver.setdefault('order_by', '-properties.version')
 
         self.client = Client.from_config(
             solver=solver, connection_close=connection_close, **config)


Test patch:
diff --git a/tests/test_leaphybridsolver.py b/tests/test_leaphybridsolver.py
index a14add6..d0d9f94 100644
--- a/tests/test_leaphybridsolver.py
+++ b/tests/test_leaphybridsolver.py
@@ -65,7 +65,7 @@ class TestLeapHybridSampler(unittest.TestCase):
             client='hybrid', connection_close=True,
             solver={'category': 'hybrid',
                     'supported_problem_types__contains': 'bqm',
-                    'order_by': '-version'})
+                    'order_by': '-properties.version'})
 
         # Non-hybrid client setting
         mock_client.reset_mock()
@@ -80,7 +80,7 @@ class TestLeapHybridSampler(unittest.TestCase):
             client='hybrid', connection_close=True,
             solver={'category': 'hybrid',
                     'supported_problem_types__contains': 'bqm',
-                    'order_by': '-version'})
+                    'order_by': '-properties.version'})
 
         # Explicitly set category to not hybrid
         with self.assertRaises(ValueError):
@@ -93,7 +93,7 @@ class TestLeapHybridSampler(unittest.TestCase):
             client='hybrid', connection_close=True,
             solver={'qpu': True, 'category': 'hybrid',
                     'supported_problem_types__contains': 'bqm',
-                    'order_by': '-version'})
+                    'order_by': '-properties.version'})
 
         mock_client.reset_mock()
         LeapHybridSampler(solver={'qpu': True, 'anneal_schedule': False})
@@ -101,7 +101,7 @@ class TestLeapHybridSampler(unittest.TestCase):
             client='hybrid', connection_close=True,
             solver={'anneal_schedule': False, 'qpu': True, 'category': 'hybrid',
                     'supported_problem_types__contains': 'bqm',
-                    'order_by': '-version'})
+                    'order_by': '-properties.version'})
 
         # Named solver: hybrid
         mock_client.reset_mock()
@@ -125,7 +125,7 @@ class TestLeapHybridSampler(unittest.TestCase):
             client='hybrid', connection_close=False,
             solver={'category': 'hybrid',
                     'supported_problem_types__contains': 'bqm',
-                    'order_by': '-version'})
+                    'order_by': '-properties.version'})
 
         mock_client.reset_mock()
         LeapHybridSampler(connection_close=False,
@@ -135,7 +135,7 @@ class TestLeapHybridSampler(unittest.TestCase):
             client='hybrid', connection_close=False,
             solver={'category': 'hybrid',
                     'supported_problem_types__contains': 'bqm',
-                    'order_by': '-version'})
+                    'order_by': '-properties.version'})
 
     @mock.patch('dwave.system.samplers.leap_hybrid_sampler.Client')
     def test_sample_bqm(self, mock_client):