ows-location
=======

The Orchard Web Service for resolving IP addresses to locations

[![CI](https://github.com/theorchard/ows-location/actions/workflows/main.yml/badge.svg)](https://github.com/theorchard/ows-dmp/actions/workflows/main.yml)
<!-- Pytest Coverage Comment:Begin -->
<!-- Pytest Coverage Comment:End -->
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

## Getting Started

### Installation

Before starting make sure you have `python3.11` installed.
An easy way to manage python versions is with `pyenv`:

```bash
$ pyenv install 3.11.2
$ pyenv global 3.11.2
```

Make sure you have `Poetry` installed (https://python-poetry.org/docs/#installation).

```bash
curl -sSL https://install.python-poetry.org | python3 -
```

Prepare environment and install dependencies:

```bash
$ cd ows-location
$ make env
```

### Download IP2Location dev/qa binaries

```bash
make binaries
```

### Running

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

```bash
make dev
```

All make commands will automatically install all dependencies in a virtual environment folder called env.
You can activate a virtual environment by running `. env/bin/activate` or `source env/bin/activate`.

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
$ pytest tests/unit/
```

or

To run unit tests: `make test`

To run unit tests with coverage reporting: `make test_unit`


### Updating

To install new dependencies.

```bash
poetry install
```

### OpenAPI specification

OpenAPI specification available for dev environment only.

Go to http://localhost:5001/docs to view Swagger UI.

To generate `OpenAPI YAML`:

```bash
$ make openapi
```

### Linting

To lint: `make lint`

To format: `make fmt`

### Third-Party Integrations for Reporting

This boilerplate comes with support for Sentry, and Datadog.
