Skip to content

Config Usage

ChangLiu edited this page May 30, 2025 · 3 revisions

Using Configuration Files

Overview

This guide demonstrates how to load and parse configuration files using Hydra's configuration management system. Neuraldecoding provides utilities to load, validate, and extract specific sections from hierarchical YAML configurations.

Configuration Parsing Function

neuraldecoding.utils.parse_verify_config

def parse_verify_config(config: DictConfig, section_name: str) -> dict

Take in a config dict, validates the config, and return the content of a specific section.

Parameters

config : DictConfig

Config dictionary loaded from Hydra's compose function.

section_name : str

The section name to extract from the config file. Supported values are 'decoder' and 'trainer'.

Returns

dict

The config for the specified section in the config file.

Raises

ValueError If the specified section is not found in the config file, if the section has invalid structure, or if an unsupported section name is provided.

Loading Configuration Files

Example Basic Usage

To load a configuration file, use Hydra's initialize and compose functions:

from hydra import initialize, compose

with initialize(version_base=None, config_path="../../configs/parsing_test_1"):
    cfg = compose("config")

decoder_config = parse_verify_config(cfg, 'decoder')

trainer_config = parse_verify_config(cfg, 'trainer')

Clone this wiki locally