Skip to content

Add graceful fallback for loguru, export version, and log zamba version at runtime#401

Open
intagliated wants to merge 2 commits into
drivendataorg:masterfrom
intagliated:fix/loguru-fallback
Open

Add graceful fallback for loguru, export version, and log zamba version at runtime#401
intagliated wants to merge 2 commits into
drivendataorg:masterfrom
intagliated:fix/loguru-fallback

Conversation

@intagliated
Copy link
Copy Markdown

Changes

File Change
zamba/__init__.py Wrapped the loguru import with a try/except, falling back to the standard logging module. Configured the logger for both paths, exported __version__, and added documentation comments.
zamba/images/manager.py Inserted logger.info(f"Running zamba version {__version__}") at the start of the predict and train functions.
zamba/models/model_manager.py Added the same version‑logging line at the start of train_model and predict_model.
pyproject.toml Added "loguru" to the tests optional‑dependency list and updated formatting to keep the file PEP‑518‑compliant.
loguru/__init__.py (temporary stub) Minimal implementation that creates a logger compatible with the tiny subset of the loguru API used in the project. This file can be removed after the real loguru package is installed via the new test dependency.

How to Verify

  1. Install the package with test dependencies

    # From the repository root
    pip install -e ".[dev,tests]"

    The tests optional‑dependency group now includes loguru, so the real library will be installed automatically.

  2. Run the test suite

    pytest -q

    Expected outcome: All tests pass without raising ModuleNotFoundError: No module named 'loguru'.

  3. Check that the version is logged

    Execute a short training or prediction command (replace the placeholder arguments with valid values for your data).

    # Example: image training
    python -c "from zamba.images.manager import train; train(...)"

    or

    # Example: video prediction
    python -c "from zamba.models.model_manager import predict_model; predict_model(...)"

    Look for a line similar to:

    INFO | __main__ | Running zamba version 2.6.1
    

    The version string should match the value defined in zamba/version.py.

  4. Verify the public version API

    python - <<'PY'
    import zamba
    print("Zamba version:", zamba.__version__)  # Should print 2.6.1 (or current version)
    PY

    No import errors should occur, and the printed version should match the package metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant