Skip to the content.

YAML Configuration Support

This document describes the YAML configuration support added to RDFAnalyzerCore.

Overview

RDFAnalyzerCore now supports configuration files in both text (.txt) and YAML (.yaml or .yml) formats. The framework automatically detects which format to use based on the file extension.

Features

Format Comparison

Text Format (.txt)

directory=/home/user/testDir
saveFile=/home/user/outDir/output.root
threads=-1
globs=root,test

YAML Format (.yaml or .yml)

directory: /home/user/testDir
saveFile: /home/user/outDir/output.root
threads: "-1"
globs: root,test

Multi-Key Config (Text)

file=file1.json name=name1 type=type1
file=file2.json name=name2 type=type2

Multi-Key Config (YAML)

- file: file1.json
  name: name1
  type: type1
- file: file2.json
  name: name2
  type: type2

Vector Config (Text)

var1
var2
var3

Vector Config (YAML)

- var1
- var2
- var3

Usage

C++ Side

The ConfigurationManager automatically detects the format:

// Automatically uses YamlConfigAdapter for .yaml files
ConfigurationManager config("config.yaml");

// Automatically uses TextConfigAdapter for .txt files
ConfigurationManager config("config.txt");

// Access values the same way regardless of format
std::string dir = config.get("directory");

Python Side

The submission_backend module handles both formats:

from submission_backend import read_config, write_config

# Auto-detects format based on extension
config = read_config("config.yaml")  # YAML format
config = read_config("config.txt")   # Text format

# Write in either format
write_config(config, "output.yaml")  # Writes as YAML
write_config(config, "output.txt")   # Writes as text

Submission File Generation

The submission file generation scripts preserve the config format:

# If you provide a YAML config, submission configs will be YAML
python core/python/generateSubmissionFilesNANO.py -c config.yaml ...

# If you provide a text config, submission configs will be text
python core/python/generateSubmissionFilesNANO.py -c config.txt ...

Migration Guide

To migrate existing text configs to YAML:

  1. Change file extension from .txt to .yaml
  2. Convert key=value syntax to key: value syntax
  3. For multi-key configs, convert to YAML list format with - prefix
  4. For vector configs, add - prefix to each item

You can also use both formats side-by-side in the same analysis. The framework will handle them transparently.

Testing

Python Tests

Run the Python test suite:

python3 core/test/test_yaml_config.py

C++ Tests

The C++ test suite includes tests for YAML configs:

./test.sh

Specific YAML tests are in core/test/testConfigurationManager_YamlParsing.cc.

Implementation Details

C++ Implementation

Python Implementation

Dependencies

C++

Python