Skip to content

feat!: Replace PyRes with Celery#104

Open
guilhermef wants to merge 10 commits intomasterfrom
replace-pyres-with-celery
Open

feat!: Replace PyRes with Celery#104
guilhermef wants to merge 10 commits intomasterfrom
replace-pyres-with-celery

Conversation

@guilhermef
Copy link
Copy Markdown
Member

Pyres was archived in 2023

@guilhermef guilhermef requested a review from marcelometal March 16, 2026 18:06
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 16, 2026

Pull Request Test Coverage Report for Build 23212210402

Details

  • 48 of 67 (71.64%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+12.5%) to 95.734%

Changes Missing Coverage Covered Lines Changed/Added Lines %
remotecv/celery_tasks.py 36 37 97.3%
remotecv/worker.py 11 29 37.93%
Totals Coverage Status
Change from base Build 23125008944: 12.5%
Covered Lines: 526
Relevant Lines: 545

💛 - Coveralls

@marcelometal
Copy link
Copy Markdown
Member

Hi @guilhermef

These files are libraries, not executable scripts, so the #!/usr/bin/python shebang isn’t needed and can be misleading.

Could you remove it?

@guilhermef
Copy link
Copy Markdown
Member Author

Thanks @marcelometal, it's removed.

Copy link
Copy Markdown

Copilot AI left a comment

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 migrates RemoteCV’s queue backend from the archived PyRes implementation to a Celery (SQS) based worker, removing the PyRes worker/unique-queue code path and updating the test suite accordingly.

Changes:

  • Remove PyRes worker + UniqueQueue/UniqueWorker implementation and associated tests.
  • Add Celery-based task runner with Redis-backed de-dupe keys, and update worker CLI/startup to always run Celery.
  • Refresh/extend tests around worker startup, Celery task behavior, and various supporting utilities/stores.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_worker.py Updates CLI startup tests to expect Celery-only behavior; adds start_celery_worker() unit test.
tests/test_unique_queue.py Removes PyRes unique-queue tests (file deleted).
tests/test_tasks.py Switches task import to remotecv.tasks.DetectTask.
tests/test_result_store.py Removes shebang line.
tests/test_redis_storage.py Removes shebang line.
tests/test_redis.py Makes Redis client assertions less string-representation dependent; adds metrics mock setup.
tests/test_profile_detector.py Removes shebang line.
tests/test_memcache_store.py Adds tests for memcache result store initialization/caching and storing behavior.
tests/test_logger_metrics.py Adds smoke tests for logger-based metrics backend.
tests/test_init.py Adds test for __version__ fallback when package metadata is unavailable.
tests/test_images.py Adds tests for image-load error handling and metadata clearing edge cases.
tests/test_http_loader.py Adds tests for synchronous HTTP loader behavior + metrics emission.
tests/test_healthcheck_handler.py Removes shebang line.
tests/test_glasses_detector.py Removes shebang line.
tests/test_feature_detector.py Removes shebang; adds test for empty-corners array behavior.
tests/test_face_detector.py Removes shebang line.
tests/test_error_handler.py Adds tests for Sentry initialization and excepthook installation/handling.
tests/test_complete_detector.py Removes shebang line.
tests/test_celery_tasks.py Adds tests for CeleryTasks enqueueing, de-dupe keys, TTL behavior, and task execution cleanup.
remotecv/worker.py Removes PyRes backend option/path; makes worker always start Celery; adds Redis key TTL CLI option.
remotecv/utils.py Removes shebang line.
remotecv/unique_queue.py Removes PyRes-backed unique queue/worker implementation (file deleted).
remotecv/tasks.py Renames metrics from pyres_task.* to generic task.*.
remotecv/storages/redis_storage.py Removes shebang line.
remotecv/image_processor.py Removes shebang line.
remotecv/detectors/profile_detector/init.py Removes shebang line.
remotecv/detectors/glasses_detector/init.py Removes shebang line.
remotecv/detectors/feature_detector/init.py Removes shebang line.
remotecv/detectors/init.py Removes shebang line.
remotecv/celery_tasks.py Introduces CeleryTasks + Redis-backed de-dupe key management and enqueue API.
pyproject.toml Major version bump and dependency updates (Celery promoted to core dependency; removes PyRes).

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

You can also share your feedback on Copilot code review. Take the survey.

start_pyres_worker()
elif params["backend"] == "celery":
start_celery_worker()
start_celery_worker()
from remotecv.utils import SENTINEL, SINGLE_NODE, config, context


def start_celery_worker():
logger.debug("key %s already enqueued", key)
return
self.get_detect_task().apply_async(
args=[detection_type, image_path, key]
Comment on lines +56 to +60
pil_img = mock.MagicMock(spec=PilImage.Image)
# spec=PilImage.Image means hasattr checks use the real class attrs;
# delete them on the instance to exercise the False branches
del pil_img.tag
del pil_img.tag_v2
guilhermef and others added 3 commits March 17, 2026 21:26
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

4 participants