Privacy-safe diagnostics, paths, and logging helpers for analytics projects.
get_logger()for consistent console and file logginglog_header()for a standardized run headerlog_path()for privacy-safe path logging- environment helpers:
detect_shell(),detect_os(),detect_python()
This toolkit is designed for reuse. It works the same locally and in GitHub Actions.
uv add datafun-toolkitpip install datafun-toolkitimport logging
from pathlib import Path
from datafun_toolkit.logger import get_logger, log_header, log_path
LOG: logging.Logger = get_logger("P01", level="DEBUG")
ROOT_PATH: Path = Path.cwd()
DATA_PATH: Path = ROOT_PATH / "data"
def main() -> None:
"""Start the main logic."""
log_header(LOG, "P01 Pipeline")
LOG.info("START main()")
log_path(LOG, "ROOT_PATH", ROOT_PATH)
log_path(LOG, "DATA_PATH", DATA_PATH)
LOG.info("Working....")
LOG.info("END main()")
if __name__ == "__main__":
main()Install tools:
- git
- uv
- VS Code
One-time setup:
uv self update
uv python pin 3.14
uv sync --extra dev --extra docs --upgrade
uvx pre-commit install
git add -A
uvx pre-commit run --all-filesBefore starting work:
git pullAfter working, run checks:
uv run ruff format .
uv run ruff check . --fix
uv run pytest --cov=src --cov-report=term-missing
uv run deptry .
uv run bandit -c pyproject.toml -r src
uv run validate-pyproject pyproject.tomlBuild and serve docs:
uv run zensical build
uv run zensical serveHit CTRL+c in the VS Code terminal to quit serving.
Save progress frequently (some tools may make changes; you may need to re-run git add and commit to ensure everything gets committed before pushing):
git add -A
git commit -m "update"
git push -u origin main