Skip to content

Commit 006601c

Browse files
authored
Merge pull request #4 from ByteBard58/fastapi-integration
merge `fastapi-integration` into main
2 parents 0c72ece + e576c2d commit 006601c

19 files changed

Lines changed: 289 additions & 170 deletions

.github/workflows/docker.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ jobs:
1919
src:
2020
- 'Datasets/**'
2121
- '.github/workflows/docker.yml'
22-
- 'app.py'
22+
- 'app/**'
2323
- 'Dockerfile'
2424
- 'requirements.txt'
25-
- 'templates/**'
26-
- 'static/**'
2725
- 'models/**'
26+
- 'notebooks/**'
2827
- 'scripts/**'
29-
- 'fit.py'
3028
- '.dockerignore'
3129
3230
docker-build:

.github/workflows/python-app.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ jobs:
2424
with:
2525
filters: |
2626
src:
27-
- 'app.py'
28-
- 'fit.py'
27+
- 'app/**'
28+
- 'models/fit.py'
2929
- 'requirements.txt'
30-
- 'templates/**'
31-
- 'static/**'
32-
- 'models/**'
30+
- 'notebooks/**'
3331
- 'scripts/**'
3432
- 'Datasets/**'
3533
- '.github/workflows/python-app.yml'
@@ -56,10 +54,10 @@ jobs:
5654
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
5755
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
5856
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
59-
- name: Run Flask app and test with Curl
57+
- name: Run FastAPI app and test with Curl
6058
run: |
61-
nohup python app.py &
59+
nohup uvicorn app.app:app &
6260
sleep 10
63-
curl -I http://127.0.0.1:5000
64-
pkill -f "python app.py"
61+
curl -I http://127.0.0.1:8000
62+
pkill -f uvicorn
6563

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ RUN pip install --upgrade pip && pip install -r requirements.txt
1414
COPY . .
1515

1616
# example env and port
17-
ENV FLASK_APP=app.py
18-
EXPOSE 5000
17+
EXPOSE 8000
1918

20-
# run the flask app
21-
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app", "--workers", "2"]
19+
# run the fastapi app with gunicorn and uvicorn workers
20+
CMD ["gunicorn", "-w", "2", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000", "app.app:app"]

README.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,59 +85,66 @@ CosmoClassifier/
8585
│ ├─ check.yml
8686
│ ├─ docker.yml
8787
│ └─ python-app.yml
88+
├─ app/
89+
│ ├─ schema/
90+
│ │ └─ validation.py
91+
│ ├─ static/
92+
│ │ ├─ confusion_matrix.png
93+
│ │ ├─ conf_mat.py
94+
│ │ ├─ script.js
95+
│ │ └─ style.css
96+
│ ├─ templates/
97+
│ │ └─ index.html
98+
│ ├─ app.py
99+
│ └─ __init__.py
88100
├─ Datasets/
89101
│ └─ SDSS_DR18.csv
90102
├─ models/
103+
│ ├─ __init__.py
104+
│ ├─ fit.py
91105
│ ├─ column_names.pkl
92106
│ └─ estimator.pkl
107+
├─ notebooks/
108+
│ ├─ __init__.py
109+
│ ├─ research_2.py
110+
│ └─ research.py
93111
├─ reports/
94112
│ ├─ research_2.html
95113
│ └─ research.html
96114
├─ screenshots/
97115
│ ├─ ss_filled.png
98116
│ └─ ss_home.png
99-
├─ static/
100-
│ ├─ confusion_matrix.png
101-
│ ├─ script.js
102-
│ └─ style.css
103-
├─ templates/
104-
│ └─ index.html
105117
├─ .dockerignore
106118
├─ .env.example
107119
├─ .gitattributes
108120
├─ .gitignore
109-
├─ app.py
110-
├─ conf_mat.py
111121
├─ Dockerfile
112-
├─ fit.py
113-
├─ health_checker.py
114122
├─ LICENSE
115123
├─ README.md
116-
├─ requirements.txt
117-
├─ research_2.py
118-
└─ research.py
124+
└─ requirements.txt
119125
120126
```
121127
---
122128
## 💻 Installation & Usage
123129

124130
### 1️⃣ Clone the Repository
125131
```bash
126-
git clone https://github.com/ByteBard58/The_CosmoClassifier
127-
cd The_CosmoClassifier
132+
git clone https://github.com/ByteBard58/CosmoClassifier
133+
cd CosmoClassifier
128134
```
129135
### 2️⃣ Install Dependencies
130136
```bash
131137
pip install -r requirements.txt
132138
```
133139
### 3️⃣ Run the App
134140
```bash
135-
python app.py
141+
uvicorn app.app:app --reload
136142
```
137143

138144
### 4️⃣ Run Marimo Notebooks (Optional)
139145
To explore the research notebooks interactively:
140146
```bash
147+
cd notebooks/
141148
marimo edit research.py
142149
# OR
143150
marimo edit research_2.py
@@ -159,14 +166,14 @@ The image is built on both ARM64 and AMD64 architectures, so that it can run on
159166
2. Open Terminal and run:
160167
```bash
161168
docker pull bytebard101/cosmoclassifier:latest
162-
docker run --rm -p 5000:5000 bytebard101/cosmoclassifier:latest
169+
docker run --rm -p 8000:8000 bytebard101/cosmoclassifier:latest
163170
```
164171
3. If your machine faces a port conflict, you will need to assign another port. Try to run this:
165172
```bash
166-
docker run --rm -p 5001:5000 bytebard101/cosmoclassifier:latest
173+
docker run --rm -p 8001:8000 bytebard101/cosmoclassifier:latest
167174
```
168175
> If you followed Step 2 and the command ran successfully, then **DO NOT** follow this step.
169-
4. The app will be live at localhost:5000. Open your browser and navigate to [http://127.0.0.1:5000](http://127.0.0.1:5000/) (or [http://127.0.0.1:5001](http://127.0.0.1:5000/) if you followed Step 3).
176+
4. The app will be live at localhost:8000. Open your browser and navigate to [http://127.0.0.1:8000](http://127.0.0.1:8000/) (or [http://127.0.0.1:8001](http://127.0.0.1:8000/) if you followed Step 3).
170177

171178
Check [Docker Documentation](https://docs.docker.com/) to learn more about Docker and it's commands.
172179

app.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

app/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)