# daemon-video

A daemon for longer-running video jobs.

**Python Version:** This project requires Python 3.13.

### Installation

```bash
$ cd daemon-video
$ python3.13 -m venv env
(env) $ . env/bin/activate
(env) $ pip install -r requirements.txt
(env) $ pip install -r requirements-dev.txt
```

### Permissions

In PROD and QA environments, to accept and authorize incoming and outgoing
requests, make sure you have the right DynamoDB permissions, as highlighted
in the corresponding [tech design](https://docs.google.com/document/d/1eHoI_BddTFMi15yCaHS6KvhSSoTrMEd3WwJINIpgNpM/edit).

### Running

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

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

or

```bash
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.

Note: Make sure to have your AWS credentials set up, either through environment variables or through a config file, and that the SQS queue exists.

### Testing

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

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

or

To run tests: `make test`

To lint: `make lint`

### Updating

To install new dependencies.

```bash
(env) $ pip install -r requirements.txt
(env) $ pip install -r requirements-dev.txt
```

or

```bash
make pip_dev
```

### Testing with Docker

1. `docker build .`
2. `aws sts assume-role --role-session-name something-very-cool --role-arn arn:aws:iam::437795906767:role/qa-daemon-video-service-role` *Note: You'll need to have systems get you access to this role.*
3. `docker run -it -d -e AWS_REGION='us-east-1' -e AWS_ACCESS_KEY_ID='ASIAWL3VLMTHU7RTJ7GC' -e AWS_SECRET_ACCESS_KEY='1k5jBZ8hlPVBS4gkAE/ZMiFR4nMA5yKnFDeTZs34' -e AWS_SESSION_TOKEN='FQoGZXIvYXdzEGIaDO8ES3KmAiWol1eZByKWAuNezDbTZMBS2FbaKR7YddHOjlUOA9Ujb/cGzAxcbXy1hEnEm7bEn/Hm+2tXHUKfVGX2ybfEx9NV25B3nfWGlPKhbOm708RPDaoXDWud83nE9bGQ/yhWPLUFAXaa8gX59ZtViMs/Us6TUSebApbJ7vlZ99OMt/c7RIoCyxqVam2qRp4wuLJtiFTqdRgGocCVyombDXlfbl2ZndVS8/95Mw6WdVX5txTNQ0TLF9R/wUGI5WlOV/I1XFAaWVUHL5IrzVdF+X4ZmS9v80Bb/1/VAE4Z62xRvoN543P0UmbsVoaeu5io8MjAdAduRqKURSLz8TfMvhoqYpKbvrb4qvfMNRedQInfo2Rw3mSXv/syqi1buiBcRJeXKPatgOAF' b818a884151a`
4. `docker exec -it 861966ee9919 bash`