[PR #2969] [MERGED] chore(ml): added testing and github workflow #9798

Closed
opened 2026-02-05 14:10:57 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/2969
Author: @mertalev
Created: 6/26/2023
Status: Merged
Merged: 6/28/2023
Merged by: @alextran1502

Base: mainHead: ml-testing


📝 Commits (10+)

📊 Changes

12 files changed (+622 additions, -95 deletions)

View changed files

📝 .github/workflows/test.yml (+30 -0)
📝 machine-learning/app/config.py (+1 -0)
machine-learning/app/conftest.py (+119 -0)
📝 machine-learning/app/main.py (+12 -8)
📝 machine-learning/app/models/base.py (+6 -18)
📝 machine-learning/app/models/cache.py (+20 -11)
📝 machine-learning/app/models/facial_recognition.py (+2 -2)
📝 machine-learning/app/models/image_classification.py (+5 -11)
📝 machine-learning/app/schemas.py (+1 -4)
machine-learning/app/test_main.py (+183 -0)
📝 machine-learning/poetry.lock (+213 -36)
📝 machine-learning/pyproject.toml (+30 -5)

📄 Description

Description

This PR adds pytest unit tests to the ML package. Given the expanding scope of ML, it's important to ensure a certain set of behaviors across changes. The tests included here aren't exhaustive and should be built upon in the future, but they're a good starting point.

Further, formatting, linting and testing are all automatically checked through GHA to ensure consistency across contributions.

Testing

To test locally, you can follow these steps:

  1. cd machine-learning
  2. poetry install --with dev
  3. pytest --cov

To test in a container, you must copy or map the machine-learning folder, not just app. You can then SSH into the container and run pytest --cov.

Note that models are mocked in most tests to avoid downloading and loading them. The exceptions are the endpoint tests, which are skipped by default. Setting MACHINE_LEARNING_TEST_FULL will run these tests as well.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/2969 **Author:** [@mertalev](https://github.com/mertalev) **Created:** 6/26/2023 **Status:** ✅ Merged **Merged:** 6/28/2023 **Merged by:** [@alextran1502](https://github.com/alextran1502) **Base:** `main` ← **Head:** `ml-testing` --- ### 📝 Commits (10+) - [`d6bd467`](https://github.com/immich-app/immich/commit/d6bd467c7e20e18ac8650262e35712b85c40390b) added testing - [`fa9e86e`](https://github.com/immich-app/immich/commit/fa9e86ec77fad50712c4c96f0b162c340a53a3da) github action for python, made mypy happy - [`26a368d`](https://github.com/immich-app/immich/commit/26a368dee6e30004abdc082a30e30534f836dc63) formatted with black - [`dde872e`](https://github.com/immich-app/immich/commit/dde872ed190009718849bcc7bc615ddf641f6cfc) minor fixes and styling - [`a0faa20`](https://github.com/immich-app/immich/commit/a0faa20bcf832aec7720d250ca9e73a574f3f8aa) test model cache - [`a52f9d5`](https://github.com/immich-app/immich/commit/a52f9d56ee349115148da928d938d274c9b5bba8) cache test dependencies - [`238447d`](https://github.com/immich-app/immich/commit/238447d8f784103fa53757c331126667e023c268) narrowed model cache tests - [`af170fe`](https://github.com/immich-app/immich/commit/af170fe70903048c85ba860bd25531b9f4358652) moved endpoint tests to their own class - [`30dea90`](https://github.com/immich-app/immich/commit/30dea907eb29d0f673eb831a9f0d5385be66a492) cleaned up fixtures - [`c6cee6f`](https://github.com/immich-app/immich/commit/c6cee6fdf7a78fac26b68c84016e7e3ba52d1212) formatting ### 📊 Changes **12 files changed** (+622 additions, -95 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/test.yml` (+30 -0) 📝 `machine-learning/app/config.py` (+1 -0) ➕ `machine-learning/app/conftest.py` (+119 -0) 📝 `machine-learning/app/main.py` (+12 -8) 📝 `machine-learning/app/models/base.py` (+6 -18) 📝 `machine-learning/app/models/cache.py` (+20 -11) 📝 `machine-learning/app/models/facial_recognition.py` (+2 -2) 📝 `machine-learning/app/models/image_classification.py` (+5 -11) 📝 `machine-learning/app/schemas.py` (+1 -4) ➕ `machine-learning/app/test_main.py` (+183 -0) 📝 `machine-learning/poetry.lock` (+213 -36) 📝 `machine-learning/pyproject.toml` (+30 -5) </details> ### 📄 Description ## Description This PR adds `pytest` unit tests to the ML package. Given the expanding scope of ML, it's important to ensure a certain set of behaviors across changes. The tests included here aren't exhaustive and should be built upon in the future, but they're a good starting point. Further, formatting, linting and testing are all automatically checked through GHA to ensure consistency across contributions. ## Testing To test locally, you can follow these steps: 1. `cd machine-learning` 2. `poetry install --with dev` 3. `pytest --cov` To test in a container, you must copy or map the `machine-learning` folder, not just `app`. You can then SSH into the container and run `pytest --cov`. Note that models are mocked in most tests to avoid downloading and loading them. The exceptions are the endpoint tests, which are skipped by default. Setting `MACHINE_LEARNING_TEST_FULL` will run these tests as well. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 14:10:57 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#9798