Skip to content

Commit 5ed24b4

Browse files
byabazairejananos
authored andcommitted
feat: Add MLConnector
- Add MLConnector README file - MLConnector basic functionality - Add endpoint to save inference data back to side-api - Change xai to read data from s3 - Change application description and model update Signed-off-by: John Byabazaire <byabazairej@gmail.com>
1 parent 897e3d5 commit 5ed24b4

75 files changed

Lines changed: 6988 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

6 KB
Binary file not shown.

mlconnector/.DS_Store

14 KB
Binary file not shown.

mlconnector/README.md

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
## MLConnector Setup Guide
2+
3+
This guide will walk you through setting up and running the MLConnector using Docker.
4+
5+
---
6+
7+
## Prerequisites
8+
9+
Before you begin, ensure you have the following installed on your system:
10+
11+
- **Docker**: Install Docker Engine and Docker Compose from [Docker’s official website](https://www.docker.com/).
12+
13+
---
14+
15+
## Environment Variables
16+
17+
The MLConnector relies on several external components. Define the following environment variables in your shell or an `.env` file:
18+
19+
### 1. Docker Registry
20+
The MLConnector dynamically creates and stores docker images for inference applications used within MYLSysOps. As such, it needs to to be able to communicate to a registry weather public, or private. This application was tested with docker registry. For further information on docker registry [check](https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-registry/).
21+
22+
- `DOCKER_USERNAME`: Your Docker registry username
23+
- `DOCKER_PASSWORD`: Your Docker registry password
24+
25+
### 2. AWS (File Storage)
26+
The MLConnector uses an external storage service, S3 to store it's data including training data and other files. You will need to setup and S3 bucket, or S3 compatible service to complete this setup. After, please provide the following details. If you do not have access to S3 bucket, or S3 compatible service, please contact us and we can help setup a temporarly one.
27+
- `AWS_ACCESS_URL`: AWS S3 endpoint URL
28+
- `AWS_ACCESS_KEY_ID`: AWS access key ID
29+
- `AWS_SECRET_ACCESS_KEY`: AWS secret access key
30+
- `AWS_S3_BUCKET_DATA`: Name of the S3 bucket for data
31+
32+
### 3. PostgreSQL Database
33+
This is used for internal communication of the varrious services. You can setup an external database service if you like. For simplicity you can you use the default values;
34+
- `POSTGRES_DB`: PostgreSQL database name (default, `mlmodel`)
35+
- `POSTGRES_USER`: PostgreSQL username (default, `postgres`)
36+
- `POSTGRES_PASSWORD`: PostgreSQL password (default, `strongpassword`)
37+
- `PGADMIN_DEFAULT_EMAIL`: pgAdmin default login email (default, `user@mail.com`)
38+
- `PGADMIN_DEFAULT_PASSWORD`: pgAdmin default login password (default, `strongpassword`)
39+
- `DB_HOST_NAME`: Database host (e.g., `database`, This corresponds to the name of the container)
40+
- `DB_PORT`: Database port (default: `5432`)
41+
- `DB_DRIVER`: Database driver string (default, `postgresql+asyncpg`) **NOTE:** Only use an async driver
42+
43+
### 4. Northbound API Endpoint
44+
The MLConnector communicates with part of the MYLSyops via the `NORTHBOUND_API`. Please set this value to the right endpoint.
45+
- `NORTHBOUND_API_ENDPOINT`: Base URL for the Northbound API (e.g., `http://your-host:8000`)
46+
47+
---
48+
49+
## Running the Application
50+
51+
1. **Start the Docker Containers**
52+
53+
```bash
54+
docker compose up -d
55+
```
56+
57+
This command builds and launches all required services in detached mode.
58+
59+
2. **View Container Logs**
60+
61+
```bash
62+
docker compose logs -f
63+
```
64+
65+
---
66+
67+
## Accessing the API Documentation
68+
69+
Once the services are up and running, open your browser and navigate to:
70+
71+
```
72+
http://<your-host>:8090/redoc
73+
```
74+
75+
Replace `<your-host>` with your server’s hostname or `localhost` if running locally.
76+
77+
---
78+
79+
## Usage Example
80+
81+
### 1) Add ML Models
82+
83+
```bash
84+
curl -X 'POST' \
85+
'http://localhost:8090/model/add' \
86+
-H 'accept: application/json' \
87+
-H 'Content-Type: application/json' \
88+
-d '{
89+
"modelname": "GradientBoostingRegressor",
90+
"modelkind": "Regressor",
91+
"hyperparameter": [
92+
{
93+
"parameter": "string",
94+
"value": 0
95+
}
96+
],
97+
"modelperformance": [
98+
{
99+
"metric": "string",
100+
"order": 0,
101+
"threshold": 0
102+
}
103+
],
104+
"trainingresource": [
105+
{
106+
"resource_name": "string",
107+
"value": 0,
108+
"deploy": "string"
109+
}
110+
],
111+
"runresource": [
112+
{
113+
"resource_name": "string",
114+
"value": 0,
115+
"deploy": "string"
116+
}
117+
],
118+
"featurelist": [
119+
{
120+
"feature_name": "size",
121+
"type": "cont",
122+
"kind": 0,
123+
"units": 0
124+
},
125+
{
126+
"feature_name": "time_of_day",
127+
"type": "cat",
128+
"kind": 0,
129+
"units": 0
130+
},
131+
{
132+
"feature_name": "minute",
133+
"type": "cat",
134+
"kind": 0,
135+
"units": 0
136+
},
137+
{
138+
"feature_name": "second",
139+
"type": "cat",
140+
"kind": 0,
141+
"units": 0
142+
},
143+
{
144+
"feature_name": "hour",
145+
"type": "cat",
146+
"kind": 0,
147+
"units": 0
148+
},
149+
{
150+
"feature_name": "day_of_week",
151+
"type": "cat",
152+
"kind": 0,
153+
"units": 0
154+
},
155+
{
156+
"feature_name": "download_time_ms",
157+
"type": "cont",
158+
"kind": 1,
159+
"units": 0
160+
}
161+
],
162+
"inference": [
163+
{
164+
"type": "string",
165+
"value": "string"
166+
}
167+
],
168+
"modeltags": [
169+
"regression",
170+
"fast"
171+
]
172+
}'
173+
```
174+
175+
### 2) Add Model Files
176+
177+
Upload model files (pickled model `.pkl`, training code `.py`, etc.) using the CC storage system:
178+
179+
```bash
180+
curl -X 'POST' \
181+
'http://localhost:8090/model/b2078e0e-e2f3-4870-840c-7f9fbf2ab76d/upload' \
182+
-H 'accept: application/json' \
183+
-H 'Content-Type: multipart/form-data' \
184+
-F 'file=@model_backend_id_144.pkl' \
185+
-F 'file_kind=model'
186+
```
187+
188+
> **Note:** The UUID `b2078e0e-e2f3-4870-840c-7f9fbf2ab76d` in the endpoint path is your `model_id`.
189+
190+
---
191+
192+
## Troubleshooting
193+
194+
- **Port Conflicts**: Ensure ports `8090` (API docs) and your database port are available.
195+
- **Environment Variables**: Verify all required variables are set. Use `docker compose config` to inspect the interpolated configuration.
196+
- **Docker Connectivity**: Ensure Docker Engine is running and your user has permissions to run Docker commands.
197+
- **API Error Codes**: All status codes and error messages can be accessed via: `http://<your-host>:8090/redoc`
198+
199+
---
200+
201+
## License
202+
203+
***
204+
205+
---
206+

0 commit comments

Comments
 (0)