Skip to content

fix: Image utils optional dependency errors and unblock unit tests on minimal env - #5808

Open
Shizoqua wants to merge 13 commits into
feast-dev:masterfrom
Shizoqua:bugfix/contrib-quickfix
Open

Shizoqua wants to merge 13 commits into
feast-dev:masterfrom
Shizoqua:bugfix/contrib-quickfix

Conversation

@Shizoqua

@Shizoqua Shizoqua commented Jan 2, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it:

Without the image extras, feast.image_utils.validate_image_format() returned False for any input, and get_image_metadata() raised ValueError: Failed to extract image metadata: name 'Image' is not defined. Neither told the user that a dependency was missing. ImageFeatureExtractor already checks this and raises a clear ImportError.

This PR:

  • calls _check_image_dependencies() in validate_image_format() and get_image_metadata(), so both raise the same ImportError when the image dependencies are not installed (sdk/python/feast/image_utils.py)
  • adds sdk/python/tests/unit/test_image_utils_optional_deps.py, which covers both functions
  • uses pytest.importorskip for PIL in sdk/python/tests/unit/test_image_utils.py and for torch in sdk/python/tests/unit/test_rag_retriever.py. Both modules imported these at the top, so collecting the unit tests without the image extras failed with ModuleNotFoundError. They are now skipped instead.

Master already makes the integration test dependencies optional during collection (#5779), so this PR no longer changes conftest.py, pytest.ini or the test utilities.

Which issue(s) this PR fixes:

No linked issue.

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Commands run:

  • make test-python-unit: 4741 passed, 60 skipped
  • pytest sdk/python/tests/unit/test_image_utils_optional_deps.py: fails on master, passes here, both with all dependencies and without the image extras
  • pytest --collect-only sdk/python/tests/unit without torch, torchvision, timm, Pillow and scikit-learn: master collects 4773 with 2 errors, this branch collects 4775 with no errors
  • pytest --collect-only sdk/python/tests/unit with all dependencies: master 4799, this branch 4801 (the 2 new tests)
  • Manual: with the image extras missing, validate_image_format(b"x") and get_image_metadata(b"x") both raise ImportError: Image processing dependencies are not installed...
  • ruff check, ruff format --check and mypy feast/image_utils.py: clean

Misc

Without torch installed, three unit tests still fail at run time, on master and on this branch: test_online_retrieval.py::test_get_online_features and two to_tensor tests in test_online_response.py. They are not related to image utils, so I left them out of this PR.

@Shizoqua
Shizoqua requested a review from a team as a code owner January 2, 2026 23:17
@Shizoqua
Shizoqua force-pushed the bugfix/contrib-quickfix branch from 017a91a to fc9bb71 Compare January 2, 2026 23:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes error handling in feast.image_utils when optional image dependencies are missing and enables unit tests to run in minimal environments without integration dependencies.

  • Adds _check_image_dependencies() calls to validate_image_format and get_image_metadata to raise clear ImportError when image dependencies are missing
  • Adds unit tests to verify optional dependency handling
  • Updates test infrastructure to support running unit tests without optional integration/auth dependencies

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
sdk/python/feast/image_utils.py Added dependency checks to image validation and metadata extraction functions
sdk/python/tests/unit/test_image_utils_optional_deps.py New unit tests verifying ImportError behavior when image dependencies are unavailable
sdk/python/tests/conftest.py Wrapped integration and auth test imports in try-except blocks to allow conftest loading without optional dependencies; fixed Windows platform detection
sdk/python/pytest.ini Removed deprecated pytest configuration for pytest 8 compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/python/tests/conftest.py Resolved
Comment thread sdk/python/tests/conftest.py Resolved
@Shizoqua
Shizoqua force-pushed the bugfix/contrib-quickfix branch 2 times, most recently from 35db3ae to d8fd430 Compare January 9, 2026 02:03
Comment thread sdk/python/pytest.ini Resolved
Shizoqua and others added 5 commits January 10, 2026 05:06
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
…s.py

Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
@Shizoqua

Copy link
Copy Markdown
Author

Good day @franciscojavierarceo
I would appreciate it if my PR is looked at and reviewed.

@Shizoqua

Copy link
Copy Markdown
Author

Good day @franciscojavierarceo
I would appreciate it if my PR is reviewed.

@Shizoqua

Copy link
Copy Markdown
Author

Hello,
Good day @franciscojavierarceo
Just a quick reminder of my PR getting reviewed.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View issue and 6 additional flags in Devin Review.

Open in Devin Review

Comment thread sdk/python/tests/conftest.py Resolved
Signed-off-by: Shizoqua <hr.lanreshittu@yahoo.com>
@Shizoqua
Shizoqua force-pushed the bugfix/contrib-quickfix branch from 5c29c83 to 5cb5c2e Compare January 30, 2026 11:42
@Shizoqua

Copy link
Copy Markdown
Author

Hello,
Good day @franciscojavierarceo
Just a quick reminder of checking out my PR.

Resolve the conflicts in sdk/python/pytest.ini, sdk/python/tests/conftest.py
and sdk/python/tests/utils/cli_repo_creator.py by taking master's version.
Master already makes the integration test dependencies optional during
collection (feast-dev#5779) and keeps IS_TEST=True through pytest-env, so the
earlier changes to these files are no longer needed.

Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
The extra assertion messages and Path wrapping in default_store are not
related to the image utils fix, so keep this PR to its purpose.

Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
…are missing

test_image_utils.py imported PIL before its importorskip checks, and
test_rag_retriever.py imported torch directly, so collecting the unit
tests without the image extras failed with ModuleNotFoundError and
pytest exited with an error. Use pytest.importorskip for both so these
modules are skipped instead.

Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
@Shizoqua

Shizoqua commented Dec 5, 2026

Copy link
Copy Markdown
Author

I merged current master and narrowed this PR. Master already handles the integration test dependencies (#5779), so I dropped my conftest.py, pytest.ini and test utility changes. It now only makes the image utils raise a clear ImportError when the image extras are missing, and skips the image and RAG unit tests when PIL or torch is not installed. Unit tests pass locally. Could a maintainer review this when there is time, and add the ok-to-test label so CI can run? Thanks.

This branch has not been deployed

No deployments
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.

3 participants