Skip to content

fix(losses): validate loss inputs and options before runs start - #617

Open
k-chrispens wants to merge 1 commit into
mainfrom
issue/552-20261105-1819-modal
Open

k-chrispens wants to merge 1 commit into
mainfrom
issue/552-20261105-1819-modal

Conversation

@k-chrispens

Copy link
Copy Markdown
Collaborator

Path typed loss options given on the command line or in a --loss-config file must name existing files, checked in loss_config_from_args so both sampleworks-guidance and run_grid_search.py refuse them before a model loads or jobs are queued. Loss weights must be finite, bragg_weight must be a finite number in [0, 1], and batch_partition a positive integer, all at option construction rather than when the loss is built.

Fixes #552

Path-valued loss options given on the command line or in a --loss-config file must name existing files, checked in loss_config_from_args so both sampleworks-guidance and run_grid_search.py refuse them before a model loads or jobs are queued. Loss weights must be finite, bragg_weight must be a finite number in [0, 1], and batch_partition a positive integer, all at option construction rather than when the loss is built.

Fixes #552
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 33fc318d-4fe2-4720-b34d-93dd7dfc2965
Commits

Reviewing files that changed from the base of the PR and between cc7d395 and 4ad2733.

Files selected for processing: 7

  • src/sampleworks/core/losses/config.py
  • src/sampleworks/core/losses/options.py
  • src/sampleworks/utils/guidance_script_arguments.py
  • tests/cli/test_guidance_cli.py
  • tests/losses/test_loss_config.py
  • tests/test_run_grid_search.py
  • tests/utils/test_guidance_script_arguments.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@k-chrispens
k-chrispens marked this pull request as ready for review November 16, 2026 01:07
Copilot AI balanced review requested due to automatic review settings November 16, 2026 01:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@marcuscollins marcuscollins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is okay but wanted to confirm that a None path should not be an error? The current code passes it, but I think that's okay because other code will fill in the value from a csv.

absent = {
name: str(entry.options[name])
for name in path_option_names(options_cls)
if entry.options.get(name) is not None and not Path(entry.options[name]).exists()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we raise an error if one of the path_option_names is None?


def __post_init__(self):
_check_resolution(self.resolution)
if type(self.batch_partition) is not int or self.batch_partition <= 0:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I favor the use of isinstance rather than booleans involving type()

This branch is waiting to be deployed

1 waiting deployment
gpu-testing — 4ad27331 Waiting Nov 16, 2026 by k-chrispens via protenix-dev #1212
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.

Validate all loss parameters early, before we create jobs

3 participants