Skip to content

Fix PR #5 CI failures in GCS temp-file handling and watcher batch-mode tests#7

Merged
yhyatt merged 2 commits intomainfrom
copilot/fix-ci-merge-issues
Feb 25, 2026
Merged

Fix PR #5 CI failures in GCS temp-file handling and watcher batch-mode tests#7
yhyatt merged 2 commits intomainfrom
copilot/fix-ci-merge-issues

Conversation

Copy link

Copilot AI commented Feb 25, 2026

PR #5 failed CI due to lint violations and three watcher batch-mode test failures introduced by context-manager-based image opening. This updates the affected code/tests to align with current file-handling patterns and test expectations.

  • Lint-compliant temp file handling

    • Updated GCS blob download temp file creation to use a context manager in src/dmaf/gcs_watcher.py.
    • Eliminates SIM115 while keeping behavior unchanged.
  • GCS watcher test cleanup

    • Updated temp file creation in tests/test_gcs_watcher.py to use context manager semantics.
    • Adjusted local import ordering in the same test module to satisfy ruff import sorting.
  • Batch scan test compatibility with Image.open(...) context usage

    • Updated three failing batch-mode tests in tests/test_watcher.py to mock Image.open as a context manager:
      • test_delete_source_enabled_batch_mode
      • test_delete_source_disabled_batch_mode
      • test_delete_source_upload_failure_batch_mode
# before
mock_image_open.return_value = mock_img

# after
mock_image_open.return_value.__enter__.return_value = mock_img

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • photoslibrary.googleapis.com
    • Triggering command: /usr/bin/python python -m pytest tests/ -m not slow -v --cov=dmaf --cov-report=xml --cov-report=term --cov-fail-under=0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: yhyatt <10474956+yhyatt@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issues causing CI merge failure Fix PR #5 CI failures in GCS temp-file handling and watcher batch-mode tests Feb 25, 2026
Copilot AI requested a review from yhyatt February 25, 2026 12:46
@yhyatt yhyatt marked this pull request as ready for review February 25, 2026 12:57
Copilot AI review requested due to automatic review settings February 25, 2026 12:57
@yhyatt yhyatt merged commit 3793c2c into main Feb 25, 2026
4 of 6 checks passed
Copy link
Contributor

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 fixes CI failures from PR #5 by addressing lint violations and three batch-mode test failures related to context manager usage for image opening. The changes aim to make temporary file handling lint-compliant and update test mocks to match the actual code behavior where batch mode uses Image.open as a context manager.

Changes:

  • Updated GCS blob download to use context manager for temp file creation (lint compliance)
  • Fixed three batch-mode test mocks to support Image.open as a context manager
  • Adjusted import ordering in GCS watcher tests to satisfy ruff

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/dmaf/gcs_watcher.py Converted temp file creation to use context manager for SIM115 lint compliance
tests/test_gcs_watcher.py Updated temp file handling to use context manager and fixed import ordering
tests/test_watcher.py Fixed three batch-mode test mocks to configure Image.open as a context manager

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

Comment on lines +100 to 103
blob.download_to_filename(tmp.name)

logger.debug(f"Downloaded {gcs_path} -> {tmp.name}")
return Path(tmp.name)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The variable tmp is referenced outside its scope. After the context manager exits (line 100), tmp.name is accessed on line 102, but tmp is only defined within the with block. To fix this, capture tmp.name in a variable before the context exits, similar to the pattern used in tests/test_gcs_watcher.py lines 72-74.

Suggested change
blob.download_to_filename(tmp.name)
logger.debug(f"Downloaded {gcs_path} -> {tmp.name}")
return Path(tmp.name)
tmp_name = tmp.name
blob.download_to_filename(tmp_name)
logger.debug(f"Downloaded {gcs_path} -> {tmp_name}")
return Path(tmp_name)

Copilot uses AI. Check for mistakes.
yhyatt added a commit that referenced this pull request Feb 25, 2026
- Dockerfile: install dmaf[gcs] to include google-cloud-storage
  (required for GCS watch directory support added in PR #7)
- Firestore composite indexes created for error_events and
  borderline_events cleanup queries (eliminates WARNING logs)
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