From 37c39c353dfbf585827a0c7bc5cf85a7d590c7a6 Mon Sep 17 00:00:00 2001
From: Jeffrey Wigger <jeffrey.wigger@epfl.ch>
Date: Tue, 10 May 2022 11:37:19 +0200
Subject: [PATCH] Measuring the metadata correctly

---
 src/decentralizepy/communication/TCP.py       | 26 ++++++++-----------
 .../sharing/RandomAlphaWavelet.py             |  2 +-
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/decentralizepy/communication/TCP.py b/src/decentralizepy/communication/TCP.py
index 58cc55d..6d72e1c 100644
--- a/src/decentralizepy/communication/TCP.py
+++ b/src/decentralizepy/communication/TCP.py
@@ -131,27 +131,23 @@ class TCP(Communication):
         if self.compress:
             if "indices" in data:
                 data["indices"] = self.compressor.compress(data["indices"])
-                meta_len = len(
-                    pickle.dumps(data["indices"])
-                )  # ONLY necessary for the statistics
-            else:
-                meta_len = 0
-            if "params" in data:
-                data["params"] = self.compressor.compress_float(data["params"])
+
+            assert "params" in data
+            data["params"] = self.compressor.compress_float(data["params"])
+            data_len = len(pickle.dumps(data["params"]))
             output = pickle.dumps(data)
+
             # the compressed meta data gets only a few bytes smaller after pickling
-            self.total_meta += meta_len
-            self.total_data += len(output) - meta_len
+            self.total_meta += len(output) - data_len
+            self.total_data += data_len
         else:
             output = pickle.dumps(data)
             # centralized testing uses its own instance
             if type(data) == dict:
-                if "indices" in data:
-                    meta_len = len(pickle.dumps(data["indices"]))
-                else:
-                    meta_len = 0
-                self.total_meta += meta_len
-                self.total_data += len(output) - meta_len
+                assert "params" in data
+                data_len = len(pickle.dumps(data["params"]))
+                self.total_meta += len(output) - data_len
+                self.total_data += data_len
         return output
 
     def decrypt(self, sender, data):
diff --git a/src/decentralizepy/sharing/RandomAlphaWavelet.py b/src/decentralizepy/sharing/RandomAlphaWavelet.py
index 62bc51f..44ea336 100644
--- a/src/decentralizepy/sharing/RandomAlphaWavelet.py
+++ b/src/decentralizepy/sharing/RandomAlphaWavelet.py
@@ -19,7 +19,7 @@ class RandomAlpha(Wavelet):
         model,
         dataset,
         log_dir,
-        alpha_list=[0.1, 0.2, 0.3, 0.4, 1.0],
+        alpha_list="[0.1, 0.2, 0.3, 0.4, 1.0]",
         dict_ordered=True,
         save_shared=False,
         metadata_cap=1.0,
-- 
GitLab