The Bioinformed Skill Assessment Platform enables users to complete BRN skill assessments, earn badges, and demonstrate their skills to potential partners and employers.
This app is developed collaboratively by the Bioinformatics Research Network Infrastructure WG.
It comprises six services which correspond to the directories in this repo:
webui
webui/
directory contains the code for that part of the app.ghbot
ghbot/
directory.slackbot
crud
crud/
directory.db
sync
sync/
directory.Overview diagram:
For a quickstart watch the first 20 min of this project's video dev notes. The instructions in that video and in the following documentation apply to all services in the app. For additional details, see the README.md
within each service's directory.
The workflow for contributing:
black .
to style your code before final push to github.main
branch. To keep things organized, the contribution workflow will begin with issues.
If you want a new feature, if you want a bug fixed, or some other change in the code, begin by opening an issue. Describe what changes you want, try to be as detailed as possible. If there's a bug, describe how to replicate the bug (preferrably in gitpod). If you want a feature, describe why you want this feature and provide details on what it will take to create it (if you already have an idea).
New issues should also be labeled so we know what kind of issue it is, and what service it pertains to -- see examples here.
Once a new issue is created, it will go onto the project board. If something is high urgency it will go into "Todo". If it is low urgency, it should go in the "Backlog".
Anyone can assign themselves to an issue. If we need someone else to work on it instead, then someone will politely ask you to give up the issue.
To keep this project neat, organized, and easy to contribute to, please make sure to do all the following when writing new code:
flake8 .
and fix all warnings / errorsblack -l 80 --experimental-string-processing .
to automatically style your code (the -l 80 --experimental-string-processing
part wraps long lines).webui
so they can be appropriately documented in the user interfaceREADME.md
files appropriatelyBRN uses branch protection for the main
branch. This means that only authorized accounts can add to this branch directly without submitting a pull request.
The CODEOWNERS
file describes these roles:
/crud @itchytummy
/webui @millerh1
/sync @millerh1
/db @millerh1
/slackbot @jmsdao @millerh1
/* @millerh1 # Files in root dir
/.github @millerh1
For example, the line /crud @itchytummy
indicates that only @itchytummy can push commits to main
if they include changes in the crud/
dir.
At all times, contributors are expected to abide by the BRN Code of Conduct. Failure to follow these guidelines may result in discplinary action, such as a ban from contributing to this work.
The ideal environment for developing this app is gitpod. You can launch that environment by creating a gitpod account, defining your AWS credentials in your user variables (watch video to see how to do this), and then click the "Open in Gitpod" button (above).
The gitpod dev environment is defined by .gitpod.yml
-- and if you wish to develop without gitpod, you are encouraged to repeat the steps in the .gitpod.yml
file locally so that you can faithfully reproduce the dev environment.
To spin up all services and create a copy of the production environment in gitpod (or your local computer), simply run the following:
docker-compose up
If you want to work on a particular service (e.g., the CRUD app), spin up all other services except the one you want to work on:
docker-compose up --scale <my_service>=0
Then you can proceed to work on <my_service>
as desired.
For example, if you wanted to work on the webui, launch the following:
docker-compose up --build --scale webui=0
From this point onwards, you can use a separate terminal to work on the webui service:
# Set up environment for local development on webui
export APP_ENV=testing
cd webui/
pip install -r requirements.txt
# Launch webui app (use 9630 because this is what docker compose uses)
flask run -p 9630 --reload --debugger
If you are working remotely, you will need to forward port 9630 (use the port panel in VS Code to do this, for example) -- then you should be able to navigate to http://localhost:9630 in your browser and see the app running.
All secrets and environmental variables are stored in .env
files which are loaded into the dev env automatically (if using gitpod). You must have AWS access in order to obtain them -- as @millerh1 if you need this. We use pydantic[dotenv] to load them for each app based on the APP_ENV
environmental parameter.
# App will use .test.env
export APP_ENV=testing
...
# App will use .dev.env
export APP_ENV=development
While working locally on a particular service, always use the testing
env. This will ensure that the service you are working on can correctly network with the other services running in docker-compose. By default, all services in docker-compose will use the development
env.
All .env
files should be treated as strictly confidential. They should never be shared or pushed to GitHub. By default, the .gitignore
file will ignore these -- but still be careful that you do not accidentally overwrite the .gitignore
.
Environmental variables, ssh keys, OAuth tokens, or other secrets should never be committed to the git history or otherwise stored in plain text anywhere.
For secrets needed during the dev process, store them in gitpod as user variables (preferred), or simply export them in your local terminal:
export MY_SECRET=<my_secret_value>
For secrets needed during GitHub actions, notify @millerh1 and he can add them.
Finally, if you notice any secrets/keys in the git repo, notify @millerh1 immediately via Slack (BRN members) or via email (outside contributors).
Sometimes it is necessary for us to rebuild the local version of the db. This need might arise if the local database is altered and no longer works (as in deleting necessary tables/records), or if the production database changes and the new data is required for local testing.
To resync the local database with production, do the following:
docker-compose down
docker-compose build --no-cache db
docker-compose up --build --force-recreate --no-deps
This should spin up the db with a full copy of the current prod database.
These steps will detail how to set up the dev environment and get started without using gitpod.
git clone git@github.com:Bioinformatics-Research-Network/Bioinformed-Skill-App.git
git checkout -b <name_of_branch>
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install -i /usr/local/aws-cli -b /usr/local/bin
rm -r aws/
rm awscliv2.zip
us-east-1
)aws configure
aws s3 cp s3://skill-assessment-app/dev-secrets/.env.download.dev.sh .
bash .env.download.dev.sh
pyenv install 3.10.4
pyenv shell 3.10.4 # Activate pyenv
python -m venv venv
pip install -r requirements.txt
cd <service_dir>/
pip install -r requirements.txt
export APP_ENV="testing"
docker-compose up --scale <service>=0
We use unit tests to ensure the code works as expected, even after new features are added or bugs squashed. Because all the repos are python-based, we use the pytest unit testing system. Within the directory for each service is a tests/
folder -- this contains the tests. You can learn more about writing and running tests from the official pytest docs here.
To run tests, simply navigate to the service of interest, and run pytest
:
# Enter webui/ dir
cd webui/
# Install service deps if you haven't already
pip install -r requirements.txt
# Set app env
export APP_ENV=testing
# Run pytest
pytest
Note: All other services will have to be running for this to work (see docker-compose instructions above).
Finally, we use 'coverage' to measure the proportion of the code base which our tests/
actually test.
You can locally test coverage by running the following:
# Enter webui/ dir
cd webui/
# Install service deps if you haven't already
pip install -r requirements.txt
# Set app env
export APP_ENV=testing
# Run pytest via coverage
coverage run -m pytest
# Report the coverage
coverage report
This will indicate the proportion of the codebase covered by the tests. To explore which lines are not covered, export an HTML report, download it, and then open it in your browser:
coverage html # Run this after `coverage run -m pytest`
To automate the process of unit tests, code coverage, and deployment, we use GitHub actions. We create workflows (found in the .github/workflows/
dir) which use YAML to define all the steps run in GitHub actions.
For each service, there are two workflows currently defined:
test.<service>.yml
- runs unit tests and code coverage.
main
branch in the directory for that service OR whenever a pull request is made to add changes to the main branch for that service. deploy.<service>.yml
- deploys the service into production on AWS.
Most of these files are boilerplate, so you will not need to edit/write them yourself unless you want to!
In each repo, there are two badges which are automatically updated by GitHub actions:
These badges come from running unit tests and code coverage as part of the GitHub actions workflow for that directory.