Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env copy
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MODEL_REGISTRY = "local"
MODEL_REGISTRY = "local"
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches:
- 0-Starter-productionizing-ml
- main
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: code checkout
uses: actions/checkout@v4

- name: isntall Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install poetry
run: pip install poetry

- name: Install dependencies
run: poetry install

- name: launch Makefile
run: make lint-all
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.venv/
.python-version
.ipynb_checkpoints/
__pycache__/

# Data
data/
Expand All @@ -13,4 +14,9 @@ models/

# Env
.env
.envrc
.envrc

# MLflow
mlartifacts/
mlruns/
mlflow.db
1 change: 1 addition & 0 deletions .mlflow.pid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
78638
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.PHONY: lint lint-fix format lint-all

lint:
@echo "checking lint with ruff"
poetry run ruff check .

lint-fix:
@echo "auto fix lint with ruff"
poetry run ruff check . --fix

format:
@echo "checking format"
poetry run ruff format .

lint-all: lint-fix lint format

.PHONY: start-mlflow stop-mlflow
MLFLOW_PORT=5000
MLFLOW_PID_FILE=.mlflow.pid

start-mlflow:
mlflow ui --backend-store-uri sqlite:///models/mlflow.db -port $(MLFLOW_PORT) & echo $$! > $(MLFLOW_PID_FILE)

stop-mlflow:
@if [ -f $(MLFLOW_PID_FILE) ]; then \
kill `cat $(MLFLOW_PID_FILE)` && rm $(MLFLOW_PID_FILE); \
echo "MLflow server stopped"; \
else \
echo "No MLflow server running"; \
fi
18 changes: 18 additions & 0 deletions api/data_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pydantic import BaseModel

class Diamond(BaseModel):
carat: float
cut: str
color: str
clarity: str
depth: float
table: float
x: float
y: float
z: float

class DiamondResponse(Diamond):
price: float

class Diamonds(BaseModel):
diamonds: list[Diamond]
23 changes: 23 additions & 0 deletions api/rest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pandas as pd
from fastapi import FastAPI
from src.diamonds.registry import load_model
from .data_model import Diamond, DiamondResponse

app = FastAPI(
title="Diamond API",
description="api to get diamond price",
version="0.1.0"
)

model = load_model("model", "local")

@app.get("/")
def read_root():
return {"Hello": "World"}

@app.post("/price")
def predict_price(diamond: Diamond):
diamond_df = pd.Dataframe([diamond.model_dump()])
prediction = model.predict(diamond_df)
diamond_reponse = DiamondResponse(**diamond.model_dump(), price=prediction[0])
return diamond_reponse
2 changes: 2 additions & 0 deletions comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello, this is yufo
great jcc
Empty file removed data/preprocessed/.gitkeep
Empty file.
Empty file removed data/raw/.gitkeep
Empty file.
Empty file removed models/.gitkeep
Empty file.
Loading