Skip to content

[facade] fix: run dependency tasks after repo clone, not in parallel#431

Open
MoralCode wants to merge 2 commits into
mainfrom
mn-ram/fix/facade-dependency-race-condition
Open

[facade] fix: run dependency tasks after repo clone, not in parallel#431
MoralCode wants to merge 2 commits into
mainfrom
mn-ram/fix/facade-dependency-race-condition

Conversation

@MoralCode

Copy link
Copy Markdown
Contributor

Ported from augurlabs/augur#3794, originally filed by @mn-ram

Description

  • Moved process_dependency_metrics, process_libyear_dependency_metrics, and process_scc_value_metrics out of Celery group() and into the main facade_core_collection chain so they execute strictly after the git clone/update completes.
  • Removed the now-unused group import from celery.

This PR fixes #247 (also resolves #247 — same root cause)

Notes for Reviewers

group() dispatches all members simultaneously, so dependency tasks were racing against the git clone and hitting FileNotFoundError on directories that didn't exist yet. Using a single chain() guarantees ordering with no extra overhead.

Signed commits

  • Yes, I signed my commits.

mn-ram added 2 commits June 27, 2026 16:10
Dependency metrics tasks (process_dependency_metrics,
process_libyear_dependency_metrics, process_scc_value_metrics) were
placed inside a Celery group() alongside the facade core collection
chain, causing them to fire concurrently with the git clone/update.
This resulted in a FileNotFoundError when the tasks tried to scan
directories that hadn't been written to disk yet.

Fix: append the three tasks to facade_core_collection and use a single
chain() so they execute strictly after the clone completes.

Fixes #3767

Signed-off-by: mn-ram <mn-ram@users.noreply.github.com>
Adds two unit tests for facade_phase() to guard against the race
condition fixed in the previous commit (issue #3767):

1. test_facade_phase_returns_chain - verifies the returned sequence is
   not a Celery group(), which would dispatch tasks in parallel.
2. test_facade_phase_dependency_tasks_follow_clone - verifies that
   process_dependency_metrics, process_libyear_dependency_metrics, and
   process_scc_value_metrics appear strictly after the git clone task
   in the chain, not before or alongside it.

All Augur/DB dependencies are stubbed so no live environment is needed.

Signed-off-by: mn-ram <mn-ram@users.noreply.github.com>
# Tests
# ---------------------------------------------------------------------------

def test_facade_phase_returns_chain(mock_facade_helper):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_facade_helper' from outer scope (line 157) (redefined-outer-name)

assert hasattr(result, "tasks"), "result should be a sequential chain with .tasks"


def test_facade_phase_dependency_tasks_follow_clone(mock_facade_helper):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_facade_helper' from outer scope (line 157) (redefined-outer-name)


facade_phase = _facade_tasks_mod.facade_phase

from celery import chain, signature # noqa: E402

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0611: Unused chain imported from celery (unused-import)

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.

process_dependency_metrics file not found - Facade race condition

2 participants