# ows-artist

Artist microservice. Manages CRUD operations on artist metadata.

## Configuration

The application uses the following environment variables for configuration:

Database connection parameters for the `art_relations` schema:

- `AR_MYSQL_DATABASE`
- `AR_MYSQL_HOST`
- `AR_MYSQL_PASSWORD`
- `AR_MYSQL_PORT`
- `AR_MYSQL_USER`

Note: the above are not used in the "test" environment, which uses SQLite rather than a live database instance.

Other environment vars:

- `Environment` - application environment (e.g. "prod", "dev", "qa", "test")
- `SENTRY_DSN` - DSN string for connecting to Sentry
- `OWS_ACCOUNT_URL` - URL for calls to the [ows-account microservice](https://github.com/theorchard/ows-account).
- `PORT` - port to run dev server on (default: 5000)

## Getting Started

### Installation

The installation is very straightforward, but make sure you are using at least
python 3.13. If you use a Mac, you can install it using `brew`. If you use
Windows, just ask for a remote VM that has it installed for you.

```bash
$ cd ows-artist
$ pyvenv env
(env) $ . env/bin/activate
(env) $ poetry install
```

Copy .env.shadow to .env and add the appropriate environement variables for your
environment.

```bash
$ cp .env.shadow .env
```

### Running

When all dependencies have been installed, you can run the flask application
on your local instance by running:

```bash
(env) $ python dev.py
```

You can optionally specify a port:

```bash
(env) $ PORT=5002 python dev.py
```

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

### Testing

To run the tests, all you have to do is to run:

```bash
(env) $ py.test tests/ --cov artist --cov-report term-missing
(env) $ ruff artist/ tests/
```
