Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
(#1474) move save-panda to dodal
Browse files Browse the repository at this point in the history
  • Loading branch information
rtuck99 committed Jul 23, 2024
1 parent 1fcb7d2 commit c54e34e
Showing 1 changed file with 1 addition and 46 deletions.
47 changes: 1 addition & 46 deletions src/hyperion/device_setup_plans/setup_panda.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import os
import sys
from argparse import ArgumentParser
from enum import Enum
from pathlib import Path
from typing import cast

import bluesky.plan_stubs as bps
from blueapi.core import MsgGenerator
from bluesky import RunEngine
from dodal.beamlines import module_name_for_beamline
from dodal.common.beamlines.beamline_utils import get_directory_provider
from dodal.devices.fast_grid_scan import PandAGridScanParams
from dodal.utils import make_all_devices
from ophyd_async.core import load_device, save_device
from ophyd_async.core import load_device
from ophyd_async.panda import (
HDFPanda,
SeqTable,
SeqTableRow,
SeqTrigger,
phase_sorter,
seq_table_from_rows,
)

Expand Down Expand Up @@ -237,41 +230,3 @@ def set_and_create_panda_directory(panda_directory: Path):
os.makedirs(panda_directory)

get_directory_provider().update(directory=panda_directory)


def _save_panda_to_file(RE: RunEngine, panda: HDFPanda, path: str):
def save_to_file():
yield from save_device(panda, path, sorter=phase_sorter)

RE(save_to_file())


def _main():
parser = ArgumentParser(description="Save a device to yaml")
parser.add_argument("beamline", help="beamline to save from e.g. i03")
parser.add_argument("device_name", help="name of the device e.g. panda")
parser.add_argument("output_file", help="output filename")
args = parser.parse_args()
beamline = args.beamline
device_name = args.device_name
output_file = args.output_file

print(f"Saving to {output_file} from {device_name} on {beamline}")
os.environ["BEAMLINE"] = beamline
RE = RunEngine()

print("Creating devices...")
module_name = module_name_for_beamline(beamline)
devices, exceptions = make_all_devices(
f"dodal.beamlines.{module_name}", include_skipped=False
)
panda = devices[device_name]

print("Saving to file...")
_save_panda_to_file(RE, cast(HDFPanda, panda), output_file)
print("Done.")
return 0


if __name__ == "__main__":
sys.exit(_main())

0 comments on commit c54e34e

Please sign in to comment.