Skip to content

fix: update pixi lockfile and address Marcus's docstring nits on previous PR (i had forgotten to add my commits before merging)#184

Merged
k-chrispens merged 6 commits intomainfrom
kmc/rf3-nits
Mar 24, 2026
Merged

fix: update pixi lockfile and address Marcus's docstring nits on previous PR (i had forgotten to add my commits before merging)#184
k-chrispens merged 6 commits intomainfrom
kmc/rf3-nits

Conversation

@k-chrispens
Copy link
Copy Markdown
Collaborator

@k-chrispens k-chrispens commented Mar 23, 2026

Summary by CodeRabbit

  • Documentation

    • Clarified RF3 configuration defaults and accepted msa_path formats (msa_path, ensemble size, recycling, chiral flags).
  • New Features

    • Added two RF3 CLI flags: --disable-chiral-features and --track-chiral-features.
  • Bug Fix / Behavior Change

    • Enabling chiral-feature tracking now raises an error if original chiral features are missing/empty instead of silently skipping; tracking behavior otherwise unchanged.
  • Chores

    • Tightened einx dependency constraint to <0.4.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

Moved chiral-gradient import to module scope, expanded RF3 docstrings, made RF3Wrapper.step() raise ValueError when chiral tracking is enabled but original chiral features are missing/empty, added two RF3 CLI flags and threaded them into guidance-config population, and tightened einx dependency to <0.4.

Changes

Cohort / File(s) Summary
RF3 wrapper
src/sampleworks/models/rf3/wrapper.py
Moved calc_chiral_grads_flat_impl import to module level; clarified RF3Config and annotate_structure_for_rf3() docstrings; when track_chiral_features is enabled and original chiral features are missing/empty, RF3Wrapper.step() now raises ValueError instead of silently skipping; added comment about L2-norm aggregation.
CLI: run_grid_search
run_grid_search.py
Added RF3-specific boolean CLI flags --disable-chiral-features and --track-chiral-features; reformatted some argument declarations; logging updated to emit the new flags when args.model == "rf3".
Guidance args mapping
src/sampleworks/utils/guidance_script_arguments.py
Populated RF3-specific config fields from argparse: reads disable_chiral_features and track_chiral_features (defaults to False) and stores them on the guidance config.
Project metadata
pyproject.toml
Tightened dependency constraint: changed einx to einx<0.4 in project dependencies.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as run_grid_search.py
  participant Config as GuidanceConfig
  participant RF3 as RF3Wrapper
  participant Loss as calc_chiral_grads_flat_impl

  User->>CLI: invoke with --model rf3 --track-chiral-features
  CLI->>Config: populate_config_for_guidance_type(args)
  Config->>RF3: pass config.track_chiral_features=True
  RF3->>RF3: featurize / prepare chiral tensors
  alt chiral features present
    RF3->>Loss: compute chiral gradients
    Loss-->>RF3: chiral gradients
    RF3->>RF3: aggregate L2 norms and continue
  else chiral features missing/empty
    RF3-->>Config: raise ValueError (tracking enabled but features absent)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • marcuscollins

Poem

🐰 I hopped through code with curious cheer,
I moved an import and hunted chiral gear,
If trackers ask and features hide,
I'll thump my foot and not let slide,
Little fixes, carrot near 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title references 'pixi lockfile' updates and 'docstring nits' but the actual changeset includes substantive logic changes to RF3 wrapper error handling, new CLI flags, and dependency constraints, making the title misleading and incomplete. Revise the title to accurately reflect the main changes: e.g., 'refactor: add RF3 chiral feature flags and improve error handling' or 'feat: add --disable-chiral-features and --track-chiral-features CLI flags'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kmc/rf3-nits

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates RF3 guidance configurability and documentation, mainly adding CLI/config plumbing for RF3 chiral feature toggles and clarifying docstrings in the RF3 wrapper.

Changes:

  • Pass RF3 chiral feature flags (disable_chiral_features, track_chiral_features) from grid search CLI into GuidanceConfig job configs.
  • Clarify RF3 wrapper docstrings for defaults and accepted MSA formats.
  • Refactor RF3 chiral tracking logic in RF3Wrapper.step() (and move calc_chiral_grads_flat_impl import to module scope).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/sampleworks/utils/guidance_script_arguments.py Propagates RF3 chiral feature flags from CLI args into per-job GuidanceConfig.
src/sampleworks/models/rf3/wrapper.py Docstring clarifications and refactor of chiral gradient tracking computation/guard.
run_grid_search.py Adds RF3-specific CLI flags and logs their values; feeds into GuidanceConfig.populate_config_for_guidance_type().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +558 to +568
if self._track_chiral_features:
if (
self._original_chiral_centers is not None
and self._original_chiral_dihedral_angles is not None
and self._original_chiral_centers.shape[0] > 0
):
raise ValueError(
"Chiral feature tracking is enabled, but original features are missing or empty"
". Cannot compute chiral gradients for tracking. This may be due to an upstream"
" change in RF3 or RF3Wrapper.featurize()."
)
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The guard for chiral feature tracking is inverted: the code currently raises when the original chiral features are present and non-empty, and then proceeds to compute chiral gradients when they are missing/empty. This will make track_chiral_features unusable (it will error on normal inputs, and may compute with None tensors otherwise). Flip the condition so the ValueError triggers only when required original features are missing (and decide whether an empty chiral_centers tensor should be treated as a skip vs. error).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
run_grid_search.py (1)

493-503: Add parse-time validation for incompatible RF3 chiral flags.

--disable-chiral-features and --track-chiral-features can currently be enabled together, which is a contradictory config and should fail fast in CLI parsing.

Suggested patch
@@
-    return parser.parse_args()
+    args = parser.parse_args()
+    if args.disable_chiral_features and args.track_chiral_features:
+        parser.error(
+            "--disable-chiral-features and --track-chiral-features are mutually exclusive."
+        )
+    return args
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@run_grid_search.py` around lines 493 - 503, The two RF3 chiral flags
(--disable-chiral-features and --track-chiral-features) are mutually exclusive
but currently allowed together; after creating the ArgumentParser (the parser
variable) and parsing arguments, add parse-time validation that checks if
args.disable_chiral_features and args.track_chiral_features are both true and
fail fast by calling parser.error(...) (or use a mutually_exclusive_group when
defining the options) so the CLI exits with a clear message; locate the parser
and the parse_args() call in run_grid_search.py to implement this check or
replace the two parser.add_argument(...) calls with a
parser.add_mutually_exclusive_group() and add both flags to that group.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@run_grid_search.py`:
- Around line 493-503: The two RF3 chiral flags (--disable-chiral-features and
--track-chiral-features) are mutually exclusive but currently allowed together;
after creating the ArgumentParser (the parser variable) and parsing arguments,
add parse-time validation that checks if args.disable_chiral_features and
args.track_chiral_features are both true and fail fast by calling
parser.error(...) (or use a mutually_exclusive_group when defining the options)
so the CLI exits with a clear message; locate the parser and the parse_args()
call in run_grid_search.py to implement this check or replace the two
parser.add_argument(...) calls with a parser.add_mutually_exclusive_group() and
add both flags to that group.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff79bd79-0d64-4d1d-ad87-1fbb21ac7b49

📥 Commits

Reviewing files that changed from the base of the PR and between 31b82e3 and 4530b42.

📒 Files selected for processing (3)
  • run_grid_search.py
  • src/sampleworks/models/rf3/wrapper.py
  • src/sampleworks/utils/guidance_script_arguments.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/sampleworks/models/rf3/wrapper.py

@k-chrispens k-chrispens changed the title chore: update pixi lockfile and address Marcus's docstring nits on previous PR (i had forgotten to add my commits before merging) fix: update pixi lockfile and address Marcus's docstring nits on previous PR (i had forgotten to add my commits before merging) Mar 24, 2026
@k-chrispens k-chrispens merged commit 728abf6 into main Mar 24, 2026
3 of 4 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.

3 participants