Skip to content

fix: move the snapshot branch into get_depends - #143

Merged
traversaro merged 1 commit into
RoboStack:masterfrom
baszalmstra:fix/snapshot-depends
Sep 1, 2026
Merged

fix: move the snapshot branch into get_depends#143
traversaro merged 1 commit into
RoboStack:masterfrom
baszalmstra:fix/snapshot-depends

Conversation

@baszalmstra

Copy link
Copy Markdown
Collaborator

CI is red on master right now — all three test jobs fail on e10a578, so every open PR is red through no fault of its own.

pixi run lint-check is what fails:

F821 Undefined name `ignore_pkgs`  --> vinca/distro.py:186
F821 Undefined name `cache_key`    --> vinca/distro.py:187

#134 added a snapshot shortcut to _get_direct_depends, but the block reads ignore_pkgs and cache_key, and neither exists in that scope. They're locals of get_depends, which is where the block was clearly written for: it computes a full recursive closure via _get_snapshot_recursive_depends and stores it under self._depends_cache[cache_key], the recursive cache. _get_direct_depends returns direct dependencies and caches them per package in _direct_depends_cache.

So this isn't only a lint problem. Any snapshot-based distro would hit NameError as soon as it resolved a dependency, and ros-rolling runs with a snapshot. Moving the block into get_depends puts it back where its variables live and where the semantics match.

There were also 4 failing tests, all fixture problems that the lint failure was masking:

  • test_distro_dependencies.py builds Distro through Distro.__new__ and never sets snapshot, so the walk raised AttributeError as soon as it reached the snapshot check.
  • make_snapshot_distro and test_empty_snapshot_keeps_live_rosdistro_behavior set _depends_cache but not _direct_depends_cache.
  • test_empty_snapshot_keeps_live_rosdistro_behavior stubbed _walker.get_recursive_depends, but _get_direct_depends calls _walker.get_depends once per dependency type. The stub was never reached, so the mock leaked through as TypeError: 'Mock' object is not iterable. It now stubs the method the code actually calls, matching how test_distro_dependencies.py does it.

Testing

pixi run test goes from 4 failed / 146 passed to 150 passed, and pixi run lint-check passes.

I have not run the generator against a real snapshot distro, so I have not confirmed end to end that the snapshot dependency resolution produces the right packages — only that it no longer blows up and that the tests from #134 pass. Someone closer to that feature should sanity-check the intent, since I fixed this from the outside; it's possible the shortcut was meant to be a direct-dependency lookup feeding the existing walk instead, which would be a bigger change.

RoboStack#134 added the snapshot shortcut to _get_direct_depends, but it reads ignore_pkgs and cache_key, which only exist in the caller. ruff fails on master with two F821 errors and the code raises NameError for any snapshot distro.

The block was written for get_depends: it computes a recursive closure and caches under the recursive cache key. Move it there.

Also fix the fixtures that construct Distro via __new__ without the attributes the code reads, and mock the walker method _get_direct_depends actually calls.

@traversaro traversaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@traversaro
traversaro merged commit 7867578 into RoboStack:master Sep 1, 2026
3 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.

2 participants