Galaxy Workflow Format 2 Descriptions

0.24.0 · active · verified Thu Apr 16

gxformat2 defines a high-level, human-readable, and human-writable workflow description format for Galaxy, known as Format 2. This package facilitates the creation, parsing, and conversion of Galaxy workflows, addressing the limitations of the older `.ga` format and moving towards compatibility with standards like the Common Workflow Language (CWL). It is actively developed and supports Galaxy versions 19.09 and newer, though the format is still somewhat experimental and may undergo minor backward-incompatible changes. The current version is 0.24.0, with a somewhat regular release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse a Format 2 workflow from a YAML string into a Python object using `parse_yaml_workflow`, and then convert it to the native Galaxy `.ga` format using `dump_format2_workflow_to_native`. It also shows how to access basic properties of the parsed workflow model.

from gxformat2.yaml import parse_yaml_workflow
from gxformat2.converter import dump_format2_workflow_to_native
import yaml

# Example Format 2 Workflow content (minimal example)
workflow_content = '''
class: GalaxyWorkflow
inputs:
  - id: input_file
    type: File
steps:
  - id: cat_tool
    tool_id: cat1
    in:
      input1: input_file
outputs:
  - id: output_file
    outputSource: cat_tool/out_file
'''

# 1. Parse a Format 2 YAML workflow string
# In a real scenario, you'd load this from a .gxwf.yml file
workflow_path = '/tmp/my_workflow.gxwf.yml'
with open(workflow_path, 'w') as f:
    f.write(workflow_content)

try:
    workflow_model = parse_yaml_workflow(workflow_path)
    print(f"Successfully parsed workflow: {workflow_model.label or workflow_model.id}")

    # 2. Convert the Format 2 workflow model to native Galaxy .ga format
    native_workflow_dict = dump_format2_workflow_to_native(workflow_model)
    print("\nConverted to native Galaxy workflow (excerpt):")
    print(yaml.dump(native_workflow_dict, indent=2, default_flow_style=False)[:200] + '...') # Print first 200 chars

    # You can access properties of the parsed model
    print(f"\nNumber of steps: {len(workflow_model.steps)}")
    print(f"First step tool_id: {workflow_model.steps[0].tool_id}")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →