Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support (de)serializing yaml-format recipes #124

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

rjgildea
Copy link
Contributor

This works by parsing serialized recipes with a YAML 1.2-compatible parser, of which JSON is a strict superset.

The following JSON-format recipe:

{
  "1": [
    "Example recipe for per-image-analysis storing results in ISPyB directly"
  ],
  "1": { "service": "DLS file watcher",
         "queue": "filewatcher",
         "parameters": { "pattern": "/path/to/images/2A4_1_%04d.cbf",
                         "pattern-start": "100",
                         "pattern-end": "100"
                       },
         "output": { "every": 2 }
       },
  "2": { "service": "DLS Per-Image-Analysis",
         "queue": "per_image_analysis",
         "output": 6
       },
  "6": { "service": "DLS ISPyB connector",
         "queue": "ispyb_pia",
         "parameters": { "ispyb_command": "store_per_image_analysis_results",
                         "program_id": "$ispyb_autoprocprogram_id",
                         "dcid": "{ispyb_dcid}"
                       }
       },
  "start": [
      [1, []]
  ]
}

could equivalently be represented in YAML format as:

1:
  output:
    every: 2
  parameters:
    pattern: /path/to/images/2A4_1_%04d.cbf
    pattern-end: 100
    pattern-start: 100
  queue: filewatcher
  service: DLS file watcher
2:
  output:
    - 6
  queue: per_image_analysis
  service: DLS Per-Image-Analysis
6:
  parameters:
    dcid: {ispyb_dcid}
    ispyb_command: store_per_image_analysis_results
    program_id: $ispyb_autoprocprogram_id
  queue: ispyb_pia
  service: DLS ISPyB connector
start:
- [1, []]

workflows.recipe.Recipe.serialize() now supports the keyword argument format="json". Acceptable values are "json" or "yaml".

No performance comparisons between the two parsers have been made yet. It could be possible to wrap the parsing in a try/except whereby we first try parsing with the native JSON parser, and failover to YAML in the event of failure, although this does complicate error handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant