Skip to content

Commit d766af2

Browse files
authored
Add description field to recipe schema and backend utilities (#430)
* add `description` and `randomness_seed` to top level recipe settings * add description in example recipes * add description to download and upload script * add description field to unit tests
1 parent 95ac24b commit d766af2

File tree

11 files changed

+19
-0
lines changed

11 files changed

+19
-0
lines changed

cellpack/autopack/DBRecipeHandler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,8 @@ def compile_db_recipe_data(db_recipe_data, obj_dict, grad_dict, comp_dict):
855855
recipe_data["grid_file_path"] = db_recipe_data.get("grid_file_path")
856856
if db_recipe_data.get("randomness_seed"):
857857
recipe_data["randomness_seed"] = db_recipe_data.get("randomness_seed")
858+
if db_recipe_data.get("description"):
859+
recipe_data["description"] = db_recipe_data.get("description")
858860
if grad_dict:
859861
recipe_data["gradients"] = [
860862
{**v} for v in DBRecipeLoader.remove_dedup_hash(grad_dict).values()

cellpack/autopack/validation/recipe_models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,12 @@ def validate_entry_content(self):
417417
# RECIPE-METADATA-LEVEL
418418
class Recipe(BaseModel):
419419
name: str
420+
description: Optional[str] = None
420421
version: str = Field("1.0.0")
421422
format_version: str = Field("2.0")
422423
bounding_box: List[List[float]] = Field([[0, 0, 0], [100, 100, 100]])
423424
grid_file_path: Optional[str] = None
425+
randomness_seed: Optional[int] = None
424426
objects: Dict[str, RecipeObject] = Field(default_factory=dict)
425427
gradients: Union[Dict[str, RecipeGradient], List[Dict[str, Any]]] = Field(
426428
default_factory=dict

cellpack/bin/upload.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def get_recipe_metadata(loader):
2121
"bounding_box": loader.recipe_data["bounding_box"],
2222
"composition": {},
2323
}
24+
if "description" in loader.recipe_data:
25+
recipe_meta_data["description"] = loader.recipe_data["description"]
2426
if "grid_file_path" in loader.recipe_data:
2527
recipe_meta_data["grid_file_path"] = loader.recipe_data["grid_file_path"]
2628
if "randomness_seed" in loader.recipe_data:

cellpack/tests/test_db_recipe_loader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@
9191
"version": "linear",
9292
"bounding_box": [[-110, -45, -62], [110, 45, 62]],
9393
"name": "test_recipe",
94+
"description": "test_description",
9495
}
9596

9697

9798
compiled_firebase_recipe_example = {
9899
"name": "test_recipe",
100+
"description": "test_description",
99101
"format_version": "2.1",
100102
"version": "linear",
101103
"bounding_box": [[-110, -45, -62], [110, 45, 62]],

cellpack/tests/test_db_uploader.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def test_upload_data_with_recipe_and_id():
2727
collection = "recipe"
2828
data = {
2929
"name": "test",
30+
"description": "test_description",
3031
"bounding_box": [[0, 0, 0], [1000, 1000, 1]],
3132
"version": "1.0.0",
3233
"composition": {"test": {"inherit": "firebase:test_collection/test_id"}},
@@ -147,11 +148,13 @@ def test_upload_collections():
147148
def test_upload_recipe():
148149
recipe_meta_data = {
149150
"name": "one_sphere",
151+
"description": "test_description",
150152
"version": "1.0.0",
151153
"composition": {},
152154
}
153155
recipe_data = {
154156
"name": "one_sphere",
157+
"description": "test_description",
155158
"version": "1.0.0",
156159
"objects": {
157160
"sphere_25": {

docs/RECIPE_SCHEMA.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ The top-level fields include metadata about the recipe, such as its name, versio
99
| Field Path | Type | Description | Default Value | Notes |
1010
| ---------------- | ------------------------------------------------ | ---------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
1111
| `name` | string | Name of the recipe | | |
12+
| `description` | string | Description of the recipe | | |
1213
| `version` | string | Recipe version string | "default" | Version of the recipe is appended to the output file name. |
1314
| `format_version` | string | Schema format version | "1.0" | Older recipe formats do not have this field. Recipes are automatically migrated to the latest format version before packing. |
1415
| `bounding_box` | array `[[minX, minY, minZ], [maxX, maxY, maxZ]]` | Bounding box of the packing result | `[[ 0, 0, 0 ], [ 100, 100, 100 ]]` | |
1516
| `grid_file_path` | string | File path to read/write grid data | | If not specified, a grid file is created and stored at the output path. |
17+
| `randomness_seed` | integer | Seed for random number generation | | |
1618

1719
**Example:**
1820
```JSON
1921
{
2022
"name": "one_sphere",
23+
"description": "Single sphere packed within a bounding box",
2124
"version": "1.0.0",
2225
"format_version": "2.0",
2326
"bounding_box": [

examples/recipes/v2/endosome.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": "gradient_packing",
33
"format_version": "2.1",
44
"name": "endosome",
5+
"description": "Endosomes puncta (represented as spheres) packed with various biases in mesh containers, representing the cell membrane and nucleus, derived from a segmented hiPS cell.",
56
"bounding_box": [
67
[
78
-124.39499130249024,

examples/recipes/v2/er_peroxisome.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": "gradient_packing",
33
"format_version": "2.1",
44
"name": "ER_peroxisome",
5+
"description": "Peroxisome puncta (represented as spheres) packed in and around mesh containers representing the cell membrane, the nucleus, and the endoplasmic reticulum (ER), derived from a segmented hiPS cell.",
56
"bounding_box": [
67
[
78
33.77499999999999,

examples/recipes/v2/golgi_endosome.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": "gradient_packing",
33
"format_version": "2.1",
44
"name": "golgi_endosome",
5+
"description": "Endosome puncta (represented as spheres) packed in and around mesh containers representing the cell membrane, the nucleus, and the Golgi, derived from a segmented hiPS cell.",
56
"bounding_box": [
67
[
78
34.5,

examples/recipes/v2/peroxisome.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": "gradient_packing",
33
"format_version": "2.1",
44
"name": "peroxisome",
5+
"description": "Peroxisomes puncta (represented as spheres) packed with various biases in mesh containers representing the cell membrane and nucleus derived from a segmented hiPS cell.",
56
"bounding_box": [
67
[
78
35.325,

0 commit comments

Comments
 (0)