Skip to content

lsst-sqre/squash-api

Repository files navigation

SQuaSH API

RESTful API for managing Science Pipelines metrics. You can learn more about SQuaSH in SQR-009.

Deployment

The SQuaSH API is deployed as part of the Science Platform. The SQuaSH API Helm chart is maintained at the SQuaRE charts repository.

We assume you are familiar with the SQuaSH MySQL 5.7 instances on Google Cloud SQL. There's an instance for each SQuaSH environment, sandbox and prod. Such instances exist under the sqre project on Google Cloud Platform, and the service account key can be found on SQuaRE 1Password (search for SQuaSH Cloud SQL service account key).

Development workflow

  1. Clone the repository
git clone  https://github.com/lsst-sqre/squash-api.git
cd squash-api
  1. Install the dependencies
python3 -m venv venv

Activate the Flask app and set development mode in your environment

echo "export FLASK_APP=squash.app:app" >> venv/bin/activate
echo "export FLASK_ENV=development" >> venv/bin/activate

source venv/bin/activate
make update
  1. Run the app locally

To run the app locally you need a local instances of MySQL, Redis, InfluxDB and Chronograf, which are set up through docker-compose.

docker-compose up -d

The SQuaSH API requires the AWS credentials present in the environment. It also assumes that the s3://squash-dev.data/ S3 bucket was previously created.

Note that by default the app will run using the development config profile, which is equivalent to do:

export SQUASH_API_PROFILE="squash.config.Development"
flask run

The app will run at http://127.0.0.1:5000

On another terminal start the Celery worker:

celery -A squash.tasks -E -l DEBUG worker

Running tests

Pytest uses the docker-compose setup to run functional tests:

tox -e pytest

To run unit tests only, you can skip the docker-compose using a pytest marker:

pytest -m "unit"

You can also exercise the API running the test API notebook.