Skip to content

Conversation

@dkazanc
Copy link
Collaborator

@dkazanc dkazanc commented Sep 9, 2025

  • Yaml generator changes to enable sweep runs
  • New sweep pipeline directive

DiamondLightSource/httomo#628

Copy link
Contributor

@yousefmoazzam yousefmoazzam left a comment

Choose a reason for hiding this comment

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

I think this does the job fine if the number of sweep values in all directives that want to do a manual sweep will have exactly 3 values.

If it's desired to be able to have a list of any number of sweep values, here's a minimal working example that demonstrates it:

import yaml


class SweepManual:
    """SweepManual class."""

    def __init__(self, lst):
        self._lst = lst


def __sweepmanual_representer(
    dumper: yaml.SafeDumper, swp: SweepManual
) -> yaml.nodes.SequenceNode:
    """Represent a sweepmanual as a YAML sequence node."""
    return dumper.represent_sequence("!Sweep", swp._lst)


def get_dumper():
    safe_dumper = yaml.SafeDumper
    safe_dumper.add_representer(SweepManual, __sweepmanual_representer)
    return safe_dumper


pipeline_data = [
    {
        "method": "FBP",
        "module_path": "httomolibgpu.recon.algorithm",
        "parameters": {
            "center": SweepManual([1, 2, 3, 4]),
            "filter_freq_cutoff": 0.35,
        },
    }
]

with open("sweep-tag-serialise.yaml", "w") as stream:
    stream.write(yaml.dump(pipeline_data, Dumper=get_dumper()))

@dkazanc
Copy link
Collaborator Author

dkazanc commented Sep 11, 2025

Thanks Yousef, let me try to add it. Having something more generic is better.

@dkazanc dkazanc merged commit 86e498b into main Sep 12, 2025
2 checks passed
@dkazanc dkazanc deleted the sweepchanges branch September 12, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants