Skip to content
Snippets Groups Projects
Commit c3b790b9 authored by Jan Müller's avatar Jan Müller
Browse files

Update swagger.yaml and implement all missing functionality

parent 20e940d4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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/')
......
......@@ -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
......@@ -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
......
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()
......@@ -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
......@@ -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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment