-
Notifications
You must be signed in to change notification settings - Fork 0
Himanshu pathak2725 patch 1 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5fbd9c2
d47ab9b
86d1e83
5db2c25
4c06bd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| ARTIFACTS_DIR="ml/artifacts" | ||
| DATA_FILE="data/transactions.csv" | ||
|
|
||
| echo "[entrypoint] Fraud Radar API container starting..." | ||
|
|
||
| # Generate synthetic data if missing (idempotent — same seed every time) | ||
| if [ ! -f "$DATA_FILE" ]; then | ||
| echo "[entrypoint] Synthetic data not found at $DATA_FILE — generating..." | ||
| python -m data.generate_data | ||
| else | ||
| echo "[entrypoint] Using existing data: $DATA_FILE ($(wc -l < "$DATA_FILE" | tr -d ' ') rows)" | ||
| fi | ||
|
|
||
| # Train model if any artifact is missing — avoids retraining on every restart | ||
| if [ ! -f "$ARTIFACTS_DIR/isolation_forest.pkl" ] || \ | ||
| [ ! -f "$ARTIFACTS_DIR/scaler.pkl" ] || \ | ||
| [ ! -f "$ARTIFACTS_DIR/calibration.json" ]; then | ||
| echo "[entrypoint] Model artifacts missing — training Isolation Forest..." | ||
| python -m ml.train | ||
| else | ||
| echo "[entrypoint] Using existing model artifacts." | ||
| fi | ||
|
Comment on lines
+9
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 5 \
'joblib\.dump|calibration\.json|_load_artifacts|service_healthy' \
scripts/entrypoint.sh ml/train.py api/main.py docker-compose.ymlRepository: HimanshuPathak2725/Real_Time_Fraud_Detection_System Length of output: 5669 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- scripts/entrypoint.sh ---'
cat -n scripts/entrypoint.sh
printf '%s\n' '--- ml/train.py (artifact write path) ---'
sed -n '1,130p' ml/train.py
printf '%s\n' '--- api/scorer.py (artifact loading) ---'
sed -n '1,180p' api/scorer.py
printf '%s\n' '--- data generation and compose health configuration ---'
sed -n '1,180p' data/generate_data.py
sed -n '1,130p' docker-compose.yml
printf '%s\n' '--- references to DATA_FILE, artifact paths, and startup commands ---'
rg -n -C 3 'DATA_FILE|ARTIFACTS_DIR|isolation_forest\.pkl|scaler\.pkl|calibration\.json|healthcheck|entrypoint' --glob '!node_modules' .Repository: HimanshuPathak2725/Real_Time_Fraud_Detection_System Length of output: 22207 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- api/main.py health endpoint ---'
sed -n '20,90p' api/main.py
printf '%s\n' '--- Dockerfile and repository artifact/data state ---'
cat -n Dockerfile
printf 'Tracked data/artifact files:\n'
git ls-files data ml/artifacts
printf 'Working-tree data/artifact paths:\n'
find data ml/artifacts -maxdepth 1 -type f -printf '%p %s bytes\n' 2>/dev/null || true
printf '%s\n' '--- health response construction and artifact exception handling ---'
rg -n -C 5 'def health|JSONResponse|status_code|except RuntimeError|joblib\.load|json\.load' api
printf '%s\n' '--- read-only behavior probe for the startup predicates ---'
python3 - <<'PY'
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as d:
root = Path(d)
data = root / "transactions.csv"
artifacts = root / "artifacts"
artifacts.mkdir()
data.write_text("not,a,valid,training,dataset\n")
for name in ("isolation_forest.pkl", "scaler.pkl", "calibration.json"):
(artifacts / name).write_bytes(b"partial")
print("data_exists:", data.is_file())
print("artifact_exists:", {p.name: p.is_file() for p in artifacts.iterdir()})
print("entrypoint_would_generate_data:", not data.is_file())
print("entrypoint_would_train:", any(
not (artifacts / name).is_file()
for name in ("isolation_forest.pkl", "scaler.pkl", "calibration.json")
))
PYRepository: HimanshuPathak2725/Real_Time_Fraud_Detection_System Length of output: 6530 Validate generated data and model artifacts before reuse.
🤖 Prompt for AI AgentsSource: MCP tools |
||
|
|
||
| echo "[entrypoint] Starting API server on 0.0.0.0:8000..." | ||
| exec uvicorn api.main:app --host 0.0.0.0 --port 8000 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: HimanshuPathak2725/Real_Time_Fraud_Detection_System
Length of output: 2609
🏁 Script executed:
Repository: HimanshuPathak2725/Real_Time_Fraud_Detection_System
Length of output: 6057
🏁 Script executed:
Repository: HimanshuPathak2725/Real_Time_Fraud_Detection_System
Length of output: 340
🏁 Script executed:
Repository: HimanshuPathak2725/Real_Time_Fraud_Detection_System
Length of output: 373
🏁 Script executed:
Repository: HimanshuPathak2725/Real_Time_Fraud_Detection_System
Length of output: 490
Remove the restart policy or enable looping
kafka.producerpublishes the CSV once, then exits without--loop.restart: unless-stoppedrestarts it and republishes the rows as duplicate transactions. Add--loopfor continuous replay. Otherwise, removerestart: unless-stopped.🤖 Prompt for AI Agents
Source: MCP tools