Skip to content

fix: explicit motile submodule imports for motile ≥1.0.1 - #68

Merged
bentaculum merged 1 commit into
weigertlab:mainfrom
bentaculum:fix/motile-constraints-compat
Aug 4, 2026
Merged

bentaculum merged 1 commit into
weigertlab:mainfrom
bentaculum:fix/motile-constraints-compat

Conversation

@bentaculum

Copy link
Copy Markdown
Member

Summary

  • Adds explicit import motile.constraints, import motile.costs, and import motile.variables in trackastra/tracking/ilp.py
  • Fixes AttributeError: module 'motile' has no attribute 'constraints' that started occurring after motile 1.0.1 was released on 2026-07-21

Root cause

motile 1.0.1 moved the from .constraints.constraint import Constraint import in its solver.py behind if TYPE_CHECKING: (+ from __future__ import annotations). In 1.0.0, that top-level import caused Python to register motile.constraints in sys.modules as a side effect of import motile, making motile.constraints.MaxParents etc. work. In 1.0.1, the subpackage is never imported at runtime, so motile.constraints raises AttributeError.

The same could happen to motile.costs and motile.variables in a future release, so all three are now imported explicitly.

Test plan

  • CI should pass with both motile 1.0.0 and 1.0.1 — the explicit imports are valid in both versions
  • ruff check passes on the changed file

motile 1.0.1 moved the `from .constraints.constraint import Constraint`
import in solver.py behind `TYPE_CHECKING`, so `import motile` alone no
longer registers `motile.constraints` in sys.modules at runtime.

Adding explicit `import motile.constraints` (and the same for
`motile.costs` and `motile.variables` to be future-proof) fixes:

    AttributeError: module 'motile' has no attribute 'constraints'

which broke the `test_empty_window_ilp` test on CI after motile 1.0.1
was released on 2026-07-21.
@bentaculum
bentaculum marked this pull request as ready for review August 4, 2026 11:42
@bentaculum
bentaculum merged commit 9c1e44f into weigertlab:main Aug 4, 2026
10 checks passed
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.

1 participant