Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
plugins =
django_coverage_plugin
omit =
venv/*
static/*
*/migrations/*
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
max-line-length = 79
exclude = .git,__pycache__,build,dist,.tox,*/migrations/*,env,__init__.py,settings.py,*/node_modules/*,routing.py
exclude = .git,__pycache__,build,dist,.tox,*/migrations/*,env,venv,__init__.py,settings.py,*/node_modules/*,routing.py
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ MANIFEST
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
# Unit tests / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_js:
install:
- npm install jest@24.8.0 puppeteer@1.17.0 jest-puppeteer@4.3.0 @babel/preset-env@7.4.5 url-join@4.0.0 @babel/core@7.4.5
script:
- echo -e "Trigger python unit testing in here when they will be ready" || true
- echo -e "python unit/integration testing running in geppetto-scidash travis" || true
after_success:
- echo $TRAVIS_BRANCH
- echo $TRAVIS_PULL_REQUEST
Expand Down
29 changes: 24 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

VENV:=$(shell if [ -d "venv" ]; then echo "venv/bin/"; else echo ""; fi)
PYTHON:=$(VENV)python3
PIP:=$(VENV)/bin/pip
MANAGE:="manage.py"
MANAGECMD=$(PYTHON) $(MANAGE)

install: create-db install-sciunit-neuronunit install-frontend install-backend
@echo "==========================="
@echo "= Finished ="
Expand Down Expand Up @@ -63,19 +70,19 @@ run-staging: migrate
django-migrate: migrations migrate

migrations:
./manage.py makemigrations
$(MANAGECMD) makemigrations

migrate:
./manage.py migrate
$(MANAGECMD) migrate

superuser:
./manage.py createsuperuser
$(MANAGECMD) createsuperuser

run-django:
./manage.py runserver
$(MANAGECMD) runserver

run-django-staging:
python3.6 manage.py runserver --insecure 0.0.0.0:8000
$(MANAGECMD) runserver --insecure 0.0.0.0:8000

run-frontend:
cd static/org.geppetto.frontend/src/main/webapp/; npm run build-dev-noTest:watch;
Expand All @@ -89,6 +96,18 @@ run-celery-beat:
run-virgo-staging:
/bin/bash /opt/virgo/bin/startup.sh

manage/%:
$(MANAGECMD) $*

run-tests: run-django-tests

run-django-tests:
$(MANAGECMD) test

coverage:
coverage run $(MANAGE) test
coverage report -m

lint: flake8-lint isort-lint yapf-lint

format: yapf-format isort-format
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://img.shields.io/travis/MetaCell/scidash/master.svg?style=flat-square&label=master)](https://travis-ci.org/MetaCell/scidash)
[![Build Status](https://img.shields.io/travis/MetaCell/scidash/development.svg?style=flat-square&label=develop)](https://travis-ci.org/MetaCell/scidash)
<p align="center">
<img src="http://scidash.github.io/assets/scidash-text.png" alt="SciDash logo"/>
</p>
Expand Down
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
flake8
yapf
isort
coverage
django_coverage_plugin
pip-tools
3 changes: 2 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
psycopg2
django==1.11.23
psycopg2==2.7.7
channels==2.1.2
djangorestframework==3.7.1
drf-writable-nested
Expand All @@ -14,3 +14,4 @@ django-celery-beat
django-celery-results
django-db-logger
git+git://github.com/ddelpiano/neuronunit@4.0.0#egg=neuronunit
wheel==0.33.6
88 changes: 19 additions & 69 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,24 @@
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile
# pip-compile requirements.in
#
airspeed==0.5.4dev-20150515
allensdk==0.14.5
amqp==2.4.2 # via kombu
apipkg==1.5 # via execnet
argparse==1.4.0 # via scoop
asgiref==2.3.2 # via channels
asteval==0.9.18 # via lmfit
async-timeout==3.0.1 # via asgiref
attrs==19.1.0 # via automat, jsonschema, twisted
attrs==19.1.0 # via automat, twisted
autobahn==19.3.3 # via daphne
automat==0.7.0 # via twisted
backcall==0.1.0 # via ipython
backports.tempfile==1.0
backports.weakref==1.0.post1 # via backports.tempfile
beautifulsoup4==4.8.2 # via bs4
billiard==3.5.0.5 # via celery
bleach==3.1.0 # via nbconvert
git+https://github.com/russelljjarvis/BluePyOpt@scidash#egg=bluepyopt-9999
bokeh==1.4.0 # via dask
bs4==0.0.1
cachetools==0.8.0 # via airspeed
celery[redis]==4.2.2
cerberus==1.3.2
certifi==2019.11.28 # via requests
channels==2.1.2
chardet==3.0.4 # via requests
click==7.0 # via distributed
cloudpickle==1.2.2 # via dask, distributed
constantly==15.1.0 # via twisted
cycler==0.10.0 # via matplotlib
cypy==0.2.0
daphne==2.2.5 # via channels
dask[complete]==2.9.1 # via distributed
dask[complete]==2.9.0 # via distributed
deap==1.3.0
decorator==4.4.1 # via ipyparallel, ipython, networkx, traitlets, validators
defusedxml==0.6.0 # via nbconvert
distributed==2.9.1 # via dask
distributed==2.9.0 # via dask
django-celery-beat==1.4.0
django-celery-results==1.0.4
django-db-logger==0.1.7
Expand All @@ -53,26 +32,17 @@ django==1.11.23
djangorestframework-jwt==1.11.0
djangorestframework==3.7.1
drf-writable-nested==0.5.1
efel==3.0.70
elephant==0.4.1
entrypoints==0.3 # via nbconvert
execnet==1.7.1
fsspec==0.6.2 # via dask
future==0.18.2 # via allensdk
gitdb2==2.0.6 # via gitpython
gitpython==3.0.5
greenlet==0.4.15 # via scoop
h5py==2.10.0 # via allensdk
heapdict==1.0.1 # via zict
git+git://github.com/ddelpiano/neuronunit@4.0.0#egg=neuronunit
hyperlink==18.0.0 # via twisted
idna==2.8 # via hyperlink, requests
igor==0.3
imageio==2.6.1 # via scikit-image
importlib-metadata==1.3.0 # via jsonschema
incremental==17.5.0 # via twisted
ipykernel==5.1.3 # via ipyparallel
ipyparallel==6.2.4
ipython-genutils==0.2.0 # via ipyparallel, nbformat, traitlets
ipython==7.11.1 # via ipykernel, ipyparallel
ipython==7.10.2 # via ipykernel, ipyparallel
jedi==0.15.2 # via ipython
jinja2==2.10.3 # via allensdk, bokeh, nbconvert
jsonschema==3.2.0 # via nbformat
Expand All @@ -89,6 +59,7 @@ lxml==4.4.2 # via libneuroml
markupsafe==1.1.1 # via jinja2
matplotlib==3.1.2 # via allensdk, scikit-image
mistune==0.8.4 # via nbconvert
more-itertools==8.0.2 # via zipp
msgpack==0.6.2 # via distributed
nbconvert==5.6.1
nbformat==4.4.0 # via nbconvert
Expand All @@ -106,54 +77,33 @@ partd==1.1.0 # via dask
patsy==0.5.1 # via statsmodels
pexpect==4.7.0 # via ipython
pickleshare==0.7.5 # via ipython
pillow==7.0.0 # via bokeh, imageio, scikit-image
pillow==6.2.1 # via bokeh, imageio, scikit-image
prompt-toolkit==3.0.2 # via ipython
psutil==5.6.7 # via distributed
psycopg2==2.7.7
ptyprocess==0.6.0 # via pexpect
pygments==2.5.2 # via ipython, nbconvert
pyhamcrest==1.9.0 # via twisted
pyjwt==1.7.1 # via djangorestframework-jwt
pylems==0.4.9.3
git+https://github.com/rgerkin/pyneuroml@master#egg=pyneuroml-9999
pynn==0.9.5
pynrrd==0.4.2 # via allensdk
pynrrd==0.4.1 # via allensdk
pyparsing==2.4.6 # via matplotlib, packaging
pyrsistent==0.15.6 # via jsonschema
python-crontab==2.3.6 # via django-celery-beat
python-dateutil==2.8.0 # via bokeh, ipyparallel, jupyter-client, matplotlib, pandas, python-crontab
pytz==2018.9 # via celery, django, django-timezone-field, pandas
pywavelets==1.1.1 # via scikit-image
pyyaml==5.2 # via bokeh, dask, distributed
pyzmq==18.1.1 # via ipyparallel, jupyter-client, scoop
quantities==0.12.1 # via elephant, neo, pynn
python-dateutil==2.8.0 # via python-crontab
pytz==2018.9 # via celery, django, django-timezone-field
redis==2.10.6 # via celery
requests-toolbelt==0.9.1 # via allensdk
requests==2.22.0 # via allensdk, requests-toolbelt
rest-framework-cache==0.1
scikit-image==0.16.2 # via allensdk
scipy==1.4.1 # via allensdk, elephant, lmfit, scikit-image, statsmodels
git+https://github.com/scidash/sciunit@dev#egg=sciunit-9999
scoop==0.7.1.1
simpleitk==1.2.4 # via allensdk
simplejson==3.17.0 # via allensdk
six==1.12.0 # via airspeed, allensdk, autobahn, automat, bleach, bokeh, cycler, django-extensions, efel, elephant, h5py, jsonschema, libneuroml, packaging, patsy, pyhamcrest, pyrsistent, python-dateutil, traitlets, txaio, validators
smmap2==2.0.5 # via gitdb2
sortedcontainers==2.1.0 # via distributed
soupsieve==1.9.5 # via beautifulsoup4
statsmodels==0.10.2 # via allensdk
tblib==1.6.0 # via distributed
testpath==0.4.4 # via nbconvert
toolz==0.10.0 # via dask, distributed, partd
tornado==6.0.3 # via bokeh, distributed, ipykernel, ipyparallel, jupyter-client
traitlets==4.3.3 # via ipykernel, ipyparallel, ipython, jupyter-client, jupyter-core, nbconvert, nbformat
six==1.12.0 # via autobahn, automat, django-extensions, pyhamcrest, python-dateutil, txaio
twisted==18.9.0 # via daphne
txaio==18.8.1 # via autobahn
uncertainties==3.1.2 # via lmfit
urllib3==1.25.7 # via requests
validators==0.14.1
vine==1.3.0 # via amqp
wcwidth==0.1.8 # via prompt-toolkit
wcwidth==0.1.7 # via prompt-toolkit
webencodings==0.5.1 # via bleach
wheel==0.33.6
zict==1.0.0 # via distributed
zipp==0.6.0 # via importlib-metadata
zope.interface==4.6.0 # via twisted

# The following packages are considered to be unsafe in a requirements file:
# setuptools
47 changes: 46 additions & 1 deletion scidash/general/serializers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rest_framework import serializers
from rest_framework import serializers, fields

from scidash.general.models import Tag

Expand All @@ -7,3 +7,48 @@ class TagSerializer(serializers.ModelSerializer):
class Meta:
model = Tag
fields = ('name', )


class SerializerWritableMethodField(fields.ModelField):
"""
A writable (ModelField base) SerializerMethodField that get its
representation from calling a method on the parent serializer class. The
method called will be of the form "get_{field_name}", and should take a
single argument, which is the object being serialized.

For example:

class ExampleSerializer(self):
class_name = SciDashSerializerWritableMethodField(
model_field=TestClass()._meta.get_field('class_name'))

def get_class_name(self, obj):
return ... # Calculate some data to return.
"""

def __init__(self, method_name=None, **kwargs):
self.method_name = method_name
super(SerializerWritableMethodField, self).__init__(**kwargs)

def bind(self, field_name, parent):
# In order to enforce a consistent style, we error if a redundant
# 'method_name' argument has been used. For example:
# my_fld = serializer.SerializerMethodField(method_name='get_my_fld')
default_method_name = 'get_{field_name}'.format(field_name=field_name)
assert self.method_name != default_method_name, (
"It is redundant to specify `%s` on SerializerMethodField '%s' in "
"serializer '%s', because it is the same as the default method "
"name. Remove the `method_name` argument." %
(self.method_name, field_name, parent.__class__.__name__)
)

# The method name should default to `get_{field_name}`.
if self.method_name is None:
self.method_name = default_method_name

super(SerializerWritableMethodField, self).bind(
field_name, parent)

def to_representation(self, value):
method = getattr(self.parent, self.method_name)
return method(value)
File renamed without changes.
15 changes: 15 additions & 0 deletions scidash/general/tests/test_geppetto_servlet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.test import TestCase

from pygeppetto_gateway.base import GeppettoServletManager


class GeppettoServletTest(TestCase):
@classmethod
def setUpClass(cls):
super(GeppettoServletTest, cls).setUpClass()
cls.servlet_manager = GeppettoServletManager()

def test_ws_address(self):
self.assertEqual(
self.servlet_manager.host,
"ws://scidash-virgo:8080/org.geppetto.frontend/GeppettoServlet")
32 changes: 26 additions & 6 deletions scidash/sciunitmodels/tests/test_data/score_object.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
{
"score_class": {"class_name": "ZScore", "url": "http://test-url.for/not-spaming-data/in-database"},
"score_class": {
"class_name": "ZScore",
"url": "http://test-url.for/not-spaming-data/in-database"
},
"hash_id": "111",
"model_instance": {
"model_class": {
"class_name": "ReducedModel",
"url": "http://test-url.for/not-spaming-data/in-database",
"import_path": "neuronunit.models.static.StaticModel",
"memo": null,
"extra_capabilities": [],
"capabilities": [
{
"class_name": "ReceivesSquareCurrent"
},
{
"class_name": "ProducesActionPotentials"
},
{
"class_name": "ProducesSpikes"
},
{
"class_name": "ProducesMembranePotential"
},
{
"class_name": "CanBeReduced"
}
Expand All @@ -25,16 +43,18 @@
"test_instance": {
"description": null,
"hash_id": "111",
"test_suites": [{
"hash": "testhash",
"name": "ReducedSuite"
}],
"test_suites": [
{
"hash": "testhash",
"name": "ReducedSuite"
}
],
"test_class": {
"class_name": "MyTest",
"url": "http://test-url.for/not-spaming-data/in-database"
},
"observation": {
"mean":"8",
"mean": "8",
"std": "3",
"url": ""
},
Expand Down
Loading