nebius/SWE-bench-extra huggingface dataset:
Repository: intelsdi-x/snap-plugin-lib-py

Issue:
Printing metric.config fails
Trying to print metric.config fails:
```
  File "/tmp/149768434/rootfs/.venv/lib/python3.5/site-packages/snap_plugin/v1/config_map.py", line 85, in __repr__  _module=plugin-exec io=stderr plugin=jolokia
    self._pb.FloatMap.items() + self._pb.BoolMap.items())  _module=plugin-exec io=stderr plugin=jolokia
TypeError: unsupported operand type(s) for +: 'ItemsView' and 'ItemsView'  _module=plugin-exec io=stderr plugin=jolokia
```
This sum in __repr__ method is incorrect:
https://github.com/intelsdi-x/snap-plugin-lib-py/blob/master/snap_plugin/v1/config_map.py#L84

Comments:

Patch:
diff --git a/snap_plugin/v1/config_map.py b/snap_plugin/v1/config_map.py
index eec7cc4..de4b64f 100644
--- a/snap_plugin/v1/config_map.py
+++ b/snap_plugin/v1/config_map.py
@@ -81,8 +81,10 @@ class ConfigMap(MutableMapping):
         raise KeyError(key)
 
     def __repr__(self):
-        return repr(self._pb.StringMap.items() + self._pb.IntMap.items() +
-                    self._pb.FloatMap.items() + self._pb.BoolMap.items())
+        return repr(dict(chain(self._pb.StringMap.items(),
+                               self._pb.IntMap.items(),
+                               self._pb.FloatMap.items(),
+                               self._pb.BoolMap.items())))
 
     def __len__(self):
         return (len(self._pb.IntMap) + len(self._pb.StringMap) +


Test patch:
diff --git a/snap_plugin/v1/tests/test_metric.py b/snap_plugin/v1/tests/test_metric.py
index dd2520e..21769e7 100644
--- a/snap_plugin/v1/tests/test_metric.py
+++ b/snap_plugin/v1/tests/test_metric.py
@@ -150,6 +150,10 @@ class TestMetric(object):
                 m.config["int"] == 1 and
                 m.config["bool"] is True)
 
+        # verify an error is not raised
+        # https://github.com/intelsdi-x/snap-plugin-lib-py/issues/12
+        repr(m.config)
+
         with pytest.raises(AttributeError) as excinfo:
                 m.config = ConfigMap()
         assert "can't set attribute" in str(excinfo.value)
Repository: intelsdi-x/snap-plugin-lib-py

Issue:
Setting a timestamp doesn't work
`metric.timestamp = time.time()` doesn't work as expected.  For instance, doing this in a collect doesn't result in the timestamp being updated throughout the rest of the workflow.

Comments:

Patch:
diff --git a/snap_plugin/v1/metric.py b/snap_plugin/v1/metric.py
index 26828ee..64c964b 100644
--- a/snap_plugin/v1/metric.py
+++ b/snap_plugin/v1/metric.py
@@ -106,6 +106,11 @@ class Metric(object):
         # timestamp
         self._timestamp = Timestamp(pb=self._pb.Timestamp,
                                     time=timestamp)
+
+        # this was added as a stop gap until
+        # https://github.com/intelsdi-x/snap/issues/1394 lands
+        self._last_advertised_time = Timestamp(pb=self._pb.LastAdvertisedTime,
+                                               time=timestamp)
         # data
         if "data" in kwargs:
             self.data = kwargs.get("data")
diff --git a/snap_plugin/v1/timestamp.py b/snap_plugin/v1/timestamp.py
index d977055..82465d4 100644
--- a/snap_plugin/v1/timestamp.py
+++ b/snap_plugin/v1/timestamp.py
@@ -35,7 +35,7 @@ class Timestamp(object):
         self._pb = pb
         self._time = time
         self._pb.sec = int(self._time)
-        self._pb.nsec = int(time - self.sec) * 10 ** 9
+        self._pb.nsec = int((self._time - self._pb.sec) * 10 ** 9)
 
     def __getattr__(self, attr):
         if attr in self.__dict__:
@@ -58,5 +58,5 @@ class Timestamp(object):
 
     def set(self, time):
         self._time = time
-        self.sec = int(time)
-        self.nsec = int(time-self.sec) * 10**9
+        self._pb.sec = int(self._time)
+        self._pb.nsec = int((self._time - self._pb.sec) * 10 ** 9)


Test patch:
diff --git a/snap_plugin/v1/tests/test_collector.py b/snap_plugin/v1/tests/test_collector.py
index 4123b54..53a62b7 100644
--- a/snap_plugin/v1/tests/test_collector.py
+++ b/snap_plugin/v1/tests/test_collector.py
@@ -41,6 +41,7 @@ class MockCollector(snap.Collector, threading.Thread):
 
     def collect(self, metrics):
         for metric in metrics:
+            metric.timestamp = time.time()
             metric.version = 2
             if "bytes" in metric.config and metric.config["bytes"] is True:
                 metric.data = b'qwerty'
@@ -144,6 +145,12 @@ def test_collect(collector_client):
     assert reply.metrics[0].Version == 2
     assert reply.metrics[0].float64_data == 99.9
     assert snap.Metric(pb=reply.metrics[0]).data == 99.9
+    reply2 = collector_client.CollectMetrics(MetricsArg(metric).pb)
+    assert (reply2.metrics[0].Timestamp.sec +
+            (reply2.metrics[0].Timestamp.nsec * 10 ** -9)) > (
+                reply.metrics[0].Timestamp.sec +
+                (reply.metrics[0].Timestamp.nsec * 10 ** -9))
+
 
     # collect bytes
     metric.config.clear()