https://github.com/ai4bharat/shoonya-backend
DRF-based API server for Shoonya platform
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 (15.2%) to scientific vocabulary
Repository
DRF-based API server for Shoonya platform
Basic Info
- Host: GitHub
- Owner: AI4Bharat
- License: mit
- Language: Python
- Default Branch: master
- Homepage: https://ai4bharat.iitm.ac.in/shoonya
- Size: 89.9 MB
Statistics
- Stars: 26
- Watchers: 7
- Forks: 14
- Open Issues: 25
- Releases: 0
Metadata Files
README.md
Shoonya Backend
Repository for Shoonya's backend.
Pre-requisites
The project was created using Python 3.7. All major dependencies along with the versions are listed in the backend/deploy/requirements.txt file.
Installation
The installation and setup instructions have been tested on the following platforms:
It can be done in 2 ways:- 1) using docker by running all services in containers or 2) directly running the services on local one by one (like, celery and redis).
If your preference is 1 over 2 please be fixed to this environment and follow the steps below it:
- Docker
- Ubuntu 20.04 OR macOs
If you are using a different operating system, you will have to look at external resources (eg. StackOverflow) to correct any errors.
Create a Virtual Environment
We recommend you to create a virtual environment to install all the dependencies required for the project.
```bash
python3 -m venv
Install dependencies
pip install -r deploy/requirements-dev.txt ```
Environment file
To set up the environment variables needed for the project, run the following lines:
bash
cp .env.example ./backend/.env
This creates an .env file at the root of the project. It is needed to make sure that the project runs correctly. Please go through the file and set the parameters according to your installation.
To create a new secret key, run the following commands (within the virtual environment): ```bash
Open a Python shell
python backend/manage.py shell
from django.core.management.utils import getrandomsecretkey getrandomsecretkey() ```
Paste the value you get there into the .env file.
Google Cloud Logging (Optional)
If Google Cloud Logging is being used, please follow these additional steps:
- Install the
google-cloud-logginglibrary using the following command:bash pip install google-cloud-logging - Follow the steps to create a Service Account from the following Google Cloud Documentation Page. This will create a Service Account and generate a JSON Key for the Service Account.
- Ensure that atleast the Project Logs Writer role (
roles/logging.logWriter) is assigned to the created Service Account. - Add the
GOOGLE_APPLICATION_CREDENTIALSvariable to the.envfile. This value of this variable should be the path to the JSON Key generated in Step 2. For example,
bash
GOOGLE_APPLICATION_CREDENTIALS="/path/to/gcloud-key.json"
Docker Installation
cd back to the root folder .Once inside, build the docker containers:
bash
docker-compose -f docker-compose-local.yml build
To run the containers:
bash
docker-compose -f docker-compose-local.yml up -d
To share the database with others, just share the postgres_data and the media folder with others.
Run Migrations (required only for the first time running the project or if you make any changes in the models)
Run the following commands: ```bash
Check if there are any pending migrations
docker-compose exec web python manage.py makemigrations
Run all pending migrations
docker-compose exec web python manage.py migrate
Create a superuser
docker-compose exec web python manage.py createsuperuser
```
If there were no errors, congratulations! The project is up and running.
If your preference is 2 over 1 please be fixed to this environment and follow the steps below it:
- Ubuntu 20.04 OR macOs
You can run the following script and each and every step for setting the codebase will be done directly. Please move to a folder in your local where you would like to store the code and run the script given below there: ```bash os=$(uname)
if [ "$os" = "Linux" ] || [ "$os" = "Darwin" ]; then
git clone https://github.com/AI4Bharat/Shoonya-Backend.git cd Shoonya-Backend git checkout dev git pull origin dev cp .env.example ./backend/.env cd backend python3 -m venv venv source venv/bin/activate
pip install -r ./deploy/requirements.txt
newsecretkey=$(python3 -c "from django.core.management.utils import getrandomsecretkey; print(getrandomsecretkey())")
envfile=".env" if sed --version 2>&1 | grep -q 'GNU sed'; then sed -i "/^SECRETKEY=/d" "$envfile" else sed -i.bak "/^SECRETKEY=/d" "$envfile" rm -f "$envfile.bak" fi
echo "SECRETKEY='$newsecretkey'" >> "$envfile"
echo "New secret key has been generated and updated in $env_file"
else echo "Cannot run this script on: $os" fi ```
Running background tasks
Please install and run redis from https://redis.io/download/ on port 6379 before starting celery.
To run background tasks for project creation, we need to run the following command in the terminal. This has also been added into the docker-compose.yml file.
bash
celery command - celery -A shoonya_backend.celery worker -l info
celery command - celery -A shoonya_backend.celery beat --loglevel=info
You can set use the celery to local by modifying CELERYBROKERURL = "redis://localhost:6379/0" in ./backend/shoonya_backend/settings.py.
We can set the concurrency and autoscale in the process as well to manage the number of worker processes in the background. Read more here.
The commands will be as follows
bash
celery -A shoonya_backend.celery worker --concurrency=2 --loglevel=info
celery -A shoonya_backend.celery worker --autoscale=10,3 --loglevel=info
Running Linters
In case you want to raise a PR, kindly run linters as specified below. You can install black by running pip install black and use black
To run black do:
bash
black ./backend/
Happy Coding!!
Owner
- Name: AI4Bhārat
- Login: AI4Bharat
- Kind: organization
- Email: opensource@ai4bharat.org
- Location: India
- Website: https://ai4bharat.org
- Twitter: AI4Bharat
- Repositories: 37
- Profile: https://github.com/AI4Bharat
Artificial-Intelligence-For-Bhārat : Building open-source AI solutions for India!
GitHub Events
Total
- Watch event: 4
- Delete event: 23
- Member event: 4
- Issue comment event: 3
- Push event: 147
- Pull request review comment event: 2
- Pull request review event: 14
- Pull request event: 91
- Fork event: 3
- Create event: 53
Last Year
- Watch event: 4
- Delete event: 23
- Member event: 4
- Issue comment event: 3
- Push event: 147
- Pull request review comment event: 2
- Pull request review event: 14
- Pull request event: 91
- Fork event: 3
- Create event: 53
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 3
- Total pull requests: 208
- Average time to close issues: 6 days
- Average time to close pull requests: 9 days
- Total issue authors: 3
- Total pull request authors: 17
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 108
- Bot issues: 0
- Bot pull requests: 34
Past Year
- Issues: 0
- Pull requests: 54
- Average time to close issues: N/A
- Average time to close pull requests: 11 days
- Issue authors: 0
- Pull request authors: 10
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 13
- Bot issues: 0
- Bot pull requests: 9
Top Authors
Issue Authors
- aditya-gitte (1)
- KunalTiwary (1)
- ishvindersethi22 (1)
Pull Request Authors
- KunalTiwary (49)
- dependabot[bot] (34)
- ishvindersethi22 (30)
- kartikvirendrar (19)
- munishmangla98 (17)
- aditya-gitte (11)
- ishangujarathi (10)
- suyogkokaje (7)
- Pursottam6003 (7)
- ch20b063 (6)
- Chetan-Gudagamanal (6)
- Shanks0465 (3)
- Gree606 (3)
- humiiii (2)
- ummegith (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- appleboy/ssh-action master composite
- actions/checkout v1 composite
- actions/setup-python v1 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- python 3.7 build