Conversation
d894a7c to
a9cda3b
Compare
ascibisz
left a comment
There was a problem hiding this comment.
I really like the code change moving the validation to recipe_loader! I tested it out and it works great.
I don't fully understand the context of the changes in migrate_v1_to_v2, but the code looks good and is very readable. But just wanted to call out that blindspot I have, I don't know much about migrate_v1_to_v2 and if you have concerns about that code change, I would suggest tagging another reviewer who has more context.
| else: | ||
| range_min = -pi | ||
| range_max = pi | ||
|
|
There was a problem hiding this comment.
fixed a bug in the conversion function to prevent invalid ranges where min>max (e.g. [6, pi])
| }, | ||
| "B": { | ||
| "orient_bias_range": [6, pi], | ||
| "orient_bias_range": [-pi, 6], |
There was a problem hiding this comment.
updated test data for orient_bias_range accordingly
There was a problem hiding this comment.
Not sure why the test_single_spheres recipe has these values for the rotation bias range.
A thought: all angles should be converted to be within the range [-pi, pi] before any subsequent comparisons. [6,12] doesn't really make any geometric sense.
This should also make the convert_rotation_range easier to implement. Something like
def constrain_angle(angle):
return (angle + np.pi) % (2 * np.pi) - np.picould help
mogres
left a comment
There was a problem hiding this comment.
Love the recipe validation during read time! I have some comments about the orientation bias range conversion, but the validation updates look good to me!
| if "orientBiasRotRangeMax" in old_ingredient | ||
| else pi | ||
| ) | ||
| has_min = "orientBiasRotRangeMin" in old_ingredient |
There was a problem hiding this comment.
This logic flow is a bit confusing. Are there any example recipes where the min range is greater than the max range which requires doing this correction?
|
|
||
| import cellpack.autopack as autopack | ||
|
|
||
| log = logging.getLogger(__name__) |
There was a problem hiding this comment.
This line can go after the imports
| # validate recipe after migration to v2.1 format but before transforming to class instances | ||
| try: | ||
| RecipeValidator.validate_recipe(recipe_data) | ||
| log.info("Recipe validation passed") |
There was a problem hiding this comment.
Maybe this should be a debug statement instead of info?
cellpack/bin/validate.py
Outdated
|
|
||
| RecipeValidator.validate_recipe(raw_recipe_data) | ||
| log.info(f"Local recipe {raw_recipe_data['name']} is valid!") | ||
| use_docker = recipe_path.startswith("firebase:") |
There was a problem hiding this comment.
Is this always true? What about users packing firebase recipes locally? Maybe the variable name in RecipeLoader could be updated to cover these use cases?
There was a problem hiding this comment.
good point! I agree the name use_docker is a bit confusing here, and we can totally replace the hardcoded "firebase" with DATABSE_IDS. I'll make a overall refinement!
cellpack/bin/validate.py
Outdated
| use_docker = recipe_path.startswith("firebase:") | ||
| loader = RecipeLoader(recipe_path, use_docker=use_docker) | ||
| recipe_data = loader.recipe_data | ||
| log.info(f"Recipe {recipe_data['name']} is valid!") |
There was a problem hiding this comment.
Should probably be a debug instead of info.
| }, | ||
| "B": { | ||
| "orient_bias_range": [6, pi], | ||
| "orient_bias_range": [-pi, 6], |
There was a problem hiding this comment.
Not sure why the test_single_spheres recipe has these values for the rotation bias range.
A thought: all angles should be converted to be within the range [-pi, pi] before any subsequent comparisons. [6,12] doesn't really make any geometric sense.
This should also make the convert_rotation_range easier to implement. Something like
def constrain_angle(angle):
return (angle + np.pi) % (2 * np.pi) - np.picould help
* fix v1-v2 orient bias range migration tests * Update cellpack/autopack/loaders/migrate_v1_to_v2.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/autopack/loaders/migrate_v1_to_v2.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Update cellpack/tests/test_recipe_version_migration.py Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org> * Fix indent * update validation * remove range swap * fix compartment test --------- Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org>



Problem
closes #401
Solution
RecipeLoader._read()after data migrationvalidate.pyto use RecipeLoader for all recipeorientBiasRotRangeType of change
Steps to Verify:
validate examples/recipes/v1/one_sphere.jsonvalidate examples/recipes/v2/pcna_surface_gradient.jsonvalidate firebase:recipes/gradients_v_default -d