snakedeploy icon indicating copy to clipboard operation
snakedeploy copied to clipboard

fix: always update pins on `update-conda-envs --pin-envs`

Open tedil opened this issue 3 months ago • 1 comments

During update-conda-envs --pin-envs environment.yaml, if the environment.yaml has no changes (e.g. if completely unconstrained), the pins would never be touched, even though there will likely be newer versions that fulfill the implicit * constraints. This change now always tries updating the pins if --pin-envs is provided (which I'd say is the expected behaviour?)

Summary by CodeRabbit

  • Bug Fixes
    • Environment pinning now always runs when pinning is enabled, regardless of whether an update was attempted or succeeded, and regardless of existing pin files.
    • Ensures consistent creation and refresh of pin files after environment operations, reducing skipped pins and improving reproducibility across runs.
    • Removes prior behavior where pinning could be skipped based on update outcomes or pin file presence.

tedil avatar Oct 08 '25 13:10 tedil

📝 Walkthrough

Walkthrough

Simplifies conditional logic in snakedeploy/conda.py so that pinning is always attempted when pin_envs is true, independent of update_envs outcome or pin file existence, and within the same try block following any environment update.

Changes

Cohort / File(s) Summary
Conda env pinning control flow
snakedeploy/conda.py
Removed conditional checks tying pinning to update result and pin file presence; now always pins when pin_envs is true, executed after potential env update within the same try block.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant Conda as conda.py

  Caller->>Conda: run(envs, update_envs, pin_envs)
  rect rgba(220,235,255,0.5)
    note over Conda: Potential environment update
    alt update_envs == true
      Conda->>Conda: update environments
      opt update may fail
        Conda-->>Caller: raise/handle exception (per existing error handling)
      end
    else
      Conda->>Conda: skip update
    end
  end

  rect rgba(220,255,220,0.5)
    note over Conda: Pinning
    alt pin_envs == true
      Conda->>Conda: pin environments (always attempt)
    else
      Conda->>Conda: skip pin
    end
  end

  Conda-->>Caller: return/complete

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly identifies the primary change to always update pins when the --pin-envs flag is used, directly reflecting the pull request’s main objective and making the intent clear to reviewers.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch always-update-pins

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 08 '25 13:10 coderabbitai[bot]