Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 63 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
*.egg-info/
dist/
build/
*.egg

# Virtual environments
venv/
env/
ENV/

# IDE
.vscode/
.idea/
*.swp
*.swo

# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/

# Git
.git/
.gitignore
.gitattributes

# Documentation
docs/_build/
*.md

# Notebooks
notebooks/
*.ipynb

# Data and models (download or mount instead)
data/*.csv
data/*.json
models/*.pkl
models/*.joblib

# Logs
*.log
logs/

# OS
.DS_Store
Thumbs.db

# CI/CD
.github/
.gitlab-ci.yml

# Development files
tests/
docker-compose.yml
Makefile
53 changes: 53 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Application Configuration
APP_NAME=iris-classifier
APP_VERSION=2.0.0
ENVIRONMENT=production

# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
API_WORKERS=4
API_RELOAD=false

# Logging Configuration
LOG_LEVEL=INFO
LOG_FILE=logs/iris-classifier.log
LOG_MAX_BYTES=10485760
LOG_BACKUP_COUNT=5

# Model Configuration
DEFAULT_MODEL=random_forest
MODEL_CACHE_SIZE=5
MODEL_PATH=models/

# Security (Generate secure keys for production)
SECRET_KEY=your-secret-key-here-change-in-production
API_KEY_ENABLED=false
API_KEY=your-api-key-here

# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_CALLS=100
RATE_LIMIT_PERIOD=60

# CORS
CORS_ORIGINS=["http://localhost:3000", "http://localhost:8000"]
CORS_ALLOW_CREDENTIALS=true

# Monitoring
PROMETHEUS_ENABLED=true
METRICS_PORT=9090

# Database (optional - for logging predictions)
DATABASE_URL=sqlite:///./iris_predictions.db
DB_ENABLED=false

# Caching
CACHE_ENABLED=true
CACHE_TTL=3600
CACHE_TYPE=memory

# Feature Flags
BATCH_PREDICTION_ENABLED=true
MAX_BATCH_SIZE=1000
MODEL_EXPLAINABILITY_ENABLED=false
95 changes: 95 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov

- name: Run tests
run: |
pytest tests/ -v --cov=iris_classifier --cov-report=xml --cov-report=term-missing

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black

- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 src/iris_classifier --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 src/iris_classifier --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics

- name: Check formatting with black
run: |
black --check src/iris_classifier

package:
runs-on: ubuntu-latest
needs: [test, lint]

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package
run: |
python -m build

- name: Check package
run: |
twine check dist/*
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,10 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Project specific
models/*.pkl
models/*.joblib
data/*.csv
data/*.json
*.log
69 changes: 69 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
repos:
# General checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-json
- id: check-toml
- id: check-merge-conflict
- id: check-case-conflict
- id: detect-private-key
- id: debug-statements

# Python formatting with Black
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3.10
args: ['--line-length=100']

# Import sorting with isort
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: ['--profile=black', '--line-length=100']

# Linting with flake8
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--max-line-length=100', '--extend-ignore=E203,W503']
additional_dependencies: [flake8-docstrings]

# Security checks with bandit
- repo: https://github.com/PyCQA/bandit
rev: 1.7.6
hooks:
- id: bandit
args: ['-c', 'pyproject.toml']
additional_dependencies: ['bandit[toml]']

# Type checking with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [types-all]
args: ['--ignore-missing-imports', '--no-strict-optional']

# Docstring coverage
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
args: [--verbose, --fail-under=80, --ignore-init-module, --ignore-init-method]

# YAML formatting
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
Loading
Loading