You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-25Lines changed: 36 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,24 +5,35 @@ This project demonstrates a foundational MLOps workflow for deploying a Breast C
5
5
## Project Structure
6
6
7
7
```
8
-
.venv/ # Python virtual environment (ignored by Git)
9
-
data/ # Stores the dataset (data.csv) - Tracked by Git for CI/CD simplicity
10
-
models/ # Stores the trained model (model.joblib) - Ignored by Git
11
-
notebooks/ # For exploratory data analysis and experimentation
12
-
src/
13
-
app.py # Flask API for model inference
14
-
model.py # Script for training and saving the model
15
-
tests/ # For unit and integration tests
16
-
.github/ # GitHub Actions workflow files
17
-
workflows/
18
-
main.yml # CI/CD pipeline definition
19
-
Dockerfile.api # Dockerfile for the Flask API container
20
-
Dockerfile.streamlit # Dockerfile for the Streamlit UI container
21
-
docker-compose.yml # Defines and links multi-container Docker application
22
-
requirements.txt # Python dependencies
23
-
README.md # Project documentation
24
-
.gitignore # Specifies files and directories to ignore in Git
25
-
streamlit_app.py # Streamlit user interface for predictions
8
+
breast-cancer-ops/
9
+
├── .github/ # GitHub Actions workflow files
10
+
│ └── workflows/
11
+
│ └── main.yml # CI/CD pipeline definition
12
+
├── config/ # Configuration files
13
+
│ ├── docker-compose.yml # Defines and links multi-container Docker application
14
+
│ ├── Dockerfile.api # Dockerfile for the Flask API container
15
+
│ └── Dockerfile.streamlit # Dockerfile for the Streamlit UI container
16
+
├── data/ # Stores the dataset (data.csv) - Tracked by Git for CI/CD simplicity
17
+
│ └── data.csv
18
+
├── docs/ # Project documentation (optional)
19
+
├── logs/ # Application logs
20
+
│ └── api_logs.log
21
+
├── models/ # Stores the trained model (model.joblib) - Ignored by Git
22
+
│ └── model.joblib
23
+
├── notebooks/ # For exploratory data analysis and experimentation
24
+
├── scripts/ # Utility and test scripts
25
+
│ ├── bash_test.sh
26
+
│ └── powershell_test.ps1
27
+
├── src/ # Source code
28
+
│ ├── app.py # Flask API for model inference
29
+
│ ├── model.py # Script for training and saving the model
30
+
│ └── streamlit_app.py # Streamlit user interface for predictions
31
+
├── tests/ # For unit and integration tests
32
+
│ └── sample_payload.json
33
+
├── .env.example # Environment variables template
34
+
├── .gitignore # Specifies files and directories to ignore in Git
35
+
├── README.md # Project documentation
36
+
└── requirements.txt # Python dependencies
26
37
```
27
38
28
39
## Setup and Run
@@ -122,30 +133,30 @@ With the Flask API running locally (as described in step 6 above), you can test
122
133
123
134
## Streamlit UI
124
135
125
-
The Streamlit application (`streamlit_app.py`) provides an interactive web interface for making predictions using the Flask API.
136
+
The Streamlit application (`src/streamlit_app.py`) provides an interactive web interface for making predictions using the Flask API.
126
137
127
138
1. **Run the Streamlit application locally:**
128
139
Ensure your virtual environment is activated and the Flask API is running (as described in step 6 under "Setup and Run"), then run:
129
140
```bash
130
-
streamlit run streamlit_app.py
141
+
streamlit run src/streamlit_app.py
131
142
```
132
143
The UI will open in your browser, typically at `http://localhost:8501`.
133
144
134
145
## Dockerization
135
146
136
-
The project now uses Docker Compose to manage both the Flask API and the Streamlit UI.
147
+
The project now uses Docker Compose to manage both the Flask API and the Streamlit UI. All Docker configuration files are located in the `config/` directory.
137
148
138
149
1. **Build and Run with Docker Compose:**
139
150
Ensure the model is trained (`models/model.joblib` exists), then navigate to the project root and run:
140
151
```bash
141
-
docker-compose up --build -d
152
+
docker-compose -f config/docker-compose.yml up --build -d
142
153
```
143
-
This will build images for `Dockerfile.api` and `Dockerfile.streamlit`, and start both services.
154
+
This will build images for `config/Dockerfile.api` and `config/Dockerfile.streamlit`, and start both services.
144
155
The Flask API will be accessible via `http://localhost:5000/` and the Streamlit UI via `http://localhost:8501/`.
145
156
146
157
2. **Stop Docker Compose services:**
147
158
```bash
148
-
docker-compose down
159
+
docker-compose -f config/docker-compose.yml down
149
160
```
150
161
This will stop and remove all services and their networks.
151
162
@@ -157,7 +168,7 @@ A GitHub Actions workflow (`.github/workflows/main.yml`) is configured to automa
157
168
2. **Set up Python and install dependencies:** Prepares the environment for model training.
158
169
3. **Create `models/` directory:** Ensures the directory exists for saving the trained model.
159
170
4. **Train the model:** Runs `src/model.py` to train the model and generate `models/model.joblib`.
160
-
5. **Build and Push Docker Compose Images:** Builds both API (`Dockerfile.api`) and Streamlit UI (`Dockerfile.streamlit`) images and pushes them to Docker Hub.
171
+
5. **Build and Push Docker Compose Images:** Builds both API (`config/Dockerfile.api`) and Streamlit UI (`config/Dockerfile.streamlit`) images and pushes them to Docker Hub.
161
172
6. **Run Docker Compose services (for testing):** Starts both the API and Streamlit UI services in isolated containers.
162
173
7. **Wait for services to be ready:** A robust loop that polls both API (`/`) and Streamlit UI (`/`) endpoints until both are responsive.
163
174
8. **Test health and prediction endpoints:** Executes `curl` commands to verify Flask API functionality.
0 commit comments