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

Update API

parent 8dcf5d5a
Branches
Tags
1 merge request!4Feature/add arbor support
......@@ -3,7 +3,7 @@ Public access server providing a REST API for the in-situ pipeline.
To generate execute this from the projects root dir:
```
java -jar <path/to/swagger-codegen-cli.2.4.8.jar> generate -i access_node/swagger/swagger.yaml -l python-flask -c config.json
java -jar swagger-codegen-cli-2.4.8.jar generate -i access_node/swagger/swagger.yaml -l python-flask -c config.json
```
# Swagger generated server
......
import connexion
import six
from access_node.models.arbor_cell_properties import ArborCellProperties # noqa: E501
from access_node.models.arbor_measurement import ArborMeasurement # noqa: E501
from access_node.models.arbor_neuron_properties import ArborNeuronProperties # noqa: E501
from access_node.models.simulation_time_info import SimulationTimeInfo # noqa: E501
from access_node.models.spikes import Spikes # noqa: E501
from access_node import util
def arbor_get_attributes(): # noqa: E501
"""Retrieves a list of measurable attributes
def arbor_get_cell_ids(): # noqa: E501
"""Retrieves the list of all cell ids.
# noqa: E501
:rtype: List[str]
:rtype: List[int]
"""
return 'do some magic!'
def arbor_get_measurements(attribute, _from=None, to=None, neuron_ids=None, offset=None, limit=None): # noqa: E501
"""Retrieves the measurements for given attribute and neuron_ids (optional).
def arbor_get_cell_properties(neuron_ids=None): # noqa: E501
"""Retrieves the properties of the specified cells.
# noqa: E501
:param neuron_ids: A list of cell IDs queried for properties.
:type neuron_ids: List[int]
:rtype: List[ArborCellProperties]
"""
return 'do some magic!'
def arbor_get_measurements(attribute, measurement_point_id=None, _from=None, to=None, offset=None, limit=None): # noqa: E501
"""Retrieves the measurements for given measurement points (optional).
# noqa: E501
:param attribute: The attribute to query (e.g., &#39;V_m&#39; for the membrane potential)
:type attribute: str
:param measurement_point_id: A list of measurement point ids queried for data.
:type measurement_point_id: List[int]
:param _from: The start time (including) to be queried.
:type _from: float
:param to: The end time (excluding) to be queried.
:type to: float
:param neuron_ids: A list of GIDs queried for spike data.
:type neuron_ids: List[int]
:param offset: The offset into the result.
:type offset: int
:param limit: The maximum of entries to be result.
......@@ -42,30 +55,6 @@ def arbor_get_measurements(attribute, _from=None, to=None, neuron_ids=None, offs
return 'do some magic!'
def arbor_get_neuron_ids(): # noqa: E501
"""Retrieves the list of all neuron ids.
# noqa: E501
:rtype: List[int]
"""
return 'do some magic!'
def arbor_get_neuron_properties(neuron_ids=None): # noqa: E501
"""Retrieves the properties of the specified neurons.
# noqa: E501
:param neuron_ids: A list of neuron IDs queried for properties.
:type neuron_ids: List[int]
:rtype: List[ArborNeuronProperties]
"""
return 'do some magic!'
def arbor_get_simulation_time_info(): # noqa: E501
"""Retrieves simulation time information.
......@@ -78,7 +67,7 @@ def arbor_get_simulation_time_info(): # noqa: E501
def arbor_get_spikes(_from=None, to=None, gids=None, offset=None, limit=None): # noqa: E501
"""Retrieves the spikes for the given simulation steps (optional) and GIDS (optional).
"""Retrieves the spikes for the given simulation steps (optional) and cells (optional).
# noqa: E501
......@@ -86,7 +75,7 @@ def arbor_get_spikes(_from=None, to=None, gids=None, offset=None, limit=None):
:type _from: float
:param to: The end time (excluding) to be queried.
:type to: float
:param gids: A list of GIDs queried for spike data.
:param gids: A list of cells queried for spike data.
:type gids: List[int]
:param offset: The offset into the result.
:type offset: int
......
......@@ -24,7 +24,7 @@ def nest_get_gids(): # noqa: E501
def nest_get_gids_in_population(population_id): # noqa: E501
"""Retrieves the list of all neuron IDs.
"""Retrieves the list of all neuron IDs within the population.
# noqa: E501
......@@ -40,7 +40,7 @@ def nest_get_gids_in_population(population_id): # noqa: E501
def nest_get_multimeter_info(): # noqa: E501
"""Retreives the available multimeters and their properties.
# noqa: E501
......@@ -51,7 +51,7 @@ def nest_get_multimeter_info(): # noqa: E501
def nest_get_multimeter_measurements(multimeter_id, attribute, _from=None, to=None, gids=None, offset=None, limit=None): # noqa: E501
"""Retrieves the measurements for a multimeter (optional) and GIDS (optional).
"""Retrieves the measurements for a multimeter, attribute and GIDS (optional).
# noqa: E501
......@@ -95,20 +95,22 @@ def nest_get_multimeter_measurements(multimeter_id, attribute, _from=None, to=No
init = True
sim_times = []
measurement = MultimeterMeasurement([],[],[])
measurement = MultimeterMeasurement([], [], [])
for node in nodes.simulation_nodes:
response = requests.get(
'http://'+node+'/multimeter_measurement', params={"multimeter_id": multimeter_id, "attribute": attribute, "_from": _from, "to": to, "gids": gids}).json()
if init:
sim_times = response['simulation_times']
measurement = MultimeterMeasurement(sim_times, gids, [None for x in range(0,(len(sim_times)*len(gids)))])
measurement = MultimeterMeasurement(
sim_times, gids, [None for x in range(0, (len(sim_times)*len(gids)))])
init = False
for x in range(len(response['gids'])):
gid = response['gids'][x]
index = measurement.gids.index(gid)
index_offset = index * len(sim_times)
for y in range(len(sim_times)):
measurement.values[index_offset+y] = response['values'][x*len(sim_times)+y]
measurement.values[index_offset +
y] = response['values'][x*len(sim_times)+y]
# offset and limit
if (offset is None):
......@@ -116,7 +118,8 @@ def nest_get_multimeter_measurements(multimeter_id, attribute, _from=None, to=No
if (limit is None or (limit + offset) > len(measurement.gids)):
limit = len(measurement.gids) - offset
measurement.gids = measurement.gids[offset:offset+limit]
measurement.values = measurement.values[offset*len(sim_times):(offset+limit)*len(sim_times)]
measurement.values = measurement.values[offset *
len(sim_times):(offset+limit)*len(sim_times)]
return measurement
......
......@@ -3,8 +3,9 @@
# flake8: noqa
from __future__ import absolute_import
# import models into model package
from access_node.models.arbor_cell_properties import ArborCellProperties
from access_node.models.arbor_measurement import ArborMeasurement
from access_node.models.arbor_neuron_properties import ArborNeuronProperties
from access_node.models.measurement_point import MeasurementPoint
from access_node.models.multimeter_info import MultimeterInfo
from access_node.models.multimeter_info_inner import MultimeterInfoInner
from access_node.models.multimeter_measurement import MultimeterMeasurement
......
......@@ -15,7 +15,7 @@ paths:
tags:
- "arbor"
summary: "Retrieves the spikes for the given simulation steps (optional) and\
\ GIDS (optional)."
\ cells (optional)."
operationId: "arbor_get_spikes"
consumes:
- "application/json"
......@@ -36,7 +36,7 @@ paths:
format: "double"
- name: "gids"
in: "query"
description: "A list of GIDs queried for spike data."
description: "A list of cells queried for spike data."
required: false
type: "array"
items:
......@@ -65,12 +65,12 @@ paths:
type: "string"
example: "Error message"
x-swagger-router-controller: "access_node.controllers.arbor_controller"
/arbor/neuron_ids:
/arbor/cell_ids:
get:
tags:
- "arbor"
summary: "Retrieves the list of all neuron ids."
operationId: "arbor_get_neuron_ids"
summary: "Retrieves the list of all cell ids."
operationId: "arbor_get_cell_ids"
produces:
- "application/json"
parameters: []
......@@ -92,7 +92,7 @@ paths:
get:
tags:
- "arbor"
summary: "Retrieves the measurements for given attribute and neuron_ids (optional)."
summary: "Retrieves the measurements for given measurement points (optional)."
operationId: "arbor_get_measurements"
consumes:
- "application/json"
......@@ -104,6 +104,14 @@ paths:
description: "The attribute to query (e.g., 'V_m' for the membrane potential)"
required: true
type: "string"
- name: "measurement_point_id"
in: "query"
description: "A list of measurement point ids queried for data."
required: false
type: "array"
items:
type: "integer"
format: "uint64"
- name: "from"
in: "query"
description: "The start time (including) to be queried."
......@@ -116,14 +124,6 @@ paths:
required: false
type: "number"
format: "double"
- name: "neuron_ids"
in: "query"
description: "A list of GIDs queried for spike data."
required: false
type: "array"
items:
type: "integer"
format: "uint64"
- name: "offset"
in: "query"
description: "The offset into the result."
......@@ -167,18 +167,18 @@ paths:
type: "string"
example: "Error message"
x-swagger-router-controller: "access_node.controllers.arbor_controller"
/arbor/neuron_properties:
/arbor/cell_properties:
get:
tags:
- "arbor"
summary: "Retrieves the properties of the specified neurons."
operationId: "arbor_get_neuron_properties"
summary: "Retrieves the properties of the specified cells."
operationId: "arbor_get_cell_properties"
produces:
- "application/json"
parameters:
- name: "neuron_ids"
in: "query"
description: "A list of neuron IDs queried for properties."
description: "A list of cell IDs queried for properties."
required: false
type: "array"
items:
......@@ -190,32 +190,7 @@ paths:
schema:
type: "array"
items:
$ref: "#/definitions/ArborNeuronProperties"
400:
description: "Operation failed."
schema:
type: "string"
example: "Error message"
x-swagger-router-controller: "access_node.controllers.arbor_controller"
/arbor/attributes:
get:
tags:
- "arbor"
summary: "Retrieves a list of measurable attributes"
operationId: "arbor_get_attributes"
produces:
- "application/json"
parameters: []
responses:
200:
description: "Operation successful."
schema:
type: "array"
items:
type: "string"
example:
- "Voltage"
- "Resistance"
$ref: "#/definitions/ArborCellProperties"
400:
description: "Operation failed."
schema:
......@@ -430,7 +405,7 @@ paths:
get:
tags:
- "nest"
summary: "Retrieves the measurements for a multimeter (optional) and GIDS (optional)."
summary: "Retreives the available multimeters and their properties."
operationId: "nest_get_multimeter_info"
consumes:
- "application/json"
......@@ -452,7 +427,7 @@ paths:
get:
tags:
- "nest"
summary: "Retrieves the measurements for a multimeter (optional) and GIDS (optional)."
summary: "Retrieves the measurements for a multimeter, attribute and GIDS (optional)."
operationId: "nest_get_multimeter_measurements"
consumes:
- "application/json"
......@@ -517,7 +492,7 @@ paths:
get:
tags:
- "nest"
summary: "Retrieves the list of all neuron IDs."
summary: "Retrieves the list of all neuron IDs within the population."
operationId: "nest_get_gids_in_population"
produces:
- "application/json"
......@@ -644,7 +619,19 @@ definitions:
- 0.123
- 0.123
- 0.123
ArborNeuronProperties:
MeasurementPoint:
type: "object"
properties:
id:
type: "integer"
format: "uint64"
cell_id:
type: "integer"
format: "uint64"
position:
type: "number"
format: "double"
ArborCellProperties:
type: "object"
properties:
neuron_id:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment