taar-api-lite/README.md

2.9 KiB

TAAR API-lite

CircleCI codecov

Instructions for development

The only special thing you will need to do is to export your AWS keys as enviroment variables to run the dev server. The docker-compose.yml file specifies two keys AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID. These keys are required to access the S3 buckets which host the data models used by TAARlite.

  1. Make sure you have docker and docker-compose
  2. export AWS_SECRET_ACCESS_KEY=
  3. export AWS_ACCESS_KEY_ID=
  4. make up

Instructions for deployment

The target environment for this project follows the dockerflow conventions. In order to run it correctly, a number of environment variables needs to be set up. The full list of variables can be found in the web section of the docker-compose.yml file. From a services standpoint, this project requires:

  • an optional Redis cache service, defined by CACHE_URL
  • redis cache expiry in seconds defined by TAAR_CACHE_EXPIRY

Updating Taar

The core of taar-service lives in the mozilla-taarlite python package. These are the steps required to deploy a new version of mozilla-taarlite on taar-api-lite using hashin:

From the root of the repository:

hashin mozilla-taarlite==<major>.<minor>.<patch>

Then open a pull request with the changes to requirements.txt. Once it's merged to master, the service will automatically update.

Web API

The dev service is hosted at: htps://taar.dev.mozaws.net

You must include a single GUID as the last segment of a URL encoded path.

The TAARlite service currently exposes a single URL that can be called with HTTP GET on the URL path :

    /taarlite/api/v1/addon_recommendations/<your_guid_here>/

A sample invocation for the GUID {some_addon_guid} using curl would look like this:

curl https://taar.dev.mozaws.net/taarlite/api/v1/addon_recommendations/%7Bsome_addon_guid%7D/

You should get JSON output that appears in this format:

{"results": ["guid1", "guid2", "guid3", "guid4"]}

You may specify an optional normalization mode by passing in a CGI argument normalize using one of the following choices:

  • rownorm_sum
  • row_count
  • row_sum

Generally - you should get the best results using rownorm_sum.

Passing in an invalid normalization type will yield an empty results list.

Example :

curl http://localhost:8000/taarlite/api/v1/addon_recommendations/%7Bsome_addon_guid%7D/?normalize=rownorm_sum