nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: apache/pulsar-client-go
Pull request #754 (2022-03-29 05:02:12)

allow config reader subscription name
### Motivation
allow config reader's subscription name, follow java's feature https://github.com/apache/pulsar/pull/8801

### Modifications
add param `SubscriptionName` in `ReaderOptions`

### Verifying this change
add the test for setting the subscritpion name



Patch:
diff --git a/pulsar/reader.go b/pulsar/reader.go
index f1cb575..3539037 100644
--- a/pulsar/reader.go
+++ b/pulsar/reader.go
@@ -68,6 +68,10 @@ type ReaderOptions struct {
 	// SubscriptionRolePrefix sets the subscription role prefix. The default prefix is "reader".
 	SubscriptionRolePrefix string
 
+	// SubscriptionName sets the subscription name.
+	// If subscriptionRolePrefix is set at the same time, this configuration will prevail
+	SubscriptionName string
+
 	// ReadCompacted, if enabled, the reader will read messages from the compacted topic rather than reading the
 	// full message backlog of the topic. This means that, if the topic has been compacted, the reader will only
 	// see the latest value for each key in the topic, up until the point in the topic message backlog that has
diff --git a/pulsar/reader_impl.go b/pulsar/reader_impl.go
index 596884a..dd552b6 100644
--- a/pulsar/reader_impl.go
+++ b/pulsar/reader_impl.go
@@ -66,11 +66,14 @@ func newReader(client *client, options ReaderOptions) (Reader, error) {
 		}
 	}
 
-	subscriptionName := options.SubscriptionRolePrefix
+	subscriptionName := options.SubscriptionName
 	if subscriptionName == "" {
-		subscriptionName = "reader"
+		subscriptionName = options.SubscriptionRolePrefix
+		if subscriptionName == "" {
+			subscriptionName = "reader"
+		}
+		subscriptionName += "-" + generateRandomName()
 	}
-	subscriptionName += "-" + generateRandomName()
 
 	receiverQueueSize := options.ReceiverQueueSize
 	if receiverQueueSize <= 0 {


Test patch:
diff --git a/pulsar/reader_test.go b/pulsar/reader_test.go
index aa12078..3c85871 100644
--- a/pulsar/reader_test.go
+++ b/pulsar/reader_test.go
@@ -24,6 +24,7 @@ import (
 	"time"
 
 	"github.com/apache/pulsar-client-go/pulsar/crypto"
+	"github.com/google/uuid"
 	"github.com/stretchr/testify/assert"
 )
 
@@ -48,6 +49,27 @@ func TestReaderConfigErrors(t *testing.T) {
 	assert.NotNil(t, err)
 }
 
+func TestReaderConfigSubscribeName(t *testing.T) {
+	client, err := NewClient(ClientOptions{
+		URL: lookupURL,
+	})
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer client.Close()
+
+	consumer, err := client.CreateReader(ReaderOptions{
+		StartMessageID:   EarliestMessageID(),
+		Topic:            uuid.New().String(),
+		SubscriptionName: uuid.New().String(),
+	})
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer consumer.Close()
+	assert.NotNil(t, consumer)
+}
+
 func TestReader(t *testing.T) {
 	client, err := NewClient(ClientOptions{
 		URL: lookupURL,
Repository: apache/rocketmq-client-go
Pull request #743 (2021-11-20 16:09:37)

[ISSUE #744] check multiple topics in one batch
## What is the purpose of the change
issue #744 
Because of the lack of pre-check, the message will be sent to the first topic when batch sending messages to multiple topics.

## Brief changelog

add check logic in func [ defaultProducer.checkMsg(msgs ...*primitive.Message) error ]




maixiaohai: @MaOreoreorui Good job! Could you create a related issue pls? 
MaOreoreorui: > @MaOreoreorui Good job! Could you create a related issue pls?

done 👨🏻‍💻
vongosling: Would you like to add a test for your pr?

Patch:
diff --git a/errors/errors.go b/errors/errors.go
index 793fcda..43b49ca 100644
--- a/errors/errors.go
+++ b/errors/errors.go
@@ -47,4 +47,5 @@ var (
 	ErrMessageEmpty      = errors.New("message is nil")
 	ErrNotRunning        = errors.New("producer not started")
 	ErrPullConsumer      = errors.New("pull consumer has not supported")
+	ErrMultipleTopics    = errors.New("the topic of the messages in one batch should be the same")
 )
diff --git a/producer/producer.go b/producer/producer.go
index 2ab2445..226eedb 100644
--- a/producer/producer.go
+++ b/producer/producer.go
@@ -103,6 +103,14 @@ func (p *defaultProducer) checkMsg(msgs ...*primitive.Message) error {
 	if len(msgs[0].Topic) == 0 {
 		return errors2.ErrTopicEmpty
 	}
+
+	topic := msgs[0].Topic
+	for _, msg := range msgs {
+		if msg.Topic != topic {
+			return errors2.ErrMultipleTopics
+		}
+	}
+
 	return nil
 }
 


Test patch:
diff --git a/producer/producer_test.go b/producer/producer_test.go
index b6ec84d..a7c15c1 100644
--- a/producer/producer_test.go
+++ b/producer/producer_test.go
@@ -310,3 +310,37 @@ func TestSyncWithNamespace(t *testing.T) {
 	assert.Equal(t, expectedResp, resp)
 	assert.Equal(t, namespaceTopic, msg.Topic)
 }
+
+func TestBatchSendDifferentTopics(t *testing.T) {
+	p, _ := NewDefaultProducer(
+		WithNsResolver(primitive.NewPassthroughResolver([]string{"127.0.0.1:9876"})),
+		WithRetry(2),
+		WithQueueSelector(NewManualQueueSelector()),
+	)
+
+	ctrl := gomock.NewController(t)
+	defer ctrl.Finish()
+	client := internal.NewMockRMQClient(ctrl)
+	p.client = client
+
+	client.EXPECT().RegisterProducer(gomock.Any(), gomock.Any()).Return()
+	client.EXPECT().Start().Return()
+	err := p.Start()
+	assert.Nil(t, err)
+
+	ctx := context.Background()
+	msgToA := &primitive.Message{
+		Topic: "topic-A",
+		Body:  []byte("this is a message body"),
+	}
+
+	msgToB := &primitive.Message{
+		Topic: "topic-B",
+		Body:  []byte("this is a message body"),
+	}
+
+	resp, err := p.SendSync(ctx, []*primitive.Message{msgToA, msgToB}...)
+	assert.Nil(t, resp)
+	assert.NotNil(t, err)
+	assert.Equal(t, err, errors.ErrMultipleTopics)
+}
Repository: osbuild/osbuild
Pull request #2026 (2025-02-20 20:07:34)

stages: ensure dirs for dracut configs are available
If the dracut config stage runs early the directory for the dracut config may not be available yet. So just create it.

[this is needed for the riscv work where we need to write the dracut config early, see https://github.com/osbuild/images/pull/1241]


Patch:
diff --git a/stages/org.osbuild.dracut.conf b/stages/org.osbuild.dracut.conf
index 912b07ef..0bedbf25 100755
--- a/stages/org.osbuild.dracut.conf
+++ b/stages/org.osbuild.dracut.conf
@@ -1,4 +1,5 @@
 #!/usr/bin/python3
+import os
 import sys
 
 import osbuild.api
@@ -32,6 +33,7 @@ def main(tree, options):
     filename = options["filename"]
 
     config_files_dir = f"{tree}/usr/lib/dracut/dracut.conf.d"
+    os.makedirs(config_files_dir, exist_ok=True)
 
     SUPPORTED_OPTIONS = {
         # simple string options


Test patch:
diff --git a/stages/test/test_dracut_conf.py b/stages/test/test_dracut_conf.py
new file mode 100644
index 00000000..c22aa12a
--- /dev/null
+++ b/stages/test/test_dracut_conf.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python3
+
+STAGE_NAME = "org.osbuild.dracut.conf"
+
+
+def test_dracut_conf_smoke(tmp_path, stage_module):
+    options = {
+        "filename": "qemu.conf",
+        "config": {
+            "add_drivers": ["virtio_blk"],
+        }
+    }
+
+    tree = tmp_path / "tree"
+    stage_module.main(tree, options)
+    expected_dracut_conf = tree / "usr/lib/dracut/dracut.conf.d/qemu.conf"
+    assert 'add_drivers+=" virtio_blk "\n' == expected_dracut_conf.read_text()
Repository: osbuild/osbuild
Pull request #2028 (2025-02-24 08:26:55)

Update images dependency ref to latest
Updating images dependency ref to current `main`



Patch:
diff --git a/Schutzfile b/Schutzfile
index 9cbc8156..b5cb013b 100644
--- a/Schutzfile
+++ b/Schutzfile
@@ -2,7 +2,7 @@
   "global": {
     "dependencies": {
       "images": {
-        "ref": "201158b13096d887861990bdb77fa048fc90cbe3"
+        "ref": "0d62970fed59a9bbb54ff1f89a9469f37f92c9fd"
       }
     }
   },
diff --git a/stages/org.osbuild.dracut.conf b/stages/org.osbuild.dracut.conf
index 912b07ef..0bedbf25 100755
--- a/stages/org.osbuild.dracut.conf
+++ b/stages/org.osbuild.dracut.conf
@@ -1,4 +1,5 @@
 #!/usr/bin/python3
+import os
 import sys
 
 import osbuild.api
@@ -32,6 +33,7 @@ def main(tree, options):
     filename = options["filename"]
 
     config_files_dir = f"{tree}/usr/lib/dracut/dracut.conf.d"
+    os.makedirs(config_files_dir, exist_ok=True)
 
     SUPPORTED_OPTIONS = {
         # simple string options


Test patch:
diff --git a/stages/test/test_dracut_conf.py b/stages/test/test_dracut_conf.py
new file mode 100644
index 00000000..c22aa12a
--- /dev/null
+++ b/stages/test/test_dracut_conf.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python3
+
+STAGE_NAME = "org.osbuild.dracut.conf"
+
+
+def test_dracut_conf_smoke(tmp_path, stage_module):
+    options = {
+        "filename": "qemu.conf",
+        "config": {
+            "add_drivers": ["virtio_blk"],
+        }
+    }
+
+    tree = tmp_path / "tree"
+    stage_module.main(tree, options)
+    expected_dracut_conf = tree / "usr/lib/dracut/dracut.conf.d/qemu.conf"
+    assert 'add_drivers+=" virtio_blk "\n' == expected_dracut_conf.read_text()
Repository: dwavesystems/dimod
Pull request #1383 (2024-08-15 17:05:35)

Catching ValueError when contracting variables in BQM with no interactions


Patch:
diff --git a/dimod/binary/binary_quadratic_model.py b/dimod/binary/binary_quadratic_model.py
index 5959037f..b548f900 100644
--- a/dimod/binary/binary_quadratic_model.py
+++ b/dimod/binary/binary_quadratic_model.py
@@ -1009,7 +1009,10 @@ class BinaryQuadraticModel(QuadraticViewsMixin):
         else:
             raise RuntimeError(f"unknown vartype: {self.vartype}")
 
-        self.remove_interaction(u, v)
+        try:
+            self.remove_interaction(u, v)
+        except ValueError:
+            pass
 
         # add all of v's interactions to u's
         for w, b in self.iter_neighborhood(v):
diff --git a/releasenotes/notes/BQM-no-interaction-var-contraction-14e2b6541373f12d.yaml b/releasenotes/notes/BQM-no-interaction-var-contraction-14e2b6541373f12d.yaml
new file mode 100644
index 00000000..4c66d013
--- /dev/null
+++ b/releasenotes/notes/BQM-no-interaction-var-contraction-14e2b6541373f12d.yaml
@@ -0,0 +1,5 @@
+---
+features:
+  - |
+    Allow  ``BinaryQuadraticModel.contract_variables()`` to contract variables without
+    an interaction. Previously it raised a ``ValueError``.


Test patch:
diff --git a/tests/test_bqm.py b/tests/test_bqm.py
index 5dd98f7c..466219df 100644
--- a/tests/test_bqm.py
+++ b/tests/test_bqm.py
@@ -717,6 +717,18 @@ class TestContractVariables(unittest.TestCase):
 
         assert_bqm_almost_equal(bqm, target, places=5)
 
+    @parameterized.expand(BQMs.items())
+    def test_no_interaction(self, name, BQM):
+        bqm = BQM({'a': 2, 'b': -8}, {('a', 'b'): -2, ('b', 'c'): 1}, 1.2,
+                  dimod.BINARY)
+
+        bqm.contract_variables('a', 'c')
+
+        assert_consistent_bqm(bqm)
+
+        target = BQM({'a': 2, 'b': -8}, {('a', 'b'): -1}, 1.2, dimod.BINARY)
+
+        self.assertEqual(bqm, target)
 
 class TestCoo(unittest.TestCase):
     @parameterized.expand(BQM_CLSs.items())
Repository: dwavesystems/dwave-cloud-client
Pull request #72 (2018-03-21 01:48:30)

Add few tests for Client factory


Patch:
diff --git a/dwave/cloud/client.py b/dwave/cloud/client.py
index ab9d7f3..6c3b218 100644
--- a/dwave/cloud/client.py
+++ b/dwave/cloud/client.py
@@ -126,7 +126,7 @@ class Client(object):
 
         from dwave.cloud import qpu, sw
         _clients = {'qpu': qpu.Client, 'sw': sw.Client}
-        _client = config.pop('client') or 'qpu'
+        _client = config.pop('client', None) or 'qpu'
         return _clients[_client](**config)
 
     def __init__(self, endpoint=None, token=None, solver=None, proxy=None,


Test patch:
diff --git a/tests/test_client.py b/tests/test_client.py
index 599d9c2..f889e08 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -7,9 +7,15 @@ from __future__ import absolute_import
 
 import unittest
 
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+
 from dwave.cloud.config import legacy_load_config
 from dwave.cloud.qpu import Client
 from dwave.cloud.exceptions import SolverAuthenticationError
+import dwave.cloud
 
 
 try:
@@ -75,5 +81,34 @@ class SolverLoading(unittest.TestCase):
         client.get_solver(config_solver)
 
 
+class ClientFactory(unittest.TestCase):
+    """Test client factory."""
+
+    def test_default(self):
+        conf = {k: k for k in 'endpoint token'.split()}
+        with mock.patch("dwave.cloud.client.load_config", lambda **kwargs: conf):
+            client = dwave.cloud.Client.from_config()
+            self.assertEqual(client.endpoint, 'endpoint')
+            self.assertEqual(client.token, 'token')
+            self.assertIsInstance(client, dwave.cloud.qpu.Client)
+            self.assertNotIsInstance(client, dwave.cloud.sw.Client)
+
+    def test_custom_kwargs(self):
+        conf = {k: k for k in 'endpoint token'.split()}
+        with mock.patch("dwave.cloud.client.load_config", lambda **kwargs: conf):
+            with mock.patch("dwave.cloud.client.Client.__init__", return_value=None) as init:
+                dwave.cloud.Client.from_config(custom='custom')
+                init.assert_called_once_with(
+                    endpoint='endpoint', token='token', custom='custom')
+
+    def test_custom_kwargs_overrides_config(self):
+        conf = {k: k for k in 'endpoint token custom'.split()}
+        with mock.patch("dwave.cloud.client.load_config", lambda **kwargs: conf):
+            with mock.patch("dwave.cloud.client.Client.__init__", return_value=None) as init:
+                dwave.cloud.Client.from_config(custom='new-custom')
+                init.assert_called_once_with(
+                    endpoint='endpoint', token='token', custom='new-custom')
+
+
 if __name__ == '__main__':
     unittest.main()
Repository: dwavesystems/dwave-cloud-client
Pull request #148 (2018-04-30 19:52:00)

Minor fixes


Patch:
diff --git a/dwave/cloud/solver.py b/dwave/cloud/solver.py
index 955c4bd..e063886 100644
--- a/dwave/cloud/solver.py
+++ b/dwave/cloud/solver.py
@@ -206,7 +206,7 @@ class Solver(object):
                 return False
         return True
 
-    def retrieve_problem(self, id_):
+    def _retrieve_problem(self, id_):
         """Resume polling for a problem previously submitted.
 
         Args:


Test patch:
diff --git a/tests/test_mock_submission.py b/tests/test_mock_submission.py
index 9e46d14..151ad09 100644
--- a/tests/test_mock_submission.py
+++ b/tests/test_mock_submission.py
@@ -339,8 +339,8 @@ class MockSubmission(_QueryTest):
             future = solver.sample_qubo({})
             future.result()
 
-            # after third poll, back-off interval should be 4
-            self.assertEqual(future._poll_backoff, 4)
+            # after third poll, back-off interval should be 4 x initial back-off
+            self.assertEqual(future._poll_backoff, Client._POLL_BACKOFF_MIN * 2**2)
 
     @mock.patch.object(Client, "_POLL_THREAD_COUNT", 1)
     @mock.patch.object(Client, "_SUBMISSION_THREAD_COUNT", 1)
@@ -425,7 +425,7 @@ class MockCancel(unittest.TestCase):
             client.session.delete = DeleteEvent.handle
 
             solver = Solver(client, solver_data('abc123'))
-            future = solver.retrieve_problem(submission_id)
+            future = solver._retrieve_problem(submission_id)
             future.cancel()
 
             try:
Repository: dwavesystems/dwave-cloud-client
Pull request #599 (2023-12-05 14:35:17)

Fix use of some deprecated functions
- datetime functions deprecated in py312
- np.bool8 deprecated in numpy 1.24


Patch:
diff --git a/dwave/cloud/utils.py b/dwave/cloud/utils.py
index 4680ade..bfdb93d 100644
--- a/dwave/cloud/utils.py
+++ b/dwave/cloud/utils.py
@@ -214,13 +214,13 @@ def datetime_to_timestamp(dt):
     Note: similar to `datetime.timestamp()` in Python 3.3+.
     """
 
-    epoch = datetime.utcfromtimestamp(0).replace(tzinfo=UTC)
+    epoch = datetime.fromtimestamp(0, tz=UTC)
     return (dt - epoch).total_seconds()
 
 
 def utcnow():
     """Returns tz-aware now in UTC."""
-    return datetime.utcnow().replace(tzinfo=UTC)
+    return datetime.now(tz=UTC)
 
 
 def epochnow() -> float:


Test patch:
diff --git a/tests/api/resources/test_problems.py b/tests/api/resources/test_problems.py
index dc722a0..ef60281 100644
--- a/tests/api/resources/test_problems.py
+++ b/tests/api/resources/test_problems.py
@@ -701,7 +701,7 @@ class NumpyParamsSerialization(unittest.TestCase):
 
     # basic scalar types we support for parameter values
     NUMPY_TYPES_AS_PYTHON = [
-        (numpy.bool_(1), True), (numpy.bool8(1), True),
+        (numpy.bool_(1), True),
         (numpy.byte(1), 1), (numpy.int8(1), 1),
         (numpy.ubyte(1), 1), (numpy.uint8(1), 1),
         (numpy.short(1), 1), (numpy.int16(1), 1),
diff --git a/tests/test_mock_submission.py b/tests/test_mock_submission.py
index b69ed3c..02dee3b 100644
--- a/tests/test_mock_submission.py
+++ b/tests/test_mock_submission.py
@@ -1079,7 +1079,7 @@ class TestSerialization(unittest.TestCase):
         return problems
 
     @parameterized.expand([
-        (numpy.bool_(1), True), (numpy.bool8(1), True),
+        (numpy.bool_(1), True),
         (numpy.byte(1), 1), (numpy.int8(1), 1),
         (numpy.ubyte(1), 1), (numpy.uint8(1), 1),
         (numpy.short(1), 1), (numpy.int16(1), 1),
diff --git a/tests/test_mock_unstructured_submission.py b/tests/test_mock_unstructured_submission.py
index 65244d7..00e37c8 100644
--- a/tests/test_mock_unstructured_submission.py
+++ b/tests/test_mock_unstructured_submission.py
@@ -418,7 +418,7 @@ class TestSerialization(unittest.TestCase):
         return _submit
 
     @parameterized.expand([
-        (numpy.bool_(1), True), (numpy.bool8(1), True),
+        (numpy.bool_(1), True),
         (numpy.byte(1), 1), (numpy.int8(1), 1),
         (numpy.ubyte(1), 1), (numpy.uint8(1), 1),
         (numpy.short(1), 1), (numpy.int16(1), 1),
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 06af973..413af5d 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -182,7 +182,7 @@ class TestSimpleUtils(unittest.TestCase):
 class TestNumpyTypesEncoding(unittest.TestCase):
 
     NUMPY_SCALARS = [
-        (numpy.bool_(1), True), (numpy.bool8(1), True),
+        (numpy.bool_(1), True),
         (numpy.byte(1), 1), (numpy.int8(1), 1),
         (numpy.ubyte(1), 1), (numpy.uint8(1), 1),
         (numpy.short(1), 1), (numpy.int16(1), 1),
Repository: dwavesystems/dwave-cloud-client
Pull request #674 (2024-10-25 19:19:26)

Avoid `sampleset.wait_id` overwrite with dimod 0.12.18+
This is to support the fix to [dwave-system#540](https://github.com/dwavesystems/dwave-system/issues/540) in [dimod#1393](https://github.com/dwavesystems/dimod/pull/1393).


Patch:
diff --git a/dwave/cloud/computation.py b/dwave/cloud/computation.py
index 8953bf9..bb02ba4 100644
--- a/dwave/cloud/computation.py
+++ b/dwave/cloud/computation.py
@@ -801,9 +801,12 @@ class Future(object):
             energy=self.energies, num_occurrences=self.num_occurrences,
             info=info, sort_labels=True)
 
-        # the id is stored in the info field, but to be consistent with
-        # the samplesets constructed .from_future, we add the method as well
-        sampleset.wait_id = self.wait_id
+        if not hasattr(sampleset, 'wait_id'):
+            # the id is stored in the info field, but to be consistent with the
+            # samplesets constructed .from_future, we add the method as well
+            # note: sampleset has .wait_id() since dimod 0.12.18+, but we want
+            # to support older dimods as well
+            sampleset.wait_id = self.wait_id
 
         # cache the constructed sampleset on computation, but don't prevent the
         # gc from collecting it if unused in parent closure
@@ -832,10 +835,12 @@ class Future(object):
 
         sampleset = dimod.SampleSet.from_future(self, lambda f: f.wait_sampleset())
 
-        # propagate id to sampleset as well
-        # note: this requires dimod>=0.8.21 (before that version SampleSet
-        # had slots set which prevented dynamic addition of attributes).
-        sampleset.wait_id = self.wait_id
+        if not hasattr(sampleset, 'wait_id'):
+            # the id is stored in the info field, but to be consistent with the
+            # samplesets constructed .from_future, we add the method as well
+            # note: sampleset has .wait_id() since dimod 0.12.18+, but we want
+            # to support older dimods as well
+            sampleset.wait_id = self.wait_id
 
         return sampleset
 


Test patch:
diff --git a/releasenotes/notes/fix-sampleset.wait_id-double-add-with-latest-dimod-e7aee85c0cd3b252.yaml b/releasenotes/notes/fix-sampleset.wait_id-double-add-with-latest-dimod-e7aee85c0cd3b252.yaml
new file mode 100644
index 0000000..939b920
--- /dev/null
+++ b/releasenotes/notes/fix-sampleset.wait_id-double-add-with-latest-dimod-e7aee85c0cd3b252.yaml
@@ -0,0 +1,9 @@
+---
+fixes:
+  - |
+    Update sample set creation in ``dwave.cloud.computation.Future`` to support
+    dimod 0.12.18+. Previously, ``wait_id()`` method used to be added to the
+    ``from_future``-created sample sets in the cloud-client, and now the ``SampleSet``
+    interface propagates ``wait_id`` from the future by default.
+    See `dimod#1392 <https://github.com/dwavesystems/dimod/issues/1392>`_ and
+    `dwave-system#540 <https://github.com/dwavesystems/dwave-system/issues/540>`_.