https://github.com/cnr-ibba/smarter-backend
SMARTER Backend API
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.0%) to scientific vocabulary
Keywords
Repository
SMARTER Backend API
Basic Info
- Host: GitHub
- Owner: cnr-ibba
- License: gpl-3.0
- Language: Python
- Default Branch: master
- Homepage: https://webserver.ibba.cnr.it/smarter-api/docs/
- Size: 438 KB
Statistics
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 11
- Releases: 1
Topics
Metadata Files
README.md
SMARTER-backend
SMARTER Backend API
Setting the .env file
docker-compose can read variables from a .env placed in the working directory.
Here we will define all variables useful for our containers, like database password.
Edit a new .env file in working directory and set passwords for such environment
variables:
text
MONGODB_ROOT_USER=<root user>
MONGODB_ROOT_PASS=<root pass>
MONGODB_SMARTER_USER=<smarter user>
MONGODB_SMARTER_PASS=<smarter pass>
TODO: manage sensitive data using secret in docker-compose, as described here and here
Setting the proper permissions
Set mongodb-home folder permissions with:
bash
chmod 777 mongodb-home/
chmod o+t mongodb-home/
Fix flask-data permissions:
bash
docker-compose run --no-deps --rm uwsgi sh -c 'chgrp -R www-data .'
cd flask-data/
find . -type f -iname "*.py" -exec chmod g-w {} \;
Build and run the application
bash
docker-compose build
docker-compose up
Connect to mongodb
bash
docker-compose run --rm --user mongodb mongo sh -c 'mongo --host mongo --username="${MONGO_INITDB_ROOT_USERNAME}" --password="${MONGO_INITDB_ROOT_PASSWORD}"'
Import data into database
Execute a mongodump of an instance of the
SMARTER-database project, for
example:
bash
docker-compose run --rm --user mongodb mongo sh -c 'DATE=$(date +%Y-%m-%d); mongodump --host mongo --username="${MONGO_INITDB_ROOT_USERNAME}" --password="${MONGO_INITDB_ROOT_PASSWORD}" --authenticationDatabase admin --db=smarter --gzip --archive=/home/mongodb/${DATE}\_smarter.archive.gz'
Then copy (or move) the dump file into mongodb-home folder of this project. You
can restore the database using mongorestore, for example:
bash
docker-compose run --rm --user mongodb mongo sh -c 'mongorestore --host mongo --username="${MONGO_INITDB_ROOT_USERNAME}" --password="${MONGO_INITDB_ROOT_PASSWORD}" --authenticationDatabase admin --db=smarter --drop --preserveUUID --gzip --archive=/home/mongodb/2021-06-18_smarter.archive.gz'
Monitoring UWSGI processes
Enter inside uwsgi container (with docker-compose exec), then monitor uwsgi with
uwsgitop:
bash
docker-compose exec uwsgi bash
uwsgitop /tmp/smarter-stats.sock
Type q to exit from monitoring process
Test application
Some useful commands to test the application:
```bash
open the flask shell
docker-compose run --rm uwsgi flask shell
test and exit when a issue is found. Call first the failed test on successive calls
docker-compose run --rm uwsgi pytest --verbosity=2 --exitfirst --failed-first --showlocals
test with coverage
docker-compose run --rm uwsgi coverage run --source='.' -m pytest
generate coverage report locally
docker-compose run --rm uwsgi coverage html
check code with flake8
docker-compose run --rm uwsgi flake8
test like CI
docker-compose run --no-deps --rm uwsgi sh -c 'coverage run --source='.' -m pytest && flake8' ```
Owner
- Name: CNR-IBBA
- Login: cnr-ibba
- Kind: organization
- Location: Milan
- Website: https://www.ibba.cnr.it/
- Repositories: 25
- Profile: https://github.com/cnr-ibba
Bioinformatic Group @ CNR-IBBA
GitHub Events
Total
- Push event: 3
- Pull request event: 2
Last Year
- Push event: 3
- Pull request event: 2
Dependencies
- nginx 1.20 build
- python 3.9 build
- mongo 4.4
- alabaster 0.7.13
- aniso8601 9.0.1
- appnope 0.1.3
- asttokens 2.4.0
- attrs 23.1.0
- babel 2.12.1
- backcall 0.2.0
- bcrypt 4.0.1
- certifi 2023.7.22
- charset-normalizer 3.2.0
- click 8.1.7
- colorama 0.4.6
- coverage 5.5
- coveralls 3.3.1
- decorator 5.1.1
- dnspython 2.4.2
- docopt 0.6.2
- docutils 0.18.1
- email-validator 2.0.0.post2
- exceptiongroup 1.1.3
- executing 1.2.0
- flake8 6.1.0
- flasgger 0.9.7.1
- flask 2.1.3
- flask-bcrypt 1.0.1
- flask-cors 4.0.0
- flask-jwt-extended 4.5.2
- flask-mongoengine 1.0.0
- flask-restful 0.3.10
- flask-shell-ipython 0.5.1
- flask-wtf 1.1.1
- idna 3.4
- imagesize 1.4.1
- importlib-metadata 6.8.0
- iniconfig 2.0.0
- ipython 8.15.0
- itsdangerous 2.1.2
- jedi 0.19.0
- jinja2 3.1.2
- jsonschema 4.19.0
- jsonschema-specifications 2023.7.1
- markupsafe 2.1.3
- matplotlib-inline 0.1.6
- mccabe 0.7.0
- mistune 3.0.1
- mongoengine 0.27.0
- packaging 23.1
- parso 0.8.3
- pexpect 4.8.0
- pickleshare 0.7.5
- pluggy 1.3.0
- prompt-toolkit 3.0.39
- ptyprocess 0.7.0
- pure-eval 0.2.2
- pycodestyle 2.11.0
- pyflakes 3.1.0
- pygments 2.16.1
- pyjwt 2.8.0
- pymongo 4.5.0
- pytest 7.4.2
- python-dateutil 2.8.2
- pytz 2023.3.post1
- pyyaml 6.0.1
- referencing 0.30.2
- requests 2.31.0
- rpds-py 0.10.3
- six 1.16.0
- snowballstemmer 2.2.0
- sphinx 7.2.6
- sphinx-rtd-theme 1.3.0
- sphinxcontrib-applehelp 1.0.7
- sphinxcontrib-devhelp 1.0.5
- sphinxcontrib-htmlhelp 2.0.4
- sphinxcontrib-jquery 4.1
- sphinxcontrib-jsmath 1.0.1
- sphinxcontrib-qthelp 1.0.6
- sphinxcontrib-serializinghtml 1.1.9
- stack-data 0.6.2
- tomli 2.0.1
- traitlets 5.10.0
- typing-extensions 4.7.1
- urllib3 2.0.4
- uwsgi 2.0.22
- uwsgitop 0.11
- wcwidth 0.2.6
- werkzeug 2.0.3
- wtforms 3.0.1
- zipp 3.16.2
- coverage 5.*
- coveralls ^3.3.1
- flake8 ^6.1.0
- flasgger ^0.9.7.1
- flask ~2.1
- flask-bcrypt ^1.0.1
- flask-cors ^4.0.0
- flask-jwt-extended ^4.5.2
- flask-mongoengine ^1.0.0
- flask-restful ^0.3.10
- flask-shell-ipython ^0.5.1
- ipython ^8.15.0
- mongoengine ^0.27.0
- pytest ^7.4.2
- python ^3.9
- python-dateutil ^2.8.2
- sphinx ^7.2.6
- sphinx-rtd-theme ^1.3.0
- uwsgi ^2.0.22
- uwsgitop ^0.11
- werkzeug ~2.0
- SpicyPizza/create-envfile v2 composite
- actions/checkout v4 composite