From bfbdd3abb62cea6ce5ce5a1ca8160a71fadc9fba Mon Sep 17 00:00:00 2001 From: rohit-kannachel Date: Sat, 14 Jun 2025 15:43:18 -0400 Subject: [PATCH 1/3] Tried to implement a less complex protocol export function to create a easier to read yaml file from protocol developer --- autolamella/structures.py | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/autolamella/structures.py b/autolamella/structures.py index e520814..285e759 100644 --- a/autolamella/structures.py +++ b/autolamella/structures.py @@ -981,6 +981,46 @@ def save(self, path: Path) -> None: """Save the protocol to disk.""" with open(path, "w") as f: yaml.safe_dump(self.to_dict(), f, indent=4) + + def save_base_protocol(self, path: Path, current_milling_dict: dict = None) -> None: + """Saves less verbose version of full experiment protocol, + similar to base protocol for methods""" + with open(path, "w") as f: + yaml.safe_dump(self.to_dict_base_protocol(current_milling_dict), f, indent=4) + + def to_dict_base_protocol(self,current_milling_dict=None): + + """Keep only base necessary items to not overwhelm the protocol yaml file""" + + if current_milling_dict is None: + current_milling_dict = {k: get_protocol_from_stages(v) for k, v in self.milling.items()} + + milling_dict = self._reduced_milling_options_dict(current_milling_dict) + + options_dict = self.tmp + + protocol_dict = {'milling':milling_dict,'options':options_dict} + + return protocol_dict + + + def _reduced_milling_options_dict(self,milling_dict): + + # Items chosen to be removed from base protocol to reduce clutter + + items_to_remove = ['alignment','imaging','num'] + + if self.method.name == 'AutoLamella-Waffle': + + for milling_stages in milling_dict.values(): + + for i,sub_stage in enumerate(milling_stages): + + [sub_stage.pop(item) for item in items_to_remove] + + + return milling_dict + @staticmethod def load(path: Path) -> 'AutoLamellaProtocol': From b6382733cc1e31e87f299505bb0bc1e78ff1f0dc Mon Sep 17 00:00:00 2001 From: Patrick Cleeve <80024299+patrickcleeve2@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:36:56 +1000 Subject: [PATCH 2/3] Update autolamella/structures.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- autolamella/structures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autolamella/structures.py b/autolamella/structures.py index 285e759..0c2d1b4 100644 --- a/autolamella/structures.py +++ b/autolamella/structures.py @@ -988,7 +988,7 @@ def save_base_protocol(self, path: Path, current_milling_dict: dict = None) -> N with open(path, "w") as f: yaml.safe_dump(self.to_dict_base_protocol(current_milling_dict), f, indent=4) - def to_dict_base_protocol(self,current_milling_dict=None): + def to_dict_base_protocol(self, current_milling_dict=None): """Keep only base necessary items to not overwhelm the protocol yaml file""" From 7c930c32d5a63181aa0bc178918e7171e3d8b1d7 Mon Sep 17 00:00:00 2001 From: Patrick Cleeve <80024299+patrickcleeve2@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:37:26 +1000 Subject: [PATCH 3/3] Update autolamella/structures.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- autolamella/structures.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autolamella/structures.py b/autolamella/structures.py index 0c2d1b4..8a54f73 100644 --- a/autolamella/structures.py +++ b/autolamella/structures.py @@ -1016,9 +1016,8 @@ def _reduced_milling_options_dict(self,milling_dict): for i,sub_stage in enumerate(milling_stages): - [sub_stage.pop(item) for item in items_to_remove] - - + for item in items_to_remove: + sub_stage.pop(item, None) return milling_dict