Skip to content

Commit 95ac24b

Browse files
authored
user workflow improvements and config updates (#411)
* default upload_results to false * update config file options * update schema docs * propose to remove config files from the packing commands but add a section to explain how configs work * set open_results_in_browser to false since it's dependent on upload_results * improve loggings * add a config file for upload results * correct option default and log level * update schema * add aws db to path * add a layer to detect non-interactive envs for db selection * fix readme * add cellpack website url * remove unnecessary restriction * update readme * add screenshots to readme (#413) * add screenshots to readme * Quick fix: update bbox value in recipes (#420) * add randomness_seed to upload and download (#416) * update bbox value in recipes * add config option for plot display * replace result screenshots and update readme * update docs/index to display images correctly
1 parent 6980506 commit 95ac24b

File tree

17 files changed

+102
-43
lines changed

17 files changed

+102
-43
lines changed

README.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
An algorithm to pack molecular recipes
88

9+
**Try cellPACK online:** [cellpack.allencell.org](https://cellpack.allencell.org)
10+
911
## Installation
1012

1113
> [!NOTE]
12-
> These are the basic installation steps. However, our recommendation for developers is to install using `uv`. See advanced installation instructions [here](./docs/INSTALL.md).
14+
> These are the basic installation steps. However, our recommendation for developers is to install using `uv`. See advanced installation instructions [here](./docs/INSTALLATION.md).
1315
1416
1. Install Python 3.11 and `git`. Update pip at least to `24.0.0`.
1517
2. Clone this git repository.
@@ -30,9 +32,65 @@ pip install -e .
3032
```
3133

3234
## Pack example recipes
33-
1. v1: `pack -r examples/recipes/v1/NM_Analysis_FigureB1.0.json`
34-
2. v2: `pack -r examples/recipes/v2/spheres_in_a_box.json`
35-
3. Pack from remote server: `pack -r github:recipes/NM_Analysis_FigureB1.0.json `
35+
36+
cellPACK supports two recipe formats: **v1** (legacy) from the original publication, and **v2** (modern) with improved structure. We recommend starting with **v2** for new recipes.
37+
38+
### Recipe Format Versions
39+
40+
#### v1 Recipes (Legacy Format)
41+
**v1 recipes** use the original schema from the [Nature Methods publication](https://www.nature.com/articles/nmeth.3204). These recipes feature:
42+
- Explicit parameter definitions for all ingredients
43+
- Backward compatibility with the original cellPACK publication examples
44+
45+
**Example v1 recipes:**
46+
- `NM_Analysis_FigureB1.0.json` - Blood plasma mesoscale model from the Nature Methods publication
47+
- `BloodPlasma_noHIV_1.0_2D.json` - 2D blood plasma model
48+
- `partner_packing.json` - Example of molecular partner binding
49+
50+
**Run a v1 recipe:**
51+
```bash
52+
pack -r examples/recipes/v1/NM_Analysis_FigureB1.0.json
53+
```
54+
55+
![Blood Plasma Model Result](docs/images/nm_analysis_figure_b1_res.png)
56+
57+
#### v2 Recipes (Modern Format)
58+
**v2 recipes** use a modernized schema with improved structure and features:
59+
- Cleaner organization with `objects` and `composition` sections
60+
- Object inheritance system for efficient recipe authoring
61+
- Better support for complex cellular environments
62+
63+
**Example v2 recipes:**
64+
- `spheres_in_a_box.json` - Simple 3D multi-sphere packing (great for getting started)
65+
- `peroxisome.json` - Peroxisome organelle model
66+
- `er_peroxisome.json` - Endoplasmic reticulum with peroxisomes
67+
- `vector_gradient.json` - Demonstrates gradient-based ingredient distributions
68+
- `partner_packing.json` - Molecular partner interactions
69+
70+
**Run a v2 recipe:**
71+
```bash
72+
pack -r examples/recipes/v2/spheres_in_a_box.json
73+
```
74+
75+
![Multi-Sphere Result](docs/images/spheres_in_a_box_res.png)
76+
77+
### Remote Recipe Loading
78+
You can also load recipes directly from remote servers:
79+
```bash
80+
pack -r github:recipes/NM_Analysis_FigureB1.0.json
81+
```
82+
83+
### Config Files
84+
Config files control packing behavior and simulation parameters including:
85+
- **Place methods** - Algorithm used for ingredient placement (e.g., `jitter`, `spheresSST`)
86+
- **Output formats** - Save options for results and analysis
87+
- **Grid settings** - Spatial grid parameters for collision detection
88+
- **Debugging options** - Visualization and diagnostic tools
89+
90+
**Using a config file:**
91+
```bash
92+
pack -r examples/recipes/v2/spheres_in_a_box.json -c examples/packing-configs/debug.json
93+
```
3694

3795
**Stable Release:** `pip install cellpack`<br>
3896
**Development Head:** `pip install git+https://github.com/mesoscope/cellpack.git`

cellpack/autopack/AWSHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def save_file_and_get_url(self, file_path):
146146
if self.is_url_valid(base_url):
147147
return file_name, base_url
148148
except NoCredentialsError as e:
149-
print(f"AWS credentials are not configured, details:{e}")
149+
logging.warning(f"AWS credentials are not configured: {e}")
150150
return None, None
151151
return None, None
152152

cellpack/autopack/FirebaseHandler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def which_db(default_db=None):
4545
if default_db in options.values():
4646
log.debug(f"Using {default_db} database -------------")
4747
return default_db
48+
# detect if running in a non-interactive environment(CI, Docker, etc), default to staging db
49+
if not os.isatty(0):
50+
log.debug("Non-interactive environment detected, using staging database")
51+
return "staging"
4852
choice = input(
4953
f"Enter number for database ({', '.join([f'{k}: {v}' for k, v in options.items()])}): "
5054
).strip()

cellpack/autopack/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def checkPath():
179179
"autopackdata": appdata,
180180
f"{DATABASE_IDS.GITHUB.value}:": autoPACKserver,
181181
f"{DATABASE_IDS.FIREBASE.value}:": None,
182+
f"{DATABASE_IDS.AWS.value}:": None,
182183
}
183184

184185

@@ -400,7 +401,7 @@ def load_file(
400401
if not initialize_db._initialized:
401402
readme_url = "https://github.com/mesoscope/cellpack?tab=readme-ov-file#introduction-to-remote-databases"
402403
sys.exit(
403-
f"The selected database: {database_name} is not initialized. Please set up credentials to pack remote recipes. Refer to the instructions at {readme_url}"
404+
f"The selected database: {database_name} is not initialized. Please set up credentials to pack remote recipes. Refer to the instructions at {readme_url}, or try cellPACK web interface: https://cellpack.allencell.org (no setup required)"
404405
)
405406
db_handler = DBRecipeLoader(initialize_db)
406407
db_handler.validate_input_recipe_path(filename)

cellpack/autopack/interface_objects/database_ids.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def with_colon(cls):
1414

1515
@classmethod
1616
def handlers(cls):
17-
def create_aws_handler(bucket_name, sub_folder_name, region_name):
17+
def create_aws_handler(
18+
bucket_name=None, sub_folder_name=None, region_name=None
19+
):
1820
return AWSHandler(
1921
bucket_name=bucket_name,
2022
sub_folder_name=sub_folder_name,

cellpack/autopack/loaders/config_loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ConfigLoader(object):
3535
"ordered_packing": False,
3636
"out": "out/",
3737
"overwrite_place_method": False,
38-
"open_results_in_browser": True,
38+
"open_results_in_browser": False,
3939
"parallel": False,
4040
"place_method": "spheresSST",
4141
"randomness_seed": None,
@@ -47,7 +47,7 @@ class ConfigLoader(object):
4747
"show_sphere_trees": False,
4848
"show_progress_bar": True,
4949
"spacing": None,
50-
"upload_results": True,
50+
"upload_results": False,
5151
"use_periodicity": False,
5252
"version": 1.0,
5353
}

cellpack/autopack/upy/simularium/simularium_helper.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# standardmodule
3+
import logging
34
import os
45
import webbrowser
56
from pathlib import Path
@@ -1379,7 +1380,7 @@ def raycast(self, **kw):
13791380
def raycast_test(self, obj, start, end, length, **kw):
13801381
return
13811382

1382-
def post_and_open_file(self, file_name, open_results_in_browser=True):
1383+
def post_and_open_file(self, file_name, open_results_in_browser):
13831384
simularium_file = Path(f"{file_name}.simularium")
13841385
url = None
13851386
job_id = os.environ.get("AWS_BATCH_JOB_ID", None)
@@ -1414,8 +1415,8 @@ def store_result_file(file_path, storage=None, batch_job_id=None):
14141415
file_name, url = initialized_handler.save_file_and_get_url(file_path)
14151416
if not file_name or not url:
14161417
db_maintainer = DBMaintenance(initialized_handler)
1417-
print(
1418-
f"If AWS access needed, please refer to the instructions at {db_maintainer.readme_url()}. \nSkipping the opening of new browser tabs -------------"
1418+
logging.warning(
1419+
f"Skipping browser opening, upload credentials not configured. For setup instructions see: {db_maintainer.readme_url()}"
14191420
)
14201421
return file_name, url
14211422

@@ -1431,8 +1432,8 @@ def store_metadata(file_name, url, db=None, job_id=None):
14311432
db_uploader.upload_result_metadata(file_name, url, job_id)
14321433
else:
14331434
db_maintainer = DBMaintenance(initialized_db)
1434-
print(
1435-
f"Firebase credentials are not found. If needed, please refer to the instructions at {db_maintainer.readme_url()}. \nSkipping firebase staging database -------------"
1435+
logging.warning(
1436+
f"Firebase credentials not found. For setup instructions see: {db_maintainer.readme_url()}. Or try cellPACK web interface: https://cellpack.allencell.org (no setup required)"
14361437
)
14371438
return
14381439

cellpack/autopack/validation/recipe_models.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -565,20 +565,6 @@ def validate_gradient_surface_objects(self):
565565
)
566566
return self
567567

568-
@model_validator(mode="after")
569-
def validate_gradient_combinations(self):
570-
"""Validate gradient combinations in object gradient lists"""
571-
if hasattr(self, "objects") and self.objects:
572-
for obj_name, obj_data in self.objects.items():
573-
if hasattr(obj_data, "gradient") and obj_data.gradient is not None:
574-
if isinstance(obj_data.gradient, list):
575-
# multiple gradients - validate combination
576-
if len(obj_data.gradient) < 2:
577-
raise ValueError(
578-
f"objects.{obj_name}.gradient: gradient lists must contain at least 2 gradients"
579-
)
580-
return self
581-
582568
@model_validator(mode="after")
583569
def validate_object_inheritance(self):
584570
"""Validate that object inherit references point to existing objects in the objects section"""

cellpack/autopack/writers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ def save_as_simularium(self, env, seed_to_results_map):
194194
result_file_name, env.boundingBox, env.name, env.version
195195
)
196196
number_of_packings = env.config_data.get("number_of_packings", 1)
197-
open_results_in_browser = env.config_data.get("open_results_in_browser", True)
198-
upload_results = env.config_data.get("upload_results", True)
197+
open_results_in_browser = env.config_data.get("open_results_in_browser", False)
198+
upload_results = env.config_data.get("upload_results", False)
199199
if (number_of_packings == 1 or is_aggregate) and upload_results:
200200
autopack.helper.post_and_open_file(file_name, open_results_in_browser)
201201

docs/CONFIG_SCHEMA.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The config file controls the packing behavior. It specifies parameters such as p
1111
| `load_from_grid_file` | boolean | Load objects from a grid file | False | |
1212
| `name` | string | Name of the config | default | Used to identify this config run |
1313
| `number_of_packings` | number (>=1) | Number of independent packing replicates | 1 | |
14-
| `open_results_in_browser` | boolean | Open results in browser after run | True | |
14+
| `open_results_in_browser` | boolean | Open results in browser after run | False | Prerequisite: AWS s3 credentials |
1515
| `ordered_packing` | boolean | Use deterministic packing order | False | |
1616
| `out` | string | Output directory path | `"out/"` | |
1717
| `overwrite_place_method` | boolean | Override object-specific place methods | False | |
@@ -26,7 +26,7 @@ The config file controls the packing behavior. It specifies parameters such as p
2626
| `show_progress_bar` | boolean | Show progress bar in terminal | False | |
2727
| `show_sphere_trees` | boolean | Visualize sphere trees | False | |
2828
| `spacing` | number | Override object spacing | None | |
29-
| `upload_results` | boolean | Upload results to S3 | True | |
29+
| `upload_results` | boolean | Upload results to S3 | False | Requires AWS S3 credentials to upload the result file to S3 | |
3030
| `use_periodicity` | boolean | Enable periodic boundary conditions | False | |
3131
| `version` | number | Config version number | 1.0 | For internal tracking |
3232
| `image_export_options.hollow` | boolean | Export hollow images | False | |

0 commit comments

Comments
 (0)