Skip to content

Commit

Permalink
python3 hhnb version with general improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rcsm17 committed May 12, 2021
1 parent 25a6f02 commit ce579ac
Show file tree
Hide file tree
Showing 609 changed files with 90,870 additions and 82,100 deletions.
27 changes: 13 additions & 14 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
*.log
*.pyc
*.swp
*.swo
*.swn
*.log
.idea/
.vscode/

*/migrations/

*/migrations/

packages
venvbspg
letsencrypt
media
db.sqlite3
bower_components
bspg/debug.py
bspg/bspg_keys
static_pool
sitemap
static/sitemap
efelg_access.log
hhnb_access.log


hh_neuron_builder/config/dev_conf.py
hh_neuron_builder/config/prod_conf.py
File renamed without changes.
165 changes: 0 additions & 165 deletions LGPL.txt

This file was deleted.

12 changes: 0 additions & 12 deletions LICENSE.txt

This file was deleted.

54 changes: 53 additions & 1 deletion README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,56 @@ The project is implemented via the Django framework and consists of two applicat
- efelg: to extract electrophysiological features from recorded and/or simulated traces
- hh-neuron-builder: to go through the neuron builder pipeline. This app integrates efelg in the feature extraction step

The project also contains the bsp_monitor web app aiming at visualizing the Brain Simulation Platform usage statistics.


## How to run it locally

To run the Hodgkin-Huxley Neuron Builder locally, you need to set up a python3 virtual environment,
install the all requirements that you can find on the "requirements.txt" file, create an OIDC Connect Client to provide
the authentication with the Ebrains platform and lastly run the server.


#### Ubuntu/Linux:

---

Create the virtual environment:

`virtualenv -p /usb/bin/python3 venv`

Activate it:

`source venv/bin/activate`

And then install the all requirements:

`pip install -r requirements.txt`


Once you have set up all of prerequisite you need to create the OIDC Connect Client provided by the Ebrains platform.
To do that you can follow the Ebrains guide [here](https://wiki.ebrains.eu/bin/view/Collabs/collaboratory-community-apps/Community%20App%20Developer%20Guide/)
or run the python script _"dev_tool/create_hhnb_dev_client.py"_.

**N.B. You need an account on the Ebrains platform and ensure you have access to the developer token as described on the guide.**

The last thing to do, when you have got your client, is to export the ***"secret"*** and ***"clientId"*** value inside your virtual
environment by append these lines on your _venv/bin/activate_ script.



# ADDING OIDC CLIENT_ID AND CLIENT_SECRET
OIDC_RP_CLIENT_ID=hhnb-client-example
OIDC_RP_CLIENT_SECRET=fe7e...

export OIDC_RP_CLIENT_ID
export OIDC_RP_CLIENT_SECRET

**N.B. Make sure to add the right values inside the environment without the quotes.**

---

When everything is done just run the server with this command:

`python manage.py runsslserver`

open your browser and go to https://127.0.0.1:8000/hh-neuron-builder to start the application.
File renamed without changes.
33 changes: 33 additions & 0 deletions auth/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from mozilla_django_oidc.auth import OIDCAuthenticationBackend, SuspiciousOperation, LOGGER
from hhnb.models import MyUser as User


class MyOIDCBackend(OIDCAuthenticationBackend):

def get_or_create_user(self, access_token, id_token, payload):
print('[MyOIDCBackend] get_or_create_user() called.')

user_info = self.get_userinfo(access_token, id_token, payload)

email = user_info.get('email')
username = user_info.get('preferred_username')

claims_verified = self.verify_claims(user_info)
if not claims_verified:
msg = 'Claims verification failed'
raise SuspiciousOperation(msg)

# email based filtering
# users = self.filter_users_by_claims(user_info)
try:
return User.objects.get(email=email, username=username)
except User.DoesNotExist:
user = User(
username=user_info.get('preferred_username'),
email=user_info.get('email'),
first_name=user_info.get('given_name', ''),
last_name=user_info.get('family_name', ''),
name=user_info.get('name', '')
)
user.save()
return user
7 changes: 0 additions & 7 deletions bsp_monitor/apps.py

This file was deleted.

5 changes: 0 additions & 5 deletions bsp_monitor/models.py

This file was deleted.

Binary file not shown.
6 changes: 0 additions & 6 deletions bsp_monitor/static/bsp_monitor/js/ga.js

This file was deleted.

Loading

0 comments on commit ce579ac

Please sign in to comment.