ows-masters-registry
====================

Registry of unique sound recordings and the territories for which we can exercise rights

## Getting Started

### Installation

The installation is very straightforward, but before starting make sure you have python3.11 installed. If you use a Mac, you can install it using `brew`. A simple way to manage python versions is with pyenv.
```bash
$ brew update
$ brew install pyenv
$ pyenv install 3.11.0
$ pyenv local 3.11.0
```

Update your `.zshrc` to insert the pyenv shims directory at the beginning of `$PATH`

```bash
# pyenv path
$ export PYENV_ROOT="$HOME/.pyenv"
$ export PATH="$PYENV_ROOT/shims:$PATH"
```

Sanity check that the python3 path is `/Users/$USER/.pyenv/shims/python3`

```bash
$ which python3
```

### Running

When all dependencies have been installed,
make a copy of the `.env.shadow` file:
```
cp .env.shadow .env
```
and set the relevant environment variables

If instead of working within a Docker container, you would like to simply run the application locally, you can run:

```
make pip_dev
make dev
```

By using the development server, you will have access to specific features that
are not necessarily available in production, such as the exception tracer.

Run Redis
Set up REDIS https://redis.io/topics/quickstart
```
redis-server
```

Run celery worker

```
celery -A  masters_registry.tasks.bulk --loglevel=debug worker
```

When making code changes on the celery worker, please restart celery
### Testing

```bash
py.test tests/ --cov masters_registry --cov-report term-missing
flake8 masters_registry/ tests/
```

## Environment Variables
| Env Variable  | Purpose                                                                                                                   |
| ------------- |-------------------------------------------------------------------------------------------------------------------------- |
| LOGGER_DSN    | Loggly https event endpoint for QA and Prod environments. Example value: https://logs-01.loggly.com/inputs/TOKEN/tag/ows1 |
| SENTRY_DSN    | Exception alerting. Example: export SENTRY_DSN=https://&lt;token&gt;@app.getsentry.com/87050. Uncaught exceptions will automatically go to Sentry. Caught exceptions can be sent to Sentry by calling: sentry_client.captureException() |
| AR_DB_URL     | Database URL for the art_relations database including the dialect, driver, username, password, host, port (optional) and database. Example: AR_DB_URL=mysql+pymysql://&lt;user&gt;:&lt;password&gt;@&lt;host&gt;/art_relations |
| BULK_STATUSES_DB_URL | Database URL for database where statuses of background processing tasks are stored including the dialect, driver, username, password, host, port (optional) and database. Example: AR_DB_URL=mysql+pymysql://&lt;user&gt;:&lt;password&gt;@&lt;host&gt;/ows_masters_registry |
| CELERY_RESULT_BACKEND | REDIS url  (this can be set to anything if you're not working with celery)
| BROKER_URL | REDIS url (this can be set to anything if you're not working with celery)
