# lambda-video
This repo contains the AWS lambdas used to support the video pipeline.

Each lambda is within the video_workflow_pipeline directory rather than in their
own directories like in the cookiecutter lambda. This flat structure was used to
make it easier to test and run the code locally for each lambda without having
to run docker.

Setup

First make sure the environment variables from config.py are set.

```
cd lambda/video_workflow_pipeline
source env/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
```

Linting

```
flake8
```

Testing

```
python -m pytest tests/
```

## Video Dashboard Item Finder

The video dashboard item finder lambda is a scheduled lambda used to search 
for newly inserted items in the video dashboard item table and post to ows-video 
to start workflows for each of the videos.

### Running Video Dashboard Item Finder without Docker

Make sure the environment variables from config.py are set.

Add the following to video_dashboard_item.py

```
if __name__ == '__main__':
    handler(None, None)
```

Then run

```
python video_dashboard_item_finder.py
```

### Testing the Lambda in the AWS Console

The video dashboard item finder lambda can be tested in the AWS console on a manual
basis. This cuts back on clutter produced by scheduling it to run in QA. In the
Lambda section of the console, find and select the video dashboard item finder
function. If no Test Event exists, create a test event and save it. Scheduled
lambdas require a datetime to be passed in to the input (intended to be the current
time).
```
{
    "time": "YYYY-MM-DDTHH:MM:SSZ"
}
```
but replace the datetime with the current datetime. Here's one way to get the current
datetime on Mac:
```
echo $(date -u +%FT%TZ)
```
