From d692548f635c50b4eab75026670bb540a74ea2a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20M=C3=BCller?= <j.mueller@vr.rwth-aachen.de>
Date: Thu, 26 Sep 2019 16:46:20 +0200
Subject: [PATCH] Update Data layout

---
 access_node/controllers/nest_controller.py | 11 ++--
 access_node/models/data.py                 | 72 +++++++++++++++-------
 access_node/swagger/swagger.yaml           | 32 ++++++----
 3 files changed, 72 insertions(+), 43 deletions(-)

diff --git a/access_node/controllers/nest_controller.py b/access_node/controllers/nest_controller.py
index cd78ddd..c3144b1 100644
--- a/access_node/controllers/nest_controller.py
+++ b/access_node/controllers/nest_controller.py
@@ -48,22 +48,19 @@ def get_data(attribute, simulation_steps=None, neuron_ids=None):  # noqa: E501
     addresses = dist_nodes['addresses']
 
     if simulation_steps != None:
+        num_ts = len(simulation_steps)
         first_ts = simulation_steps[0]
-        last_ts = simulation_steps[-1]
-        num_ts = 
     else:
+        num_ts = get_simulation_step_count()
         first_ts = get_timestep()
-        last_ts = first_ts * get_simulation_step_count()
-        count = get_simulation_step_count()
-        timesteps = [first_ts*x for x in range(count)]
 
     if neuron_ids != None:
         ids = neuron_ids
     else:
         ids = get_neuron_ids()
 
-    data = Data([timesteps[0], timesteps[-1]], ids,
-                [[None]*len(timesteps) for x in range(len(ids))])
+    data = Data(first_ts, num_ts, ids,
+                [[None]*num_ts for x in range(len(ids))])
     for address in addresses:
         response = requests.get(address+'/data', params={
                                 "attribute": attribute, "simulation_steps": simulation_steps, "neuron_ids": neuron_ids}).json()
diff --git a/access_node/models/data.py b/access_node/models/data.py
index e1ac4a7..690de21 100644
--- a/access_node/models/data.py
+++ b/access_node/models/data.py
@@ -15,29 +15,34 @@ class Data(Model):
     Do not edit the class manually.
     """
 
-    def __init__(self, simulation_steps: List[float]=None, neuron_ids: List[float]=None, values: List[float]=None):  # noqa: E501
+    def __init__(self, first_simulation_step: float=None, num_simulation_steps: float=None, neuron_ids: List[float]=None, values: List[List[float]]=None):  # noqa: E501
         """Data - a model defined in Swagger
 
-        :param simulation_steps: The simulation_steps of this Data.  # noqa: E501
-        :type simulation_steps: List[float]
+        :param first_simulation_step: The first_simulation_step of this Data.  # noqa: E501
+        :type first_simulation_step: float
+        :param num_simulation_steps: The num_simulation_steps of this Data.  # noqa: E501
+        :type num_simulation_steps: float
         :param neuron_ids: The neuron_ids of this Data.  # noqa: E501
         :type neuron_ids: List[float]
         :param values: The values of this Data.  # noqa: E501
-        :type values: List[float]
+        :type values: List[List[float]]
         """
         self.swagger_types = {
-            'simulation_steps': List[float],
+            'first_simulation_step': float,
+            'num_simulation_steps': float,
             'neuron_ids': List[float],
-            'values': List[float]
+            'values': List[List[float]]
         }
 
         self.attribute_map = {
-            'simulation_steps': 'simulation_steps',
+            'first_simulation_step': 'first_simulation_step',
+            'num_simulation_steps': 'num_simulation_steps',
             'neuron_ids': 'neuron_ids',
             'values': 'values'
         }
 
-        self._simulation_steps = simulation_steps
+        self._first_simulation_step = first_simulation_step
+        self._num_simulation_steps = num_simulation_steps
         self._neuron_ids = neuron_ids
         self._values = values
 
@@ -53,25 +58,46 @@ class Data(Model):
         return util.deserialize_model(dikt, cls)
 
     @property
-    def simulation_steps(self) -> List[float]:
-        """Gets the simulation_steps of this Data.
+    def first_simulation_step(self) -> float:
+        """Gets the first_simulation_step of this Data.
 
 
-        :return: The simulation_steps of this Data.
-        :rtype: List[float]
+        :return: The first_simulation_step of this Data.
+        :rtype: float
+        """
+        return self._first_simulation_step
+
+    @first_simulation_step.setter
+    def first_simulation_step(self, first_simulation_step: float):
+        """Sets the first_simulation_step of this Data.
+
+
+        :param first_simulation_step: The first_simulation_step of this Data.
+        :type first_simulation_step: float
+        """
+
+        self._first_simulation_step = first_simulation_step
+
+    @property
+    def num_simulation_steps(self) -> float:
+        """Gets the num_simulation_steps of this Data.
+
+
+        :return: The num_simulation_steps of this Data.
+        :rtype: float
         """
-        return self._simulation_steps
+        return self._num_simulation_steps
 
-    @simulation_steps.setter
-    def simulation_steps(self, simulation_steps: List[float]):
-        """Sets the simulation_steps of this Data.
+    @num_simulation_steps.setter
+    def num_simulation_steps(self, num_simulation_steps: float):
+        """Sets the num_simulation_steps of this Data.
 
 
-        :param simulation_steps: The simulation_steps of this Data.
-        :type simulation_steps: List[float]
+        :param num_simulation_steps: The num_simulation_steps of this Data.
+        :type num_simulation_steps: float
         """
 
-        self._simulation_steps = simulation_steps
+        self._num_simulation_steps = num_simulation_steps
 
     @property
     def neuron_ids(self) -> List[float]:
@@ -95,22 +121,22 @@ class Data(Model):
         self._neuron_ids = neuron_ids
 
     @property
-    def values(self) -> List[float]:
+    def values(self) -> List[List[float]]:
         """Gets the values of this Data.
 
 
         :return: The values of this Data.
-        :rtype: List[float]
+        :rtype: List[List[float]]
         """
         return self._values
 
     @values.setter
-    def values(self, values: List[float]):
+    def values(self, values: List[List[float]]):
         """Sets the values of this Data.
 
 
         :param values: The values of this Data.
-        :type values: List[float]
+        :type values: List[List[float]]
         """
 
         self._values = values
diff --git a/access_node/swagger/swagger.yaml b/access_node/swagger/swagger.yaml
index 23ff927..a5d4fab 100644
--- a/access_node/swagger/swagger.yaml
+++ b/access_node/swagger/swagger.yaml
@@ -197,11 +197,12 @@ definitions:
   Data:
     type: "object"
     properties:
-      simulation_steps:
-        type: "array"
-        items:
-          type: "number"
-          format: "int64"
+      first_simulation_step:
+        type: "number"
+        format: "int64"
+      num_simulation_steps:
+        type: "number"
+        format: "int64"
       neuron_ids:
         type: "array"
         items:
@@ -210,14 +211,19 @@ definitions:
       values:
         type: "array"
         items:
-          type: "number"
+          type: "array"
+          items:
+            type: "number"
     example:
-      simulation_steps:
-      - 0.1
-      - 0.2
+      first_simulation_step:
+      - 1
+      num_simulation_steps:
+      - 2
       values:
-      - 61.48
-      - 13.46
+      - - 61.48
+        - 45.23
+      - - 13.46
+        - 23.77
       neuron_ids:
       - 1
       - 2
@@ -236,8 +242,8 @@ definitions:
           format: "int64"
     example:
       simulation_steps:
-      - 0.1
-      - 0.2
+      - 2
+      - 5
       neuron_ids:
       - 1
       - 2
-- 
GitLab