Skip to content

Update #2

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

Merged
merged 13 commits into from
Jun 9, 2025
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
3 changes: 3 additions & 0 deletions .dvcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add patterns of files dvc should ignore, which could improve
# the performance. Learn more at
# https://dvc.org/doc/user-guide/dvcignore
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

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

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: make install

- name: Run code quality checks (Linting, Formatting Check, Type Check, Pre-commit hooks)
run: make check-all

- name: Run tests with coverage
run: make test-cov
57 changes: 31 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
# folders

## IDEs
.idea/
.vscode/

## Cache
__pycache__
.ipynb_checkpoints

## Project
experiments/*
models/*


# files

## Mac OS
.DS_Store

## Configs
.env
config/*.json

.venv/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.classdvc get https://github.com/iterative/dataset-registry \
use-cases/cats-dogs

*$py.class

# C extensions
*.so
Expand Down Expand Up @@ -121,6 +98,12 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock

# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
Expand All @@ -133,8 +116,10 @@ ipython_config.py
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
Expand Down Expand Up @@ -185,3 +170,23 @@ 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/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the enitre vscode folder
# .vscode/

# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc

# Cursor
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore
63 changes: 63 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Pre-commit hooks to ensure code quality before commits
# Install: uv run pre-commit install
# Run manually: uv run pre-commit run --all-files

repos:
# Basic file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
args: ['--maxkb=2048'] # Allow up to 2MB files
- id: check-merge-conflict
- id: check-case-conflict
- id: debug-statements
exclude: ^tests/ # Allow debug statements in tests

# Python code formatting and linting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.11
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]

# Type checking (with relaxed settings for MLOps course)
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
hooks:
- id: mypy
args: [
--config-file=pyproject.toml,
--explicit-package-bases,
--namespace-packages
]
additional_dependencies: [
pandas-stubs>=2.0.0,
types-PyYAML>=6.0.0,
types-requests>=2.31.0,
]
exclude: ^tests/ # Skip type checking for tests initially

# Security scanning
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: ^(\.venv/|\.git/|htmlcov/|\.pytest_cache/|.*\.dvc$)

# Additional Python checks
- repo: https://github.com/pycqa/bandit
rev: 1.8.3
hooks:
- id: bandit
args: [--quiet]
files: ^src/.*\.py$
exclude: ^tests/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.6
127 changes: 127 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"version": "1.5.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
},
{
"name": "AWSKeyDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"name": "Base64HighEntropyString",
"limit": 4.5
},
{
"name": "BasicAuthDetector"
},
{
"name": "CloudantDetector"
},
{
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "GitLabTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
},
{
"name": "IbmCloudIamDetector"
},
{
"name": "IbmCosHmacDetector"
},
{
"name": "IPPublicDetector"
},
{
"name": "JwtTokenDetector"
},
{
"name": "KeywordDetector",
"keyword_exclude": ""
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "OpenAIDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "PypiTokenDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TelegramBotTokenDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"filters_used": [
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
},
{
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
},
{
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
},
{
"path": "detect_secrets.filters.heuristic.is_lock_file"
},
{
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
},
{
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
},
{
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
},
{
"path": "detect_secrets.filters.heuristic.is_sequential_string"
},
{
"path": "detect_secrets.filters.heuristic.is_swagger_file"
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
}
],
"results": {},
"generated_at": "2025-05-29T13:17:00Z"
}
67 changes: 67 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.PHONY: help install test lint format clean run-pipeline tutorial-setup tutorial-clean tutorial-init tutorial-file tutorial-directory tutorial-changes tutorial-versions tutorial-remotes tutorial-advanced tutorial-pipelines tutorial-full tutorial-reset

help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

setup-hooks: ## Install pre-commit hooks
uv run pre-commit install
@echo "Pre-commit hooks installed!

install: ## Install dependencies
uv sync --group dev
uv run pre-commit install

pre-commit: ## Run pre-commit on all files
uv run pre-commit run --all-files

autofix: lint-fix format ## Automatically fix linting issues and then format code
@echo "Code auto-fixing and formatting complete."

type-check: ## Run mypy type checking separately
uv run mypy src/ --config-file=pyproject.toml

check-all: lint format-check type-check test pre-commit ## Run all checks (lint + test)
@echo "All checks complete."


tutorial-clean: ## Clean up all DVC-related files and data (reset to initial state)
@echo "🧹 Cleaning up DVC tutorial state..."
@# Remove DVC directory and config
rm -rf .dvc/
@# Remove all .dvc files
find . -name "*.dvc" -type f -delete
@# Remove data directories and files created during tutorial
rm -rf data/
rm -rf datadir/
rm -rf cats-dogs-untracked/
rm -rf imported_data.xml* external_data.xml*
@# Remove pipeline files
rm -rf dvc.yaml dvc.lock
rm -rf model.weights.h5 metrics.csv
@# Remove temporary remote storage
rm -rf /tmp/dvc_remote_storage
@# Clean git index of any staged DVC files
-git reset HEAD *.dvc .dvc/ dvc.yaml 2>/dev/null || true
@# Remove any DVC-related entries from .gitignore that might have been added
@if [ -f .gitignore ]; then \
grep -v "^/data" .gitignore > .gitignore.tmp && mv .gitignore.tmp .gitignore || true; \
grep -v "^/datadir" .gitignore > .gitignore.tmp && mv .gitignore.tmp .gitignore || true; \
fi
@# Remove Git branches created during tutorial
@echo "Switching to a safe branch before cleanup..."
@if git show-ref --verify --quiet refs/heads/main; then \
git checkout main; \
elif git show-ref --verify --quiet refs/heads/master; then \
git checkout master; \
else \
git checkout -b cleanup-temp; \
fi
@echo "Removing tutorial branches..."
@for branch in cats-dogs-v1 cats-dogs-v2 tutorial cleanup-temp; do \
if git show-ref --verify --quiet refs/heads/$$branch && [ "$$branch" != "$$(git branch --show-current)" ]; then \
echo "Deleting branch $$branch"; \
git branch -D $$branch 2>/dev/null || true; \
fi; \
done
@echo "✅ DVC tutorial cleanup complete! Repository reset to initial state."
Loading
Loading