Skip to content

Fix and improve gradient validation#415

Merged
rugeli merged 7 commits intomainfrom
fix/graident-validation
Oct 30, 2025
Merged

Fix and improve gradient validation#415
rugeli merged 7 commits intomainfrom
fix/graident-validation

Conversation

@rugeli
Copy link
Collaborator

@rugeli rugeli commented Oct 21, 2025

Problem

closes #414

Solution

  • fixed bug in validation schema for gradient mode
  • archived gradient_data.py and merged the code to pydantic validation

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Steps to Verify:

pack -r cellpack/tests/recipes/v2/test_combined_gradient.json

@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

Packing analysis report

Analysis for packing results located at cellpack/tests/outputs/test_spheres/spheresSST

Ingredient name Encapsulating radius Average number packed
ext_A 25 236.0

Packing image

Packing image

Distance analysis

Expected minimum distance: 50.00
Actual minimum distance: 50.01

Ingredient key Pairwise distance distribution
ext_A Distance distribution ext_A

Comment on lines -6 to -15
DEFAULT_GRADIENT_MODE_SETTINGS = {
"mode": "X",
"weight_mode": "linear",
"pick_mode": "linear",
"description": "Linear gradient in the X direction",
"reversed": False, # is the direction of the vector reversed?
"invert": None, # options: "weight", "distance"
"mode_settings": {},
"weight_mode_settings": {},
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moving the constant to recipe model to keep things centralized

weight_mode: Optional[WeightMode] = None
reversed: Optional[bool] = None
invert: Optional[bool] = None
invert: Optional[InvertOptions] = None
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed invert type to be string to match the settings in gradient_data.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

merging gradient constants, classes, and settings here from archived gradient_data.py

@rugeli
Copy link
Collaborator Author

rugeli commented Oct 21, 2025

@mogres Found a potential bug when running pack -r cellpack/tests/recipes/v2/test_combined_gradient.json. the progress bar shows as incomplete even though the packing ran through, likely a separate bug to fix.

2025-10-21 09:54:44 | root | INFO | pack:55 | pack() | Packing recipe: test_combined_gradient
2025-10-21 09:54:44 | root | INFO | pack:56 | pack() | Outputs will be saved to out/test_combined_gradient/spheresSST
Packing test_combined_gradient_1.0.0:  26%|████████████████████▊                                                          | 132/500 [00:00<00:01, 353.48it/s]
2025-10-21 09:54:46 | root | INFO | pack:101 | main() | Workflow completed in 2.0s`

@rugeli rugeli requested review from meganrm and mogres October 21, 2025 19:43
Copy link
Collaborator

@mogres mogres left a comment

Choose a reason for hiding this comment

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

Looks great!! Thanks for the quick fix!

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to still have this test for gradient data with the new validation schema, but that can be a separate PR.

Copy link
Collaborator

@mogres mogres left a comment

Choose a reason for hiding this comment

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

@mogres Found a potential bug when running pack -r cellpack/tests/recipes/v2/test_combined_gradient.json. the progress bar shows as incomplete even though the packing ran through, likely a separate bug to fix.

2025-10-21 09:54:44 | root | INFO | pack:55 | pack() | Packing recipe: test_combined_gradient
2025-10-21 09:54:44 | root | INFO | pack:56 | pack() | Outputs will be saved to out/test_combined_gradient/spheresSST
Packing test_combined_gradient_1.0.0:  26%|████████████████████▊                                                          | 132/500 [00:00<00:01, 353.48it/s]
2025-10-21 09:54:46 | root | INFO | pack:101 | main() | Workflow completed in 2.0s`

This probably happens because cellPACK is unable to pack all 500 spheres. We can log a warning if the actual number of packed objects is not equal to the request number as an indicator.

@mogres mogres self-requested a review October 21, 2025 21:33
Copy link
Collaborator

@mogres mogres left a comment

Choose a reason for hiding this comment

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

Packed some test gradient recipes and they worked as expected!

@rugeli rugeli merged commit 2e7be07 into main Oct 30, 2025
10 checks passed
@rugeli rugeli deleted the fix/graident-validation branch October 30, 2025 22:14
mogres added a commit that referenced this pull request Nov 7, 2025
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.

Recipe validation update for gradients

2 participants