# Apps Runner Lambda
It runs apps unit of works which are in `QUEUED` status.

## Lambda Environment variables
To execute the Apps Runner Lambda he following environment variables must be configured:

| Variable                | Description                                                   |
|-------------------------|---------------------------------------------------------------|
| `ENVIRONMENT`           | Environment name (`prod`, `dev`)                              |
| `MAX_ACTIVE_RUNS`       | Concurrent runs limit for `DAILY` UoWs                        |
| `BACKFILL_ACTIVE_RUNS`  | Concurrent runs limit for `BACKFILL` UoWs                     |
| `PRIORITY_THRESHOLD`    | Min UoW priority value                                        |
| `PROCESS_BACKFILL_UOWS` | Flag to enabla/disable processing of UoWs with `BACKFILL` type|
| `RDS_SECRETS_KEY`       | RDS secret key                                                |
| `ETL_SF_ARN`            | ARN of `delphi-apps_etl_main` SF                              |
| `CHARTMETRIC_SF_ARN`    | ARN of `delphi-chartmertric_snowflake` SF                     |
| `SENTRY_SECRET_KEY`     | Sentry secret key                                             |


## Lambda Input
Lambda works without payload, but you can optionally pass a list of data sources to process(all by default):
```json
{
    "data_sources": ["slz", "chartmetric"]
}
```

## Lambda Output
In case of successful lambda execution the following output will be provided:
```json
{
    "meta": {
        "status": "OK"
    }
}
```

If any kind of exception occurred, the response will look like the following:
```json
{
    "meta": {
        "status": "FAILURE",
        "message": <exception message>
    }
}
```

## Developers guide

Use `pre-commit` for git hooks managing (https://pre-commit.com/#installation). Hook configuration
can be found at .pre-commit-config.yaml. `isort` and `yapf` tools are included to run as a part
of precommit hook.

To register a new hook run:
```shell script
pre-commit install
```

To run hooks without code committing:
```shell script
pre-commit run
```

Don’t forget to run formatter check, `pylint` and `mypy` before code committing manually.
It will save you from wasting time at reading CI logs for failed build.
```shell script
make fmtcheck && make lint && make typecheck
```
