diff --git a/.swagger-codegen-ignore b/.swagger-codegen-ignore index 740abad13e6f094e438aaecd285b0614f46d98ab..19e32ada7d435e9440b2031105940cfa8b5fff00 100644 --- a/.swagger-codegen-ignore +++ b/.swagger-codegen-ignore @@ -23,4 +23,4 @@ #!docs/README.md README.md requirements.txt -access_node/controllers/nest_controller.py \ No newline at end of file +#access_node/controllers/nest_controller.py \ No newline at end of file diff --git a/access_node/__main__.py b/access_node/__main__.py index 8a3103ba5ea6de886172797e06dff0897434aa2e..a5a15570626d27889c6a500f64e5d5a9838bdac7 100644 --- a/access_node/__main__.py +++ b/access_node/__main__.py @@ -4,20 +4,21 @@ import connexion from access_node import encoder -from access_node.models.nodes import simulation_nodes, info_node +from access_node.models.nodes import nodes import json import requests def main(): - # get simulation nodes + # get info node with open('access_node//info_node.json', 'r') as f: info = json.load(f) - info_node = info['address'] + nodes.info_node = info['address'] + # get simulation nodes node_type = 'nest_simulation' - simulation_nodes = requests.get(info_node+'/nodes', params={"node_type": node_type }).json() + nodes.simulation_nodes = requests.get(nodes.info_node+'/nodes', params={"node_type": node_type }).json() # run acces_node app = connexion.App(__name__, specification_dir='./swagger/') diff --git a/access_node/controllers/nest_controller.py b/access_node/controllers/nest_controller.py index 2b217b9b0011870a11d551d537f660c2f9fc7b54..2358256a280141509caea7f0c8795418dd868ad4 100644 --- a/access_node/controllers/nest_controller.py +++ b/access_node/controllers/nest_controller.py @@ -6,6 +6,7 @@ from access_node.models.simulation_time_info import SimulationTimeInfo # noqa: from access_node.models.spikes import Spikes # noqa: E501 from access_node import util +from access_node.models.nodes import nodes import requests @@ -15,9 +16,10 @@ def get_gids(): # noqa: E501 # noqa: E501 - :rtype: List[float] + :rtype: List[int] """ - return 'do some magic!' + gids = requests.get(nodes.info_node+'/gids').json() + return gids def get_gids_in_population(population_id): # noqa: E501 @@ -26,11 +28,12 @@ def get_gids_in_population(population_id): # noqa: E501 # noqa: E501 :param population_id: The identifier of the population - :type population_id: str + :type population_id: int - :rtype: List[float] + :rtype: List[int] """ - return 'do some magic!' + gids = requests.get(nodes.info_node+'/population/$'+str(population_id)+'/gids').json() + return gids def get_neuron_properties(gids=None): # noqa: E501 @@ -39,33 +42,36 @@ def get_neuron_properties(gids=None): # noqa: E501 # noqa: E501 :param gids: A list of GIDs queried for properties. - :type gids: List[] + :type gids: List[int] :rtype: List[NeuronProperties] """ - return 'do some magic!' + properties = requests.get(nodes.info_node+'/neuron_properties').json() + return properties def get_populations(): # noqa: E501 - """Retrieves the list of all populations. + """Retrieves the list of all population IDs. # noqa: E501 - :rtype: List[str] + :rtype: List[int] """ - return 'do some magic!' + time_info = requests.get(nodes.info_node+'/simulation_time_info').json() + return time_info -def get_simulation_step_count(): # noqa: E501 - """Retrieves the number of simulation steps. +def get_simulation_time_info(): # noqa: E501 + """Retrieves simulation time information. # noqa: E501 :rtype: SimulationTimeInfo """ - return 'do some magic!' + populations = requests.get(nodes.info_node+'/populations').json() + return populations def get_spikes(_from=None, to=None, gids=None, offset=None, limit=None): # noqa: E501 @@ -74,34 +80,30 @@ def get_spikes(_from=None, to=None, gids=None, offset=None, limit=None): # noqa # noqa: E501 :param _from: The start time (including) to be queried. - :type _from: + :type _from: float :param to: The end time (excluding) to be queried. - :type to: + :type to: float :param gids: A list of GIDs queried for spike data. - :type gids: List[] + :type gids: List[int] :param offset: The offset into the result. - :type offset: + :type offset: int :param limit: The maximum of entries to be result. - :type limit: + :type limit: int :rtype: Spikes """ - with open('access_node//distribution_nodes.json', 'r') as f: - dist_nodes = json.load(f) - simulation_nodes = dist_nodes['addresses'] - spikes = Spikes([], []) - for node in simulation_nodes: + for node in nodes.simulation_nodes: response = requests.get( node+'/spikes', params={"_from": _from, "to": to, "gids": gids}).json() - for x in range(len(response['simulation_steps'])): - spikes.simulation_steps.append(response['simulation_steps'][x]) + for x in range(len(response['simulation_times'])): + spikes.simulation_times.append(response['simulation_times'][x]) spikes.neuron_ids.append(response['neuron_ids'][x]) # sort - sorted_ids = [x for _,x in sorted(zip(spikes.simulation_steps, spikes.neuron_ids))] + sorted_ids = [x for _,x in sorted(zip(spikes.simulation_times, spikes.neuron_ids))] spikes.neuron_ids = sorted_ids - spikes.simulation_steps.sort() + spikes.simulation_times.sort() # offset and limit if (offset is None): @@ -109,7 +111,7 @@ def get_spikes(_from=None, to=None, gids=None, offset=None, limit=None): # noqa if (limit is None): limit = len(spikes.neuron_ids) spikes.neuron_ids = spikes.neuron_ids[offset:limit] - spikes.simulation_steps = spikes.simulation_steps[offset:limit] + spikes.simulation_times = spikes.simulation_times[offset:limit] return spikes @@ -120,34 +122,30 @@ def get_spikes_by_population(population_id, _from=None, to=None, offset=None, li # noqa: E501 :param population_id: The identifier of the population. - :type population_id: str + :type population_id: int :param _from: The start time (including) to be queried. - :type _from: + :type _from: float :param to: The end time (excluding) to be queried. - :type to: + :type to: float :param offset: The offset into the result. - :type offset: + :type offset: int :param limit: The maximum of entries to be result. - :type limit: + :type limit: int :rtype: Spikes """ - with open('access_node//distribution_nodes.json', 'r') as f: - dist_nodes = json.load(f) - simulation_nodes = dist_nodes['addresses'] - spikes = Spikes([], []) - for node in simulation_nodes: + for node in nodes.simulation_nodes: response = requests.get( node+'/population/'+population_id+'/spikes', params={"_from": _from, "to": to}).json() - for x in range(len(response['simulation_steps'])): - spikes.simulation_steps.append(response['simulation_steps'][x]) + for x in range(len(response['simulation_times'])): + spikes.simulation_times.append(response['simulation_times'][x]) spikes.neuron_ids.append(response['neuron_ids'][x]) # sort - sorted_ids = [x for _,x in sorted(zip(spikes.simulation_steps, spikes.neuron_ids))] + sorted_ids = [x for _,x in sorted(zip(spikes.simulation_times, spikes.neuron_ids))] spikes.neuron_ids = sorted_ids - spikes.simulation_steps.sort() + spikes.simulation_times.sort() # offset and limit if (offset is None): @@ -155,7 +153,7 @@ def get_spikes_by_population(population_id, _from=None, to=None, offset=None, li if (limit is None): limit = len(spikes.neuron_ids) spikes.neuron_ids = spikes.neuron_ids[offset:limit] - spikes.simulation_steps = spikes.simulation_steps[offset:limit] + spikes.simulation_times = spikes.simulation_times[offset:limit] return spikes diff --git a/access_node/models/neuron_properties.py b/access_node/models/neuron_properties.py index c52a861759cc04508486739ed8afc4c936d16245..75f78592d6a0961e4cf403e0e99d1de161e6c770 100644 --- a/access_node/models/neuron_properties.py +++ b/access_node/models/neuron_properties.py @@ -15,16 +15,16 @@ class NeuronProperties(Model): Do not edit the class manually. """ - def __init__(self, gid: float=None, properties: object=None): # noqa: E501 + def __init__(self, gid: int=None, properties: object=None): # noqa: E501 """NeuronProperties - a model defined in Swagger :param gid: The gid of this NeuronProperties. # noqa: E501 - :type gid: float + :type gid: int :param properties: The properties of this NeuronProperties. # noqa: E501 :type properties: object """ self.swagger_types = { - 'gid': float, + 'gid': int, 'properties': object } @@ -48,22 +48,22 @@ class NeuronProperties(Model): return util.deserialize_model(dikt, cls) @property - def gid(self) -> float: + def gid(self) -> int: """Gets the gid of this NeuronProperties. :return: The gid of this NeuronProperties. - :rtype: float + :rtype: int """ return self._gid @gid.setter - def gid(self, gid: float): + def gid(self, gid: int): """Sets the gid of this NeuronProperties. :param gid: The gid of this NeuronProperties. - :type gid: float + :type gid: int """ self._gid = gid diff --git a/access_node/models/nodes.py b/access_node/models/nodes.py index 1cc6e15d8af5fcad32b7b4c1f259fc928cbe5422..2da37ca1713b0bc2fe3f2e2cca854d9eee2130e9 100644 --- a/access_node/models/nodes.py +++ b/access_node/models/nodes.py @@ -1,3 +1,8 @@ -simulation_nodes = ["hallo"] +from typing import List -info_node = "" \ No newline at end of file +class Nodes(object): + def __init__(self, info_node: str=None, simulation_nodes: List[str]=None): + self.info_node = info_node + self.simulation_nodes = simulation_nodes + +nodes = Nodes() diff --git a/access_node/models/simulation_time_info.py b/access_node/models/simulation_time_info.py index a6b3019b907b15738e217b92aacf8bdec6437290..5d379a4a3335875e3e97af0cac6201e960738cb4 100644 --- a/access_node/models/simulation_time_info.py +++ b/access_node/models/simulation_time_info.py @@ -15,7 +15,7 @@ class SimulationTimeInfo(Model): Do not edit the class manually. """ - def __init__(self, start: float=None, end: float=None, current: float=None, timestep: float=None): # noqa: E501 + def __init__(self, start: float=None, end: float=None, current: float=None): # noqa: E501 """SimulationTimeInfo - a model defined in Swagger :param start: The start of this SimulationTimeInfo. # noqa: E501 @@ -24,27 +24,22 @@ class SimulationTimeInfo(Model): :type end: float :param current: The current of this SimulationTimeInfo. # noqa: E501 :type current: float - :param timestep: The timestep of this SimulationTimeInfo. # noqa: E501 - :type timestep: float """ self.swagger_types = { 'start': float, 'end': float, - 'current': float, - 'timestep': float + 'current': float } self.attribute_map = { 'start': 'start', 'end': 'end', - 'current': 'current', - 'timestep': 'timestep' + 'current': 'current' } self._start = start self._end = end self._current = current - self._timestep = timestep @classmethod def from_dict(cls, dikt) -> 'SimulationTimeInfo': @@ -119,24 +114,3 @@ class SimulationTimeInfo(Model): """ self._current = current - - @property - def timestep(self) -> float: - """Gets the timestep of this SimulationTimeInfo. - - - :return: The timestep of this SimulationTimeInfo. - :rtype: float - """ - return self._timestep - - @timestep.setter - def timestep(self, timestep: float): - """Sets the timestep of this SimulationTimeInfo. - - - :param timestep: The timestep of this SimulationTimeInfo. - :type timestep: float - """ - - self._timestep = timestep diff --git a/access_node/models/spikes.py b/access_node/models/spikes.py index 0762236cfa2bb8c99b4272a73223d397368eaca8..b46505f539aa7f1ae3d4dddd98418c7bec009600 100644 --- a/access_node/models/spikes.py +++ b/access_node/models/spikes.py @@ -15,25 +15,25 @@ class Spikes(Model): Do not edit the class manually. """ - def __init__(self, simulation_steps: List[float]=None, gids: List[float]=None): # noqa: E501 + def __init__(self, simulation_times: List[float]=None, gids: List[int]=None): # noqa: E501 """Spikes - a model defined in Swagger - :param simulation_steps: The simulation_steps of this Spikes. # noqa: E501 - :type simulation_steps: List[float] + :param simulation_times: The simulation_times of this Spikes. # noqa: E501 + :type simulation_times: List[float] :param gids: The gids of this Spikes. # noqa: E501 - :type gids: List[float] + :type gids: List[int] """ self.swagger_types = { - 'simulation_steps': List[float], - 'gids': List[float] + 'simulation_times': List[float], + 'gids': List[int] } self.attribute_map = { - 'simulation_steps': 'simulation_steps', + 'simulation_times': 'simulation_times', 'gids': 'gids' } - self._simulation_steps = simulation_steps + self._simulation_times = simulation_times self._gids = gids @classmethod @@ -48,45 +48,45 @@ class Spikes(Model): return util.deserialize_model(dikt, cls) @property - def simulation_steps(self) -> List[float]: - """Gets the simulation_steps of this Spikes. + def simulation_times(self) -> List[float]: + """Gets the simulation_times of this Spikes. This array is always sorted. # noqa: E501 - :return: The simulation_steps of this Spikes. + :return: The simulation_times of this Spikes. :rtype: List[float] """ - return self._simulation_steps + return self._simulation_times - @simulation_steps.setter - def simulation_steps(self, simulation_steps: List[float]): - """Sets the simulation_steps of this Spikes. + @simulation_times.setter + def simulation_times(self, simulation_times: List[float]): + """Sets the simulation_times of this Spikes. This array is always sorted. # noqa: E501 - :param simulation_steps: The simulation_steps of this Spikes. - :type simulation_steps: List[float] + :param simulation_times: The simulation_times of this Spikes. + :type simulation_times: List[float] """ - self._simulation_steps = simulation_steps + self._simulation_times = simulation_times @property - def gids(self) -> List[float]: + def gids(self) -> List[int]: """Gets the gids of this Spikes. :return: The gids of this Spikes. - :rtype: List[float] + :rtype: List[int] """ return self._gids @gids.setter - def gids(self, gids: List[float]): + def gids(self, gids: List[int]): """Sets the gids of this Spikes. :param gids: The gids of this Spikes. - :type gids: List[float] + :type gids: List[int] """ self._gids = gids diff --git a/access_node/swagger/swagger.yaml b/access_node/swagger/swagger.yaml index 63b380b26909a6a57067b766a84ac70c7bb39543..13f7feec99343ab3d1ff280da80641de0581e9c2 100644 --- a/access_node/swagger/swagger.yaml +++ b/access_node/swagger/swagger.yaml @@ -14,8 +14,8 @@ paths: get: tags: - "nest" - summary: "Retrieves the number of simulation steps." - operationId: "get_simulation_step_count" + summary: "Retrieves simulation time information." + operationId: "get_simulation_time_info" produces: - "application/json" parameters: [] @@ -45,7 +45,7 @@ paths: schema: type: "array" items: - type: "number" + type: "integer" format: "uint64" 400: description: "Operation failed." @@ -68,7 +68,7 @@ paths: required: false type: "array" items: - type: "number" + type: "integer" format: "uint64" responses: 200: @@ -87,7 +87,7 @@ paths: get: tags: - "nest" - summary: "Retrieves the list of all populations." + summary: "Retrieves the list of all population IDs." operationId: "get_populations" produces: - "application/json" @@ -98,7 +98,8 @@ paths: schema: type: "array" items: - type: "string" + type: "integer" + format: "uint64" 400: description: "Operation failed." schema: @@ -122,32 +123,32 @@ paths: description: "The start time (including) to be queried." required: false type: "number" - format: "uint64" + format: "double" - name: "to" in: "query" description: "The end time (excluding) to be queried." required: false type: "number" - format: "uint64" + format: "double" - name: "gids" in: "query" description: "A list of GIDs queried for spike data." required: false type: "array" items: - type: "number" + type: "integer" format: "uint64" - name: "offset" in: "query" description: "The offset into the result." required: false - type: "number" + type: "integer" format: "uint64" - name: "limit" in: "query" description: "The maximum of entries to be result." required: false - type: "number" + type: "integer" format: "uint64" responses: 200: @@ -176,30 +177,31 @@ paths: in: "path" description: "The identifier of the population." required: true - type: "string" + type: "integer" + format: "uint64" - name: "from" in: "query" description: "The start time (including) to be queried." required: false type: "number" - format: "uint64" + format: "double" - name: "to" in: "query" description: "The end time (excluding) to be queried." required: false type: "number" - format: "uint64" + format: "double" - name: "offset" in: "query" description: "The offset into the result." required: false - type: "number" + type: "integer" format: "uint64" - name: "limit" in: "query" description: "The maximum of entries to be result." required: false - type: "number" + type: "integer" format: "uint64" responses: 200: @@ -225,14 +227,15 @@ paths: in: "path" description: "The identifier of the population" required: true - type: "string" + type: "integer" + format: "uint64" responses: 200: description: "Operation successful." schema: type: "array" items: - type: "number" + type: "integer" format: "uint64" 400: description: "Operation failed." @@ -244,19 +247,19 @@ definitions: Spikes: type: "object" properties: - simulation_steps: + simulation_times: type: "array" description: "This array is always sorted." items: type: "number" - format: "uint64" + format: "double" gids: type: "array" items: - type: "number" + type: "integer" format: "uint64" example: - simulation_steps: + simulation_times: - 0.8008281904610115 - 0.8008281904610115 gids: @@ -266,7 +269,7 @@ definitions: type: "object" properties: gid: - type: "number" + type: "integer" format: "uint64" properties: type: "object" @@ -282,18 +285,14 @@ definitions: properties: start: type: "number" - format: "uint64" + format: "double" end: type: "number" - format: "uint64" + format: "double" current: - type: "number" - format: "uint64" - timestep: type: "number" format: "double" example: current: 1.4658129805029452 - timestep: 5.962133916683182 start: 0.8008281904610115 end: 6.027456183070403