File size: 1,821 Bytes
0ada3cf
 
dd9a82b
0ada3cf
 
 
 
dd9a82b
0379fe4
0ada3cf
f006f31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd9a82b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
title: Room API
emoji: 🚀
colorFrom: indigo
colorTo: pink
python_version: 3.8
pinned: true
short_description: Room API
sdk: docker
---
# Environment
Set environment variables in .env file or via shell:

```bash
export API_KEY="APIKEY TO USE THIS API"
export HUGGINGFACE_ACCESS_TOKEN="HF READ ACCESS TOKEN"
```

## Consul environment
To use the enviroment variables from Consul, set variables in consul.env file or via shell:

```bash
TGX_CONSUL_AUTH_USER="CONSUL AUTH USER"
TGX_CONSUL_AUTH_PASS="CONSUL AUTH PASSWORD"
TGX_CONSUL_TOKEN="CONSUL TOKEN"
TGX_CONSUL_NODES="CONSUL_URLS_SEPARTEDBY_;"
```

# Development
Dependencies and run is managed by Poetry

## Dependencies
Use Poetry to Update and install dependencies:

```bash
poetry update
poetry install
```

## Build

### Using docker compose
```bash
docker compose build --no-cache
docker compose up -d
```

*NOTE* Docker compose is set to run on port 8080, change the port in docker-compose.yml if needed.

### Docker API
Check if docker daemon is running:

```bash
sudo systemctl start docker
```

Build docker:

```bash
docker build -t mappingservice .
```

## Run


### Console

```bash
poetry run uvicorn mappingservice.main:app --reload
```

Site runs at http://127.0.0.1:8000/ml-api


### Docker
```bash
docker run -d --name mycontainer -p 80:80 mappingservice
```
##### Run

Send Consul variables on Docker run

###### API
```bash
docker run -e TGX_CONSUL_NODES='URL_NODES' -e TGX_CONSUL_TOKEN='TOKEN' -e TGX_CONSUL_AUTH_USER='USER' -e TGX_CONSUL_AUTH_PASS='PWD' -d --name mycontainer -p 80:80 mappingservice
```

### Benchmark
Use Poetry to Update and install Locust dependencies:

```bash
poetry update --only benchmark
poetry install --only benchmark
```

Run Locust in terminal
```bash
locust -f ./benchmark/
```
Site runs at http://localhost:8089/