# streamlit-audience
Demo application to showcase artist similarity models

## Getting Started

### Installation

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

```bash
$ pyenv install 3.8.13
$ pyenv global 3.8.13
```

or installing with `Homebrew`:

```bash
$ brew update
$ brew install python@3.8.13
```

Add `python3.8.13` to system path (for iTerm):

```bash
$ echo 'export PATH="/opt/homebrew/opt/python@3.8.13/bin:$PATH"' >> ~/.zshrc
```

Apply profile changes (iTerm2):

```bash
$ source ~/.zshrc
```

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

```bash
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
```

Prepare environment and install dependencies:

```bash
$ cd streamlit-audience
$ make env
```

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


### Updating

To install new dependencies.

```bash
poetry install
```

### Linting

To lint: `make lint`

To format: `make fmt`

### Developing Streamlit app

To run artist similarity Streamlit app locally. App can be closed with CTRL+C from terminal

```bash
$ cd streamlit-audience
$ make dev
```


### Deploying to DEV AWS account
You can deploy the application manually to the [dev-streamlit-audience](https://us-east-1.console.aws.amazon.com/ecs/v2/clusters/dev-streamlit-audience/services?region=us-east-1) ECS Fargate cluster by following these steps:

1. Generate temporary MFA-powered AWS credentials for your DEV AWS account using `generate.sh` script from [aws-creds-generator](https://github.com/theorchard/collab/tree/master/jcarrion/aws-creds-generator) by following the README from there.
2. Run docker locally and authenticate yourself in a remote ECR repository by running:
```bash
$ make docker-login
```
3. Deploy the app by running:
```bash
$ make docker-pipeline
```


### Default Streamlit app

To run default Streamlit app that's included by default. This will open browser window. App can be closed with CTRL+C from terminal

```bash
$ cd streamlit-audience
$ make demo_start
```
### Containerized Streamlit app depending on local OS

To run developed Streamlit app from Docker container using local OS. App can be accessed from browser: http://localhost:8080/

```bash
$ cd streamlit-audience
$ make up-local
```

### Containerized Streamlit app depending for amd64/Linux
This is meant for creating image that suits AWS.
```bash
$ cd streamlit-audience
$ make up
```
