# `lambda-product-staging`

## Quickstart

Choose your favourite or similar:

```shell
pip install uv
pipx install uv
brew install uv
```

Run commands for each lambda/task/common:

```shell
git clone git@github.com:theorchard/lambda-product-staging.git
cd lambda-product-staging
make uv_dev
make clean shadow
# cd common
# cd fargate/*
# cd lambda/*
make dev
make docker_up
make docker_event
make docker_down
```

## Project Root

Make commands at the root will fan out and run the corresponding make tasks `lambda/*` `fargate/*` directories, as well as `common/`.

```shell
make clean
make shadow
```

`make lock` is different, in that it will execute `uv lock` in the same folders as well as the project root.

```shell
make lock
```

Gotchas:

* `uv workspaces` share a root virtual environment, and some of the individual module make tasks are destructive, so these cannot currently be run in parallel.

* `make docker_unit_lnit` will exhaust the network space locally with all of the lambdas if you do not accept the prompt to prune networks:
```shell
STDERR:
 update_session-lint-and-test  Built
 Network update_session_default  Creating
 Network update_session_default  Error
failed to create network update_session_default: Error response from daemon: all predefined address pools have been fully subnetted
make[1]: *** [docker_unit_lint] Error 1
```

## Lambdas & Fargate Tasks & `common`

You can cd into any `lambda/*`, `fargate/*`, `common/` and run make tasks for the individual module:


```shell
make dev
make docker_up
make docker_event
make docker_down
make test_unit
make fmt
make lint
make docker_unit_lint
```


## Step Functions

### Visualization

Scripts in the Makefile are available to help you navigate to different aspects of the project. To get these set up you will want to:

* Install [VSCode](https://code.visualstudio.com/)
* Install [`code` command in PATH](https://code.visualstudio.com/docs/setup/mac#_configure-the-path-with-vs-code)
* Install the [AWS Toolkit VSCode Extension](https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.aws-toolkit-vscode)
* `cp .env.shadow .env` and fill out environment variables

Using the AWS Toolkit VSCode Extension, you can visualize the project's step functions with the following `make` commands:

```shell
make view_sfn_bulk_session_ingest
make view_sfn_validate_bulk_assets
make view_sfn_validate_bulk_metadata
```


### Integration Testing

```shell
make test_integration
make docker_sfn_integration_test
```
