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

Inital code generation

parent b335850a
No related branches found
No related tags found
No related merge requests found
Showing
with 1118 additions and 1 deletion
.travis.yaml
.swagger-codegen-ignore
README.md
tox.ini
git_push.sh
test-requirements.txt
setup.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.python-version
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#Ipython Notebook
.ipynb_checkpoints
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.python-version
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#Ipython Notebook
.ipynb_checkpoints
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
2.4.8
\ No newline at end of file
# ref: https://docs.travis-ci.com/user/languages/python
language: python
python:
- "3.2"
- "3.3"
- "3.4"
- "3.5"
#- "3.5-dev" # 3.5 development branch
#- "nightly" # points to the latest development branch e.g. 3.6-dev
# command to install dependencies
install: "pip install -r requirements.txt"
# command to run tests
script: nosetests
FROM python:3-alpine
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt /usr/src/app/
RUN pip3 install --no-cache-dir -r requirements.txt
COPY . /usr/src/app
EXPOSE 8080
ENTRYPOINT ["python3"]
CMD ["-m", "access_node"]
\ No newline at end of file
# access-node
Public access server providing a REST API for the in-situ pipeline.
Public access server providing REST API for the in-situ pipeline.
\ No newline at end of file
# Swagger generated server
## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
is an example of building a swagger-enabled Flask server.
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
## Requirements
Python 3.5.2+
## Usage
To run the server, please execute the following from the root directory:
```
pip3 install -r requirements.txt
python3 -m access_node
```
and open your browser to here:
```
http://localhost:8080//ui/
```
Your Swagger definition lives here:
```
http://localhost:8080//swagger.json
```
To launch the integration tests, use tox:
```
sudo pip install tox
tox
```
## Running with Docker
To run the server on a Docker container, please execute the following from the root directory:
```bash
# building the image
docker build -t access_node .
# starting up a container
docker run -p 8080:8080 access_node
```
#!/usr/bin/env python3
import connexion
from access_node import encoder
def main():
app = connexion.App(__name__, specification_dir='./swagger/')
app.app.json_encoder = encoder.JSONEncoder
app.add_api('swagger.yaml', arguments={'title': 'In-Situ Pipeline REST API'})
app.run(port=8080)
if __name__ == '__main__':
main()
import connexion
import six
from access_node.models.attribute import Attribute # noqa: E501
from access_node.models.data import Data # noqa: E501
from access_node.models.error import Error # noqa: E501
from access_node.models.spikes import Spikes # noqa: E501
from access_node import util
def get_attributes(): # noqa: E501
"""Retrieves the details of per-neuron attributes.
# noqa: E501
:rtype: List[Attribute]
"""
return 'do some magic!'
def get_data(attribute, simulation_steps=None, neuron_ids=None): # noqa: E501
"""Retrieves the per-neuron attributes for the given attribute name, simulation steps (optional) and neuron IDs (optional).
# noqa: E501
:param attribute: Attribute name.
:type attribute: str
:param simulation_steps: Simulation steps (leave empty for all steps).
:type simulation_steps: List[float]
:param neuron_ids: Neuron IDs (leave empty for all neurons).
:type neuron_ids: List[]
:rtype: Data
"""
return 'do some magic!'
def get_neuron_ids(): # noqa: E501
"""Retrieves the list of all neuron IDs.
# noqa: E501
:rtype: List[float]
"""
return 'do some magic!'
def get_simulation_step_count(): # noqa: E501
"""Retrieves the number of simulation steps.
# noqa: E501
:rtype: float
"""
return 'do some magic!'
def get_spikes(simulation_steps=None, neuron_ids=None): # noqa: E501
"""Retrieves the spikes for the given simulation steps (optional) and neuron IDs (optional).
# noqa: E501
:param simulation_steps: Simulation steps (leave empty for all steps).
:type simulation_steps: List[]
:param neuron_ids: Neuron IDs (leave empty for all neurons).
:type neuron_ids: List[]
:rtype: Spikes
"""
return 'do some magic!'
def get_timestep(): # noqa: E501
"""Retrieves the time between two simulation steps.
# noqa: E501
:rtype: float
"""
return 'do some magic!'
from connexion.apps.flask_app import FlaskJSONEncoder
import six
from access_node.models.base_model_ import Model
class JSONEncoder(FlaskJSONEncoder):
include_nulls = False
def default(self, o):
if isinstance(o, Model):
dikt = {}
for attr, _ in six.iteritems(o.swagger_types):
value = getattr(o, attr)
if value is None and not self.include_nulls:
continue
attr = o.attribute_map[attr]
dikt[attr] = value
return dikt
return FlaskJSONEncoder.default(self, o)
# coding: utf-8
# flake8: noqa
from __future__ import absolute_import
# import models into model package
from access_node.models.attribute import Attribute
from access_node.models.data import Data
from access_node.models.error import Error
from access_node.models.precision import Precision
from access_node.models.spikes import Spikes
# coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from access_node.models.base_model_ import Model
from access_node.models.precision import Precision # noqa: F401,E501
from access_node import util
class Attribute(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, name: str=None, precision: Precision=None): # noqa: E501
"""Attribute - a model defined in Swagger
:param name: The name of this Attribute. # noqa: E501
:type name: str
:param precision: The precision of this Attribute. # noqa: E501
:type precision: Precision
"""
self.swagger_types = {
'name': str,
'precision': Precision
}
self.attribute_map = {
'name': 'name',
'precision': 'precision'
}
self._name = name
self._precision = precision
@classmethod
def from_dict(cls, dikt) -> 'Attribute':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Attribute of this Attribute. # noqa: E501
:rtype: Attribute
"""
return util.deserialize_model(dikt, cls)
@property
def name(self) -> str:
"""Gets the name of this Attribute.
:return: The name of this Attribute.
:rtype: str
"""
return self._name
@name.setter
def name(self, name: str):
"""Sets the name of this Attribute.
:param name: The name of this Attribute.
:type name: str
"""
self._name = name
@property
def precision(self) -> Precision:
"""Gets the precision of this Attribute.
:return: The precision of this Attribute.
:rtype: Precision
"""
return self._precision
@precision.setter
def precision(self, precision: Precision):
"""Sets the precision of this Attribute.
:param precision: The precision of this Attribute.
:type precision: Precision
"""
self._precision = precision
import pprint
import six
import typing
from access_node import util
T = typing.TypeVar('T')
class Model(object):
# swaggerTypes: The key is attribute name and the
# value is attribute type.
swagger_types = {}
# attributeMap: The key is attribute name and the
# value is json key in definition.
attribute_map = {}
@classmethod
def from_dict(cls: typing.Type[T], dikt) -> T:
"""Returns the dict as a model"""
return util.deserialize_model(dikt, cls)
def to_dict(self):
"""Returns the model properties as a dict
:rtype: dict
"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model
:rtype: str
"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
# coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from access_node.models.base_model_ import Model
from access_node import util
class Data(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, simulation_steps: List[float]=None, neuron_ids: List[float]=None, data: 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 neuron_ids: The neuron_ids of this Data. # noqa: E501
:type neuron_ids: List[float]
:param data: The data of this Data. # noqa: E501
:type data: List[float]
"""
self.swagger_types = {
'simulation_steps': List[float],
'neuron_ids': List[float],
'data': List[float]
}
self.attribute_map = {
'simulation_steps': 'simulation_steps',
'neuron_ids': 'neuron_ids',
'data': 'data'
}
self._simulation_steps = simulation_steps
self._neuron_ids = neuron_ids
self._data = data
@classmethod
def from_dict(cls, dikt) -> 'Data':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Data of this Data. # noqa: E501
:rtype: Data
"""
return util.deserialize_model(dikt, cls)
@property
def simulation_steps(self) -> List[float]:
"""Gets the simulation_steps of this Data.
:return: The simulation_steps of this Data.
:rtype: List[float]
"""
return self._simulation_steps
@simulation_steps.setter
def simulation_steps(self, simulation_steps: List[float]):
"""Sets the simulation_steps of this Data.
:param simulation_steps: The simulation_steps of this Data.
:type simulation_steps: List[float]
"""
self._simulation_steps = simulation_steps
@property
def neuron_ids(self) -> List[float]:
"""Gets the neuron_ids of this Data.
:return: The neuron_ids of this Data.
:rtype: List[float]
"""
return self._neuron_ids
@neuron_ids.setter
def neuron_ids(self, neuron_ids: List[float]):
"""Sets the neuron_ids of this Data.
:param neuron_ids: The neuron_ids of this Data.
:type neuron_ids: List[float]
"""
self._neuron_ids = neuron_ids
@property
def data(self) -> List[float]:
"""Gets the data of this Data.
:return: The data of this Data.
:rtype: List[float]
"""
return self._data
@data.setter
def data(self, data: List[float]):
"""Sets the data of this Data.
:param data: The data of this Data.
:type data: List[float]
"""
self._data = data
# coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from access_node.models.base_model_ import Model
from access_node import util
class Error(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, code: float=None, message: str=None): # noqa: E501
"""Error - a model defined in Swagger
:param code: The code of this Error. # noqa: E501
:type code: float
:param message: The message of this Error. # noqa: E501
:type message: str
"""
self.swagger_types = {
'code': float,
'message': str
}
self.attribute_map = {
'code': 'code',
'message': 'message'
}
self._code = code
self._message = message
@classmethod
def from_dict(cls, dikt) -> 'Error':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Error of this Error. # noqa: E501
:rtype: Error
"""
return util.deserialize_model(dikt, cls)
@property
def code(self) -> float:
"""Gets the code of this Error.
:return: The code of this Error.
:rtype: float
"""
return self._code
@code.setter
def code(self, code: float):
"""Sets the code of this Error.
:param code: The code of this Error.
:type code: float
"""
self._code = code
@property
def message(self) -> str:
"""Gets the message of this Error.
:return: The message of this Error.
:rtype: str
"""
return self._message
@message.setter
def message(self, message: str):
"""Sets the message of this Error.
:param message: The message of this Error.
:type message: str
"""
self._message = message
# coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from access_node.models.base_model_ import Model
from access_node import util
class Precision(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
allowed enum values
"""
DOUBLE = "double"
INTEGER = "integer"
def __init__(self): # noqa: E501
"""Precision - a model defined in Swagger
"""
self.swagger_types = {
}
self.attribute_map = {
}
@classmethod
def from_dict(cls, dikt) -> 'Precision':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Precision of this Precision. # noqa: E501
:rtype: Precision
"""
return util.deserialize_model(dikt, cls)
# coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from access_node.models.base_model_ import Model
from access_node import util
class Spikes(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, simulation_steps: List[float]=None, neuron_ids: List[float]=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 neuron_ids: The neuron_ids of this Spikes. # noqa: E501
:type neuron_ids: List[float]
"""
self.swagger_types = {
'simulation_steps': List[float],
'neuron_ids': List[float]
}
self.attribute_map = {
'simulation_steps': 'simulation_steps',
'neuron_ids': 'neuron_ids'
}
self._simulation_steps = simulation_steps
self._neuron_ids = neuron_ids
@classmethod
def from_dict(cls, dikt) -> 'Spikes':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Spikes of this Spikes. # noqa: E501
:rtype: Spikes
"""
return util.deserialize_model(dikt, cls)
@property
def simulation_steps(self) -> List[float]:
"""Gets the simulation_steps of this Spikes.
:return: The simulation_steps of this Spikes.
:rtype: List[float]
"""
return self._simulation_steps
@simulation_steps.setter
def simulation_steps(self, simulation_steps: List[float]):
"""Sets the simulation_steps of this Spikes.
:param simulation_steps: The simulation_steps of this Spikes.
:type simulation_steps: List[float]
"""
self._simulation_steps = simulation_steps
@property
def neuron_ids(self) -> List[float]:
"""Gets the neuron_ids of this Spikes.
:return: The neuron_ids of this Spikes.
:rtype: List[float]
"""
return self._neuron_ids
@neuron_ids.setter
def neuron_ids(self, neuron_ids: List[float]):
"""Sets the neuron_ids of this Spikes.
:param neuron_ids: The neuron_ids of this Spikes.
:type neuron_ids: List[float]
"""
self._neuron_ids = neuron_ids
---
swagger: "2.0"
info:
description: "This is the REST API for the in-situ pipeline."
version: "1.0.0"
title: "In-Situ Pipeline REST API"
host: "localhost"
basePath: "/"
schemes:
- "https"
- "http"
paths:
/timestep:
get:
tags:
- "nest"
summary: "Retrieves the time between two simulation steps."
operationId: "get_timestep"
produces:
- "application/json"
parameters: []
responses:
200:
description: "Operation successful."
schema:
type: "number"
format: "double"
400:
description: "Operation failed."
schema:
$ref: "#/definitions/Error"
x-swagger-router-controller: "swagger_server.controllers.nest_controller"
/simulation_step_count:
get:
tags:
- "nest"
summary: "Retrieves the number of simulation steps."
operationId: "get_simulation_step_count"
produces:
- "application/json"
parameters: []
responses:
200:
description: "Operation successful."
schema:
type: "number"
format: "int64"
400:
description: "Operation failed."
schema:
$ref: "#/definitions/Error"
x-swagger-router-controller: "swagger_server.controllers.nest_controller"
/neuron_ids:
get:
tags:
- "nest"
summary: "Retrieves the list of all neuron IDs."
operationId: "get_neuron_ids"
produces:
- "application/json"
parameters: []
responses:
200:
description: "Operation successful."
schema:
type: "array"
items:
type: "number"
format: "int64"
400:
description: "Operation failed."
schema:
$ref: "#/definitions/Error"
x-swagger-router-controller: "swagger_server.controllers.nest_controller"
/attributes:
get:
tags:
- "nest"
summary: "Retrieves the details of per-neuron attributes."
operationId: "get_attributes"
produces:
- "application/json"
parameters: []
responses:
200:
description: "Operation successful."
schema:
type: "array"
items:
$ref: "#/definitions/Attribute"
400:
description: "Operation failed."
schema:
$ref: "#/definitions/Error"
x-swagger-router-controller: "swagger_server.controllers.nest_controller"
/data:
get:
tags:
- "nest"
summary: "Retrieves the per-neuron attributes for the given attribute name,\
\ simulation steps (optional) and neuron IDs (optional)."
operationId: "get_data"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: "attribute"
in: "query"
description: "Attribute name."
required: true
type: "string"
- name: "simulation_steps"
in: "query"
description: "Simulation steps (leave empty for all steps)."
required: false
type: "array"
items:
type: "number"
format: "double"
collectionFormat: "multi"
- name: "neuron_ids"
in: "query"
description: "Neuron IDs (leave empty for all neurons)."
required: false
type: "array"
items:
type: "number"
format: "int64"
collectionFormat: "multi"
responses:
200:
description: "Operation successful."
schema:
$ref: "#/definitions/Data"
400:
description: "Operation failed."
schema:
$ref: "#/definitions/Error"
x-swagger-router-controller: "swagger_server.controllers.nest_controller"
/spikes:
get:
tags:
- "nest"
summary: "Retrieves the spikes for the given simulation steps (optional) and\
\ neuron IDs (optional)."
operationId: "get_spikes"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: "simulation_steps"
in: "query"
description: "Simulation steps (leave empty for all steps)."
required: false
type: "array"
items:
type: "number"
format: "int64"
collectionFormat: "multi"
- name: "neuron_ids"
in: "query"
description: "Neuron IDs (leave empty for all neurons)."
required: false
type: "array"
items:
type: "number"
format: "int64"
collectionFormat: "multi"
responses:
200:
description: "Operation successful."
schema:
$ref: "#/definitions/Spikes"
400:
description: "Operation failed."
schema:
$ref: "#/definitions/Error"
x-swagger-router-controller: "swagger_server.controllers.nest_controller"
definitions:
Precision:
type: "string"
enum:
- "double"
- "integer"
Attribute:
type: "object"
properties:
name:
type: "string"
precision:
$ref: "#/definitions/Precision"
example:
precision: {}
name: "name"
Data:
type: "object"
properties:
simulation_steps:
type: "array"
items:
type: "number"
format: "int64"
neuron_ids:
type: "array"
items:
type: "number"
format: "int64"
data:
type: "array"
items:
type: "number"
example:
simulation_steps:
- 0.8008281904610115
- 0.8008281904610115
data:
- 1.4658129805029452
- 1.4658129805029452
neuron_ids:
- 6.027456183070403
- 6.027456183070403
Spikes:
type: "object"
properties:
simulation_steps:
type: "array"
items:
type: "number"
format: "int64"
neuron_ids:
type: "array"
items:
type: "number"
format: "int64"
example:
simulation_steps:
- 0.8008281904610115
- 0.8008281904610115
neuron_ids:
- 6.027456183070403
- 6.027456183070403
Error:
type: "object"
properties:
code:
type: "number"
message:
type: "string"
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