Privacy-safe diagnostics, paths, and logging helpers for analytics projects.
find_project_root()andsafe_relpath_str()for robust, repo-relative pathsget_logger()for consistent console and file logging (using a standard logging API)log_header()for a privacy-safe logging header (shows OS, shell, Python version, repo-relative cwd)
This toolkit is designed for reuse. It works the same locally and in GitHub Actions.
uv add datafun-toolkitpip install datafun-toolkitfrom datafun_toolkit import find_project_root, get_logger, log_header, safe_relpath_str
from pathlib import Path
def main() -> None:
logger = get_logger("example")
log_header(logger, "example")
root = find_project_root()
logger.info(f"project_root={root.name}")
logger.info(f"cwd={safe_relpath_str(Path.cwd(), root)}")
if __name__ == "__main__":
main()Tools:
- git
- uv
- VS Code
One-time setup:
uv self update
uv python pin 3.12
uv sync --extra dev --extra docs --upgradeBefore starting work:
git pullAfter working, run checks:
git add .
uv run ruff check .
uv run ruff format .
uv run deptry .
uv run pyright
uv run pytest
uv run bandit -c pyproject.toml -r src
uv run pre-commit run --all-files
git add .Build and serve docs:
uv run mkdocs build --strict
uv run mkdocs serve