Skip to content

Commit

Permalink
Merge pull request #29 from ai-cfia/28-update-the-deployment-document…
Browse files Browse the repository at this point in the history
…ation-to-display-every-path-to-test

issue #28: usage and deployment documentation update
  • Loading branch information
ThomasCardin authored Jan 9, 2024
2 parents e44e828 + 3b0aedb commit 622c2b4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 24 deletions.
16 changes: 2 additions & 14 deletions docs/DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
# Deployment

## Azure
Create and set the environment variables based on `.env.template`. Make sure
Note on the container: Create and set the environment variables based on `.env.template`. Make sure
`FINESSE_BACKEND_DEBUG_MODE` is NOT set to `True` in PRODUCTION builds.

Build (do this from your WSL Ubuntu where Docker is already installed):

```
docker build -t finesse-backend .
```

test locally:

```
export PORT=<your_port_here>
docker run -p $PORT:$PORT -e PORT=$PORT --env-file .env finesse-backend
```
Refer to the [infrastructure repository](https://github.com/ai-cfia/infra) for a Kubernetes deployment. The secrets (in this case environment variables) are managed with Hashicorp Vault.
52 changes: 42 additions & 10 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,56 @@
## Running and testing the API
Create and set the environment variables based on `.env.template`.
# Running and testing the API locally

## With your local environment

Create and set the environment variables based on `.env.template`. You will need to create a `.env` file.

Running:

```
```bash
flask run -h 0.0.0.0 --debug
```

Alternatively, set the `FINESSE_BACKEND_DEBUG_MODE` environment variable to
`True` and
run:
```
`True` and run:

```bash
python run.py
```

Query from the command-line:
## With docker

Create and set the environment variables based on `.env.template`. You will need to create a `.env` file.

Build the container:

```bash
docker build -t finesse-backend .
```

Deploy the container locally:

```bash
docker run -p 5000:5000 -e PORT=$PORT --env-file .env finesse-backend
```
curl -X POST http://localhost:5000/search --data '{"query": "is e.coli a virus
or bacteria?"}' -H "Content-Type: application/json"

## Check if the API is working properly

Test the path: `/search/static`

```bash
curl -X POST http://localhost:5000/search/static --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json"
```

Test the path: `/search/azure`

```bash
curl -X POST http://localhost:5000/search/azure --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json"
```

Test the path: `/search/ailab`

```bash
curl -X POST http://localhost:5000/search/ailab --data '{"query": "is e.coli a virus or bacteria?"}' -H "Content-Type: application/json"
```

JSON structure explanation:
Expand All @@ -30,4 +62,4 @@ JSON structure explanation:
- title: The title of the document.
- content: The main content or body of the document.
- subtitle: The title or titles extracted from the snippet.
- last_updated: The last modified date of the document.
- last_updated: The last modified date of the document.

0 comments on commit 622c2b4

Please sign in to comment.