pyagc.utils.get_training_config

get_training_config(dataset: str, config_path: str = 'train.conf.yaml') dict[source]

Load training configuration from a YAML file with dataset-specific overrides.

This function loads a hierarchical configuration file where a ‘default’ section provides base configurations and dataset-specific sections override these defaults. The merge is performed using deep dictionary updates to preserve nested structure.

The configuration file should follow this structure:

default:
  learning_rate: 0.001
  hidden_dim: 128
  model:
    num_layers: 2
    dropout: 0.5

Cora:
  learning_rate: 0.01
  model:
    num_layers: 3

CiteSeer:
  hidden_dim: 256
Parameters:
  • dataset (str) – Name of the dataset. Should match a top-level key in the configuration file (case-sensitive).

  • config_path (str, optional) – Path to the YAML configuration file. (default: 'train.conf.yaml')

Returns:

Merged configuration dictionary where dataset-specific values

override default values. Nested dictionaries are recursively merged.

Return type:

dict

Raises:
  • FileNotFoundError – If the configuration file does not exist.

  • yaml.YAMLError – If the configuration file contains invalid YAML syntax.

Example

>>> # Given train.conf.yaml:
>>> # default:
>>> #   lr: 0.001
>>> #   hidden: 128
>>> # Cora:
>>> #   lr: 0.01
>>> config = get_training_config('Cora')
>>> print(config)
{'lr': 0.01, 'hidden': 128}

Note

  • If the dataset is not found in the config file, only default configuration is returned

  • Nested dictionaries are merged recursively via deep_update()

  • This function does not validate configuration values