Skip to content

Commit 4097572

Browse files
CopilotjustinchubyCopilot
authored
Fix affected-model scoping for concrete model file changes (#528)
The CI model-impact detection was over-scoping file changes, so a diff in one concrete model implementation could incorrectly trigger sibling models in the same import graph. That widened the test matrix and made the PR- and Windows-targeted CI behavior less precise than intended. - Scope - Model files are now treated as direct registrations first. - Only shared/base modules without a direct registry mapping continue through reverse-dependency tracing. - This keeps broad import-graph impact analysis for infra changes without cascading unrelated model types when a single model implementation changes. - Fix - In `scripts/detect_affected_models.py`, the model-file path handling now stops after adding the directly registered model types for that module. - Reverse-dependency expansion remains available for non-directly-registered modules such as shared base classes, preserving the existing dependency-based behavior where it is actually useful. - Why this matters - A change to `src/mobius/models/lfm2.py` no longer incorrectly includes `lfm2_vl` just because both share common imports or a base implementation. - The affected-model list stays aligned with the actual registry ownership of the file being changed, which is the right scope for CI targeting. ```python if module_name in registry_map: affected.update(registry_map[module_name]) continue ``` This narrows the detection to the actual model registration boundary while preserving import-graph tracing for shared infrastructure files. <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #527 --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: justinchuby <[email protected]> Co-authored-by: Justin Chu <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]>
1 parent ce1926f commit 4097572

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

‎scripts/detect_affected_models.py‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,30 @@ def detect_affected_models(
478478
if not module_name:
479479
continue
480480

481-
# Direct: this module's own registered types
481+
# A concrete model module should only scope to the model_types it
482+
# directly registers. Reverse-dependency expansion is intentionally
483+
# skipped here so a change in one model implementation does not
484+
# incorrectly cascade to sibling models that happen to import shared
485+
# helpers from it. Shared-base modules (e.g. ``models/base.py``) do
486+
# not map directly to registered model_types, so they still fall
487+
# through to the transitive scan below.
482488
if module_name in registry_map:
483489
affected.update(registry_map[module_name])
484490

485-
# Transitive: find modules that import from this model file
491+
# Also include directly registered model modules that import this one.
492+
# Some architectures are implemented as thin wrappers over another
493+
# model module (e.g. importing a base model class).
494+
direct_dependents = {
495+
mod for mod, deps in import_graph.items() if module_name in deps
496+
}
497+
for dep_module in direct_dependents:
498+
if dep_module in registry_map:
499+
affected.update(registry_map[dep_module])
500+
continue
501+
502+
# Transitive: find modules that import from this model file.
503+
# This is only used for infrastructure/shared-model modules without a
504+
# direct registration. Example: a base class file used by many models.
486505
dependents = _find_reverse_dependents(module_name, import_graph)
487506
for dep_module in dependents:
488507
if dep_module in registry_map:

0 commit comments

Comments
 (0)