Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions autolamella/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,45 @@ 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with always removing these options from the dict, as others use the alignment/imaging settings. Instead of specifying method.name =="Waffle" (L1013), can you just add a flag here to remove the options for your use case. If it stays the way it is, it's gonna cause some silent issues later on


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):

for item in items_to_remove:
sub_stage.pop(item, None)
return milling_dict


@staticmethod
def load(path: Path) -> 'AutoLamellaProtocol':
Expand Down