From 4071e47701778040c5cd585fd0b3e027f5e5a6b2 Mon Sep 17 00:00:00 2001 From: Ruge Li Date: Tue, 22 Oct 2024 14:45:52 -0700 Subject: [PATCH 1/5] retrieve job id --- cellpack/autopack/DBRecipeHandler.py | 4 ++-- cellpack/autopack/upy/simularium/simularium_helper.py | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cellpack/autopack/DBRecipeHandler.py b/cellpack/autopack/DBRecipeHandler.py index 08c12cc3..e3c77a0d 100644 --- a/cellpack/autopack/DBRecipeHandler.py +++ b/cellpack/autopack/DBRecipeHandler.py @@ -644,7 +644,7 @@ def upload_recipe(self, recipe_meta_data, recipe_data): recipe_to_save["recipe_path"] = self.db.create_path("recipes", recipe_id) self.upload_data("recipes", recipe_to_save, recipe_id) - def upload_result_metadata(self, file_name, url): + def upload_result_metadata(self, file_name, url, job_id=None): """ Upload the metadata of the result file to the database. """ @@ -654,7 +654,7 @@ def upload_result_metadata(self, file_name, url): self.db.update_or_create( "results", file_name, - {"user": username, "timestamp": timestamp, "url": url}, + {"user": username, "timestamp": timestamp, "url": url, "batch_job_id": job_id}, ) diff --git a/cellpack/autopack/upy/simularium/simularium_helper.py b/cellpack/autopack/upy/simularium/simularium_helper.py index bd09210b..25696187 100644 --- a/cellpack/autopack/upy/simularium/simularium_helper.py +++ b/cellpack/autopack/upy/simularium/simularium_helper.py @@ -1398,11 +1398,14 @@ def raycast_test(self, obj, start, end, length, **kw): def post_and_open_file(self, file_name, open_results_in_browser=True): simularium_file = Path(f"{file_name}.simularium") url = None + job_id = os.environ.get("AWS_BATCH_JOB_ID", None) + if job_id: + print(f"Batch Job ID: {job_id}") file_name, url = simulariumHelper.store_result_file( simularium_file, storage="aws" ) if file_name and url: - simulariumHelper.store_metadata(file_name, url, db="firebase") + simulariumHelper.store_metadata(file_name, url, db="firebase", job_id=job_id) if open_results_in_browser: simulariumHelper.open_in_simularium(url) @@ -1424,7 +1427,7 @@ def store_result_file(file_path, storage=None): return file_name, url @staticmethod - def store_metadata(file_name, url, db=None): + def store_metadata(file_name, url, db=None, job_id=None): if db == "firebase": handler = DATABASE_IDS.handlers().get(db) initialized_db = handler( @@ -1432,7 +1435,7 @@ def store_metadata(file_name, url, db=None): ) # default to staging for metadata uploads if initialized_db._initialized: db_uploader = DBUploader(initialized_db) - db_uploader.upload_result_metadata(file_name, url) + db_uploader.upload_result_metadata(file_name, url, job_id) else: db_maintainer = DBMaintenance(initialized_db) print( From 93324a6fe679db7c6f974c74a75231813e60b991 Mon Sep 17 00:00:00 2001 From: Ruge Li Date: Tue, 22 Oct 2024 14:46:45 -0700 Subject: [PATCH 2/5] formatting --- cellpack/autopack/Analysis.py | 11 +++++--- cellpack/autopack/DBRecipeHandler.py | 25 +++++++++++-------- cellpack/autopack/Environment.py | 14 +++++------ cellpack/autopack/GeometryTools.py | 7 +----- cellpack/autopack/Graphics.py | 6 ++--- cellpack/autopack/__init__.py | 4 ++- cellpack/autopack/ingredient/single_cube.py | 4 +-- cellpack/autopack/ingredient/single_sphere.py | 5 +++- .../autopack/interface_objects/partners.py | 8 +++--- cellpack/autopack/loaders/recipe_loader.py | 10 +++++--- cellpack/autopack/upy/colors.py | 1 + cellpack/autopack/upy/simularium/__init__.py | 1 + .../upy/simularium/simularium_helper.py | 4 ++- cellpack/autopack/writers/__init__.py | 8 +++--- 14 files changed, 61 insertions(+), 47 deletions(-) diff --git a/cellpack/autopack/Analysis.py b/cellpack/autopack/Analysis.py index 5b88b335..00b72e39 100644 --- a/cellpack/autopack/Analysis.py +++ b/cellpack/autopack/Analysis.py @@ -755,7 +755,10 @@ def add_ingredient_positions_to_plot( ) # plot the sphere if ingr.use_rbsphere: - (ext_recipe, pts,) = ingr.getInterpolatedSphere( + ( + ext_recipe, + pts, + ) = ingr.getInterpolatedSphere( seed_ingredient_positions[-i - 1], seed_ingredient_positions[-i], ) @@ -857,9 +860,9 @@ def update_pairwise_distances( ingr.name, ingr2.name, ): - pairwise_distance_dict[seed_index][ - f"{ingr.name}_{ingr2.name}" - ] = self.env.calc_pairwise_distances(ingr.name, ingr2.name).tolist() + pairwise_distance_dict[seed_index][f"{ingr.name}_{ingr2.name}"] = ( + self.env.calc_pairwise_distances(ingr.name, ingr2.name).tolist() + ) return pairwise_distance_dict diff --git a/cellpack/autopack/DBRecipeHandler.py b/cellpack/autopack/DBRecipeHandler.py index e3c77a0d..6f4df5a8 100644 --- a/cellpack/autopack/DBRecipeHandler.py +++ b/cellpack/autopack/DBRecipeHandler.py @@ -201,13 +201,13 @@ def resolve_local_regions(self, local_data, recipe_data, db): if not DataDoc.is_key(key_or_dict): obj_item = local_data["regions"][region_name][index]["object"] if DataDoc.is_key(obj_item): - local_data["regions"][region_name][index][ - "object" - ] = prep_recipe_data["objects"][obj_item] + local_data["regions"][region_name][index]["object"] = ( + prep_recipe_data["objects"][obj_item] + ) else: - local_data["regions"][region_name][index][ - "object" - ] = prep_recipe_data["objects"][obj_item["name"]] + local_data["regions"][region_name][index]["object"] = ( + prep_recipe_data["objects"][obj_item["name"]] + ) # replace reference in obj with actual data obj_data = local_data["regions"][region_name][index]["object"] self.resolve_object_data(obj_data, prep_recipe_data) @@ -362,9 +362,9 @@ def convert_representation(doc, db): and doc_value["packing"] is not None ): position_value = doc_value["packing"]["positions"] - convert_doc["representations"]["packing"][ - "positions" - ] = ObjectDoc.convert_positions_in_representation(position_value) + convert_doc["representations"]["packing"]["positions"] = ( + ObjectDoc.convert_positions_in_representation(position_value) + ) return convert_doc @staticmethod @@ -654,7 +654,12 @@ def upload_result_metadata(self, file_name, url, job_id=None): self.db.update_or_create( "results", file_name, - {"user": username, "timestamp": timestamp, "url": url, "batch_job_id": job_id}, + { + "user": username, + "timestamp": timestamp, + "url": url, + "batch_job_id": job_id, + }, ) diff --git a/cellpack/autopack/Environment.py b/cellpack/autopack/Environment.py index 76ce3492..e6f4550e 100644 --- a/cellpack/autopack/Environment.py +++ b/cellpack/autopack/Environment.py @@ -628,10 +628,10 @@ def resolve_gradient_data_objects(self, gradient_data): """ # TODO: check if other modes need to be resolved if gradient_data["mode"] == "surface": - gradient_data["mode_settings"][ - "object" - ] = self.get_compartment_object_by_name( - gradient_data["mode_settings"]["object"] + gradient_data["mode_settings"]["object"] = ( + self.get_compartment_object_by_name( + gradient_data["mode_settings"]["object"] + ) ) return gradient_data @@ -2567,9 +2567,9 @@ def store_asJson(self, resultfilename=None, indent=True): if r: self.result_json["exteriorRecipe"] = OrderedDict() for ingr in r.ingredients: - self.result_json["exteriorRecipe"][ - ingr.composition_name - ] = self.dropOneIngrJson(ingr, self.result_json["exteriorRecipe"]) + self.result_json["exteriorRecipe"][ingr.composition_name] = ( + self.dropOneIngrJson(ingr, self.result_json["exteriorRecipe"]) + ) # compartment ingr for orga in self.compartments: diff --git a/cellpack/autopack/GeometryTools.py b/cellpack/autopack/GeometryTools.py index 4817e20f..08275b99 100644 --- a/cellpack/autopack/GeometryTools.py +++ b/cellpack/autopack/GeometryTools.py @@ -165,12 +165,7 @@ def region_2_integrand(self, theta, rho, d): def region_2(self, rho, d): # require scipy - i4 = ( - d**3 - / 6.0 - * (rho**2 / d**2 - 1) - * (pi / 4 - self.region_1_2_theta(rho, d)) - ) + i4 = d**3 / 6.0 * (rho**2 / d**2 - 1) * (pi / 4 - self.region_1_2_theta(rho, d)) i3 = ( d**2 * rho diff --git a/cellpack/autopack/Graphics.py b/cellpack/autopack/Graphics.py index abec1318..6e0dbba6 100644 --- a/cellpack/autopack/Graphics.py +++ b/cellpack/autopack/Graphics.py @@ -1523,9 +1523,9 @@ def displayCompartmentsIngredients(self): elif self.vi.host == "dejavu": self.orgaToMasterGeom[ingr] = ingr.mesh elif self.vi.host == "softimage": - self.orgaToMasterGeom[ - ingr - ] = ingr.mesh # self.getMasterInstance(polygon) + self.orgaToMasterGeom[ingr] = ( + ingr.mesh + ) # self.getMasterInstance(polygon) # polygon already an instance from a different object\ j += 1 diff --git a/cellpack/autopack/__init__.py b/cellpack/autopack/__init__.py index dc8467c8..f2ed6bb0 100755 --- a/cellpack/autopack/__init__.py +++ b/cellpack/autopack/__init__.py @@ -392,7 +392,9 @@ def read_text_file(filename, destination="", cache="collisionTrees", force=None) return sphere_data -def load_file(filename, destination="", cache="geometries", force=None, use_docker=False): +def load_file( + filename, destination="", cache="geometries", force=None, use_docker=False +): if is_remote_path(filename): database_name, file_path = convert_db_shortname_to_url(filename) # command example: `pack -r firebase:recipes/[FIREBASE-RECIPE-ID] -c [CONFIG-FILE-PATH]` diff --git a/cellpack/autopack/ingredient/single_cube.py b/cellpack/autopack/ingredient/single_cube.py index c8612fd6..4b5c643c 100644 --- a/cellpack/autopack/ingredient/single_cube.py +++ b/cellpack/autopack/ingredient/single_cube.py @@ -366,9 +366,7 @@ def cube_surface_distance( current_distance = numpy.sqrt(dist_x**2 + dist_y**2) else: # vertex is the closest - current_distance = numpy.sqrt( - dist_x**2 + dist_y**2 + dist_z**2 - ) + current_distance = numpy.sqrt(dist_x**2 + dist_y**2 + dist_z**2) return current_distance def get_signed_distance( diff --git a/cellpack/autopack/ingredient/single_sphere.py b/cellpack/autopack/ingredient/single_sphere.py index d0e2b356..5d13e956 100644 --- a/cellpack/autopack/ingredient/single_sphere.py +++ b/cellpack/autopack/ingredient/single_sphere.py @@ -188,7 +188,10 @@ def collision_jitter( distance_to_packing_location - radius_of_ing_being_packed ) - (insidePoints, newDistPoints,) = self.get_new_distances_and_inside_points( + ( + insidePoints, + newDistPoints, + ) = self.get_new_distances_and_inside_points( env, jtrans, rotMat, diff --git a/cellpack/autopack/interface_objects/partners.py b/cellpack/autopack/interface_objects/partners.py index 72cac5ac..514b82e1 100644 --- a/cellpack/autopack/interface_objects/partners.py +++ b/cellpack/autopack/interface_objects/partners.py @@ -60,9 +60,11 @@ def __init__(self, partners): partner["name"], partner["position"] if "position" in partner else [0, 0, 0], partner["weight"] if "weight" in partner else weight, - partner["binding_probability"] - if "binding_probability" in partner - else 1.0, + ( + partner["binding_probability"] + if "binding_probability" in partner + else 1.0 + ), ) self.all_partners.append(partner) diff --git a/cellpack/autopack/loaders/recipe_loader.py b/cellpack/autopack/loaders/recipe_loader.py index d289a703..6c2563a5 100644 --- a/cellpack/autopack/loaders/recipe_loader.py +++ b/cellpack/autopack/loaders/recipe_loader.py @@ -157,7 +157,9 @@ def _migrate_version(self, old_recipe): ) def _read(self, resolve_inheritance=True, use_docker=False): - new_values, database_name = autopack.load_file(self.file_path, cache="recipes", use_docker=use_docker) + new_values, database_name = autopack.load_file( + self.file_path, cache="recipes", use_docker=use_docker + ) if database_name == "firebase": objects, gradients, composition = DBRecipeLoader.collect_and_sort_data( new_values["composition"] @@ -252,9 +254,9 @@ def _load_json(self): ): node = {"include": compartment["from"]} sub_recipe = self._request_sub_recipe(inode=node) - recipe_data["compartments"][ - compartment["from"] - ] = sub_recipe["compartments"] + recipe_data["compartments"][compartment["from"]] = ( + sub_recipe["compartments"] + ) continue compartment_dict = recipe_data["compartments"][cname] rep = None diff --git a/cellpack/autopack/upy/colors.py b/cellpack/autopack/upy/colors.py index 69d60b14..3fc2c5b3 100644 --- a/cellpack/autopack/upy/colors.py +++ b/cellpack/autopack/upy/colors.py @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with upy. If not, see . """ + import numpy from math import floor diff --git a/cellpack/autopack/upy/simularium/__init__.py b/cellpack/autopack/upy/simularium/__init__.py index acafa855..46a2d600 100644 --- a/cellpack/autopack/upy/simularium/__init__.py +++ b/cellpack/autopack/upy/simularium/__init__.py @@ -16,5 +16,6 @@ You should have received a copy of the GNU General Public License along with upy. If not, see . """ + # CRITICAL_DEPENDENCIES = ['blender','c4d'] __revision__ = "01" diff --git a/cellpack/autopack/upy/simularium/simularium_helper.py b/cellpack/autopack/upy/simularium/simularium_helper.py index 25696187..0932b6db 100644 --- a/cellpack/autopack/upy/simularium/simularium_helper.py +++ b/cellpack/autopack/upy/simularium/simularium_helper.py @@ -1405,7 +1405,9 @@ def post_and_open_file(self, file_name, open_results_in_browser=True): simularium_file, storage="aws" ) if file_name and url: - simulariumHelper.store_metadata(file_name, url, db="firebase", job_id=job_id) + simulariumHelper.store_metadata( + file_name, url, db="firebase", job_id=job_id + ) if open_results_in_browser: simulariumHelper.open_in_simularium(url) diff --git a/cellpack/autopack/writers/__init__.py b/cellpack/autopack/writers/__init__.py index 5b439ecb..f98a5c59 100644 --- a/cellpack/autopack/writers/__init__.py +++ b/cellpack/autopack/writers/__init__.py @@ -292,10 +292,10 @@ def save_Mixed_asJson( "include": ing_filename, } else: - env.jsondic["cytoplasme"]["ingredients"][ - ingr.composition_name - ] = io_ingr.ingrJsonNode( - ingr, result=result, kwds=kwds, transpose=transpose + env.jsondic["cytoplasme"]["ingredients"][ingr.composition_name] = ( + io_ingr.ingrJsonNode( + ingr, result=result, kwds=kwds, transpose=transpose + ) ) # {"name":ingr.composition_name} env.jsondic["cytoplasme"]["ingredients"][ingr.composition_name][ "name" From 685d4ca85c59865f24a092a8616a9d030d5e617c Mon Sep 17 00:00:00 2001 From: Ruge Li Date: Fri, 25 Oct 2024 15:09:20 -0700 Subject: [PATCH 3/5] add a bucket for batch jobs --- .../upy/simularium/simularium_helper.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cellpack/autopack/upy/simularium/simularium_helper.py b/cellpack/autopack/upy/simularium/simularium_helper.py index 0932b6db..b2e3cad4 100644 --- a/cellpack/autopack/upy/simularium/simularium_helper.py +++ b/cellpack/autopack/upy/simularium/simularium_helper.py @@ -1402,7 +1402,7 @@ def post_and_open_file(self, file_name, open_results_in_browser=True): if job_id: print(f"Batch Job ID: {job_id}") file_name, url = simulariumHelper.store_result_file( - simularium_file, storage="aws" + simularium_file, storage="aws", batch_job_id=job_id ) if file_name and url: simulariumHelper.store_metadata( @@ -1412,14 +1412,21 @@ def post_and_open_file(self, file_name, open_results_in_browser=True): simulariumHelper.open_in_simularium(url) @staticmethod - def store_result_file(file_path, storage=None): + def store_result_file(file_path, storage=None, batch_job_id=None): if storage == "aws": handler = DATABASE_IDS.handlers().get(storage) - initialized_handler = handler( - bucket_name="cellpack-results", - sub_folder_name="simularium", - region_name="us-west-2", - ) + if batch_job_id: # save results to batch job bucket + initialized_handler = handler( + bucket_name="cellpack-demo", + sub_folder_name="simularium", + region_name="us-west-2", + ) + else: + initialized_handler = handler( + bucket_name="cellpack-results", + sub_folder_name="simularium", + region_name="us-west-2", + ) file_name, url = initialized_handler.save_file_and_get_url(file_path) if not file_name or not url: db_maintainer = DBMaintenance(initialized_handler) From 19d556c448f4f99798b99ed29cf7756a1c6779b0 Mon Sep 17 00:00:00 2001 From: Ruge Li Date: Fri, 25 Oct 2024 15:09:30 -0700 Subject: [PATCH 4/5] formatting --- cellpack/autopack/Analysis.py | 11 ++++------- cellpack/autopack/DBRecipeHandler.py | 18 +++++++++--------- cellpack/autopack/Environment.py | 14 +++++++------- cellpack/autopack/GeometryTools.py | 7 ++++++- cellpack/autopack/Graphics.py | 6 +++--- cellpack/autopack/ingredient/single_cube.py | 4 +++- cellpack/autopack/ingredient/single_sphere.py | 5 +---- cellpack/autopack/loaders/recipe_loader.py | 6 +++--- cellpack/autopack/writers/__init__.py | 8 ++++---- 9 files changed, 40 insertions(+), 39 deletions(-) diff --git a/cellpack/autopack/Analysis.py b/cellpack/autopack/Analysis.py index 00b72e39..5b88b335 100644 --- a/cellpack/autopack/Analysis.py +++ b/cellpack/autopack/Analysis.py @@ -755,10 +755,7 @@ def add_ingredient_positions_to_plot( ) # plot the sphere if ingr.use_rbsphere: - ( - ext_recipe, - pts, - ) = ingr.getInterpolatedSphere( + (ext_recipe, pts,) = ingr.getInterpolatedSphere( seed_ingredient_positions[-i - 1], seed_ingredient_positions[-i], ) @@ -860,9 +857,9 @@ def update_pairwise_distances( ingr.name, ingr2.name, ): - pairwise_distance_dict[seed_index][f"{ingr.name}_{ingr2.name}"] = ( - self.env.calc_pairwise_distances(ingr.name, ingr2.name).tolist() - ) + pairwise_distance_dict[seed_index][ + f"{ingr.name}_{ingr2.name}" + ] = self.env.calc_pairwise_distances(ingr.name, ingr2.name).tolist() return pairwise_distance_dict diff --git a/cellpack/autopack/DBRecipeHandler.py b/cellpack/autopack/DBRecipeHandler.py index 6f4df5a8..61c86745 100644 --- a/cellpack/autopack/DBRecipeHandler.py +++ b/cellpack/autopack/DBRecipeHandler.py @@ -201,13 +201,13 @@ def resolve_local_regions(self, local_data, recipe_data, db): if not DataDoc.is_key(key_or_dict): obj_item = local_data["regions"][region_name][index]["object"] if DataDoc.is_key(obj_item): - local_data["regions"][region_name][index]["object"] = ( - prep_recipe_data["objects"][obj_item] - ) + local_data["regions"][region_name][index][ + "object" + ] = prep_recipe_data["objects"][obj_item] else: - local_data["regions"][region_name][index]["object"] = ( - prep_recipe_data["objects"][obj_item["name"]] - ) + local_data["regions"][region_name][index][ + "object" + ] = prep_recipe_data["objects"][obj_item["name"]] # replace reference in obj with actual data obj_data = local_data["regions"][region_name][index]["object"] self.resolve_object_data(obj_data, prep_recipe_data) @@ -362,9 +362,9 @@ def convert_representation(doc, db): and doc_value["packing"] is not None ): position_value = doc_value["packing"]["positions"] - convert_doc["representations"]["packing"]["positions"] = ( - ObjectDoc.convert_positions_in_representation(position_value) - ) + convert_doc["representations"]["packing"][ + "positions" + ] = ObjectDoc.convert_positions_in_representation(position_value) return convert_doc @staticmethod diff --git a/cellpack/autopack/Environment.py b/cellpack/autopack/Environment.py index e6f4550e..76ce3492 100644 --- a/cellpack/autopack/Environment.py +++ b/cellpack/autopack/Environment.py @@ -628,10 +628,10 @@ def resolve_gradient_data_objects(self, gradient_data): """ # TODO: check if other modes need to be resolved if gradient_data["mode"] == "surface": - gradient_data["mode_settings"]["object"] = ( - self.get_compartment_object_by_name( - gradient_data["mode_settings"]["object"] - ) + gradient_data["mode_settings"][ + "object" + ] = self.get_compartment_object_by_name( + gradient_data["mode_settings"]["object"] ) return gradient_data @@ -2567,9 +2567,9 @@ def store_asJson(self, resultfilename=None, indent=True): if r: self.result_json["exteriorRecipe"] = OrderedDict() for ingr in r.ingredients: - self.result_json["exteriorRecipe"][ingr.composition_name] = ( - self.dropOneIngrJson(ingr, self.result_json["exteriorRecipe"]) - ) + self.result_json["exteriorRecipe"][ + ingr.composition_name + ] = self.dropOneIngrJson(ingr, self.result_json["exteriorRecipe"]) # compartment ingr for orga in self.compartments: diff --git a/cellpack/autopack/GeometryTools.py b/cellpack/autopack/GeometryTools.py index 08275b99..4817e20f 100644 --- a/cellpack/autopack/GeometryTools.py +++ b/cellpack/autopack/GeometryTools.py @@ -165,7 +165,12 @@ def region_2_integrand(self, theta, rho, d): def region_2(self, rho, d): # require scipy - i4 = d**3 / 6.0 * (rho**2 / d**2 - 1) * (pi / 4 - self.region_1_2_theta(rho, d)) + i4 = ( + d**3 + / 6.0 + * (rho**2 / d**2 - 1) + * (pi / 4 - self.region_1_2_theta(rho, d)) + ) i3 = ( d**2 * rho diff --git a/cellpack/autopack/Graphics.py b/cellpack/autopack/Graphics.py index 6e0dbba6..abec1318 100644 --- a/cellpack/autopack/Graphics.py +++ b/cellpack/autopack/Graphics.py @@ -1523,9 +1523,9 @@ def displayCompartmentsIngredients(self): elif self.vi.host == "dejavu": self.orgaToMasterGeom[ingr] = ingr.mesh elif self.vi.host == "softimage": - self.orgaToMasterGeom[ingr] = ( - ingr.mesh - ) # self.getMasterInstance(polygon) + self.orgaToMasterGeom[ + ingr + ] = ingr.mesh # self.getMasterInstance(polygon) # polygon already an instance from a different object\ j += 1 diff --git a/cellpack/autopack/ingredient/single_cube.py b/cellpack/autopack/ingredient/single_cube.py index 4b5c643c..c8612fd6 100644 --- a/cellpack/autopack/ingredient/single_cube.py +++ b/cellpack/autopack/ingredient/single_cube.py @@ -366,7 +366,9 @@ def cube_surface_distance( current_distance = numpy.sqrt(dist_x**2 + dist_y**2) else: # vertex is the closest - current_distance = numpy.sqrt(dist_x**2 + dist_y**2 + dist_z**2) + current_distance = numpy.sqrt( + dist_x**2 + dist_y**2 + dist_z**2 + ) return current_distance def get_signed_distance( diff --git a/cellpack/autopack/ingredient/single_sphere.py b/cellpack/autopack/ingredient/single_sphere.py index 5d13e956..d0e2b356 100644 --- a/cellpack/autopack/ingredient/single_sphere.py +++ b/cellpack/autopack/ingredient/single_sphere.py @@ -188,10 +188,7 @@ def collision_jitter( distance_to_packing_location - radius_of_ing_being_packed ) - ( - insidePoints, - newDistPoints, - ) = self.get_new_distances_and_inside_points( + (insidePoints, newDistPoints,) = self.get_new_distances_and_inside_points( env, jtrans, rotMat, diff --git a/cellpack/autopack/loaders/recipe_loader.py b/cellpack/autopack/loaders/recipe_loader.py index 6c2563a5..a9e32c0a 100644 --- a/cellpack/autopack/loaders/recipe_loader.py +++ b/cellpack/autopack/loaders/recipe_loader.py @@ -254,9 +254,9 @@ def _load_json(self): ): node = {"include": compartment["from"]} sub_recipe = self._request_sub_recipe(inode=node) - recipe_data["compartments"][compartment["from"]] = ( - sub_recipe["compartments"] - ) + recipe_data["compartments"][ + compartment["from"] + ] = sub_recipe["compartments"] continue compartment_dict = recipe_data["compartments"][cname] rep = None diff --git a/cellpack/autopack/writers/__init__.py b/cellpack/autopack/writers/__init__.py index f98a5c59..5b439ecb 100644 --- a/cellpack/autopack/writers/__init__.py +++ b/cellpack/autopack/writers/__init__.py @@ -292,10 +292,10 @@ def save_Mixed_asJson( "include": ing_filename, } else: - env.jsondic["cytoplasme"]["ingredients"][ingr.composition_name] = ( - io_ingr.ingrJsonNode( - ingr, result=result, kwds=kwds, transpose=transpose - ) + env.jsondic["cytoplasme"]["ingredients"][ + ingr.composition_name + ] = io_ingr.ingrJsonNode( + ingr, result=result, kwds=kwds, transpose=transpose ) # {"name":ingr.composition_name} env.jsondic["cytoplasme"]["ingredients"][ingr.composition_name][ "name" From e82ca6fe1b8385cce083e546e95bcc478cea8879 Mon Sep 17 00:00:00 2001 From: Ruge Li Date: Mon, 4 Nov 2024 11:58:43 -0800 Subject: [PATCH 5/5] remove print statement and add comments --- cellpack/autopack/upy/simularium/simularium_helper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cellpack/autopack/upy/simularium/simularium_helper.py b/cellpack/autopack/upy/simularium/simularium_helper.py index b2e3cad4..845bec2c 100644 --- a/cellpack/autopack/upy/simularium/simularium_helper.py +++ b/cellpack/autopack/upy/simularium/simularium_helper.py @@ -1399,8 +1399,6 @@ def post_and_open_file(self, file_name, open_results_in_browser=True): simularium_file = Path(f"{file_name}.simularium") url = None job_id = os.environ.get("AWS_BATCH_JOB_ID", None) - if job_id: - print(f"Batch Job ID: {job_id}") file_name, url = simulariumHelper.store_result_file( simularium_file, storage="aws", batch_job_id=job_id ) @@ -1415,7 +1413,9 @@ def post_and_open_file(self, file_name, open_results_in_browser=True): def store_result_file(file_path, storage=None, batch_job_id=None): if storage == "aws": handler = DATABASE_IDS.handlers().get(storage) - if batch_job_id: # save results to batch job bucket + # if batch_job_id is not None, then we are in a batch job and should use the temp bucket + # TODO: use cellpack-results bucket for batch jobs once we have the correct permissions + if batch_job_id: initialized_handler = handler( bucket_name="cellpack-demo", sub_folder_name="simularium",