Skip to content

YAML Configuration Generation #1810

@Relm-Arrowny

Description

@Relm-Arrowny

Currently, the Bluesky beamline-specific device configurations are defined within a Python script located in the dodal package. Any modification to a device's name, PV prefix, or configuration parameters necessitates editing this Python file, committing the change to dodal, and performing a full software release cycle. This process is cumbersome, introduces unnecessary dependencies on core library releases for deployment configuration changes and complicates beamline commissioning or maintenance.

Goals

Acceptance criteria :

Configuration Structure & Separation

  • Clear separation of concerns - separate beamline device definitions away from python codes that create the instance, dodal contain only device classes and no beamline-specific configuration (PVs, names, parameters)
  • A clearly defined configuration layer - specific device properties declaratively in YAML. This includes the device's Python class, its PV prefix, instantiation arguments, configuration and initialisation parameters using property setter.
  • Each device should be defined in its own YAML with one-to-one mapping, each logical device instance (e.g., i10apple2) must be defined in its own dedicated YAML file.
  • An aggregation mechanism, such as an all.yml file, capable of easily including, importing, or temporarily excluding individual or specific device configuration files using comment mark for deployment.
  • support object injection or wire-up in YAML file, i.e. a new object reuses existing objects like IOC.
  • support property setter/getter after object instantiation

Instantiation & Consumption

  • Develop a config loader or object creator utility that reads the aggregated configuration, dynamically resolves the Python class from dodal, and creates the instantiated device objects making them available to device manger.
  • The implementation should not only limited to device hardware objects, it should support any object creation.
  • The object creation process is a 2 stage process: 1st is object instantiation and registration with device manager, 2nd is property setter so different objects can be injected or wired-up together, i.e. IOC. The property setting should support both compulsory and optional property checking.

Deployment & Maintainability

  • Remove dodal configuration dependences. Any change to a PV prefix or device parameter or adding a new device requires only updating the relevant YAML files and restarting the BlueAPI, with no modification or redeployment of dodal.
  • Create clear documentation and a schema or example file for the YAML format, detailing the required structure, device types, and configuration parameters.

Tasks

base on the goals, deduce the tasks required. check them off once they're done

  • Schema Definition: Finalize the devices.yaml format to support nested dependencie
  • Handle Hierarchy: Define how to represent complex devices that contain sub-devices
  • Class Mapping template: Build a Python template that maps YAML strings
  • Instantiation Logic: Develop the "loader" that reads the YAML and instantiate the devices with the provided parameters
  • Pydantic: Use Pydantic to validate the YAML file.
  • Mock Mode Support: Enable a flag in the YAML for testing without beamline hardware.

Related Resources

any images/gifs, mockups/wireframes that would aid the development should be listed here
MockUp : link to mockup
Coda doc: link to coda
Additional context
Possible Structure:

beamline: i10
globals:
  config_server: "https://daq-config.diamond.ac.uk"
  lookup_dir: "/dls_sw/i10/software/gda/.../lookupTables/"

# References to individual device files
includes:
  - configs/mirrors.yaml
  - configs/id_downstream.yaml
  - configs/id_upstream.yaml
  - configs/slits.yaml

Each devices:

devices:
  - name: first_mirror
    type: PiezoMirror
    module: dodal.devices.i10
    args:
      prefix: "{PREFIX.beamline_prefix}-OP-COL-01:"

  - name: switching_mirror
    type: PiezoMirror
    module: dodal.devices.i10
    args:
      prefix: "{PREFIX.beamline_prefix}-OP-SWTCH-01:"
    properties:
      <property_name>: property_value
- name: pgm
    type: PlaneGratingMonochromator
    description: "I10 Plane Grating Monochromator"
    args:
      prefix: "{PREFIX.beamline_prefix}-OP-PGM-01:"
      grating: "I10Grating"
      grating_pv: "NLINES2"

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions