{"id":2970,"library":"hyperpyyaml","title":"HyperPyYAML","description":"HyperPyYAML is a Python library that extends the YAML syntax for enhanced interaction with Python objects and better hyperparameter definition. It is actively maintained, with a recent version 1.2.3, and typically releases updates as needed for bug fixes and new features.","status":"active","version":"1.2.3","language":"en","source_language":"en","source_url":"https://github.com/speechbrain/HyperPyYAML","tags":["YAML","configuration","hyperparameters","speechbrain","data serialization","MLOps"],"install":[{"cmd":"pip install hyperpyyaml","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core YAML parsing.","package":"pyyaml","optional":false},{"reason":"Underlying YAML parsing, specific version required for compatibility.","package":"ruamel.yaml","optional":false}],"imports":[{"symbol":"load_hyperpyyaml","correct":"from hyperpyyaml import load_hyperpyyaml"}],"quickstart":{"code":"import torch\nfrom hyperpyyaml import load_hyperpyyaml\n\nexample_hyperparams_yaml = \"\"\"\nbase_channels: 32\nkernel_size: 11\npadding: !ref <kernel_size> // 2\nlayer1: !new:torch.nn.Conv1d\n  in_channels: 1\n  out_channels: !ref <base_channels>\n  kernel_size: !ref <kernel_size>\n  padding: !ref <padding>\nmodel: !new:torch.nn.Sequential\n  - !ref <layer1>\n  - !new:torch.nn.LeakyReLU\n\"\"\"\n\n# Using load_hyperpyyaml to parse the YAML string\nloaded_hparams = load_hyperpyyaml(example_hyperparams_yaml)\n\nprint(loaded_hparams['base_channels'])\nprint(loaded_hparams['padding'])\nprint(loaded_hparams['model'])\n","lang":"python","description":"This quickstart demonstrates how to load a YAML string containing HyperPyYAML extensions. It shows the use of `!ref` for referencing other parameters and `!new` for instantiating Python objects (like PyTorch modules) directly from the YAML."},"warnings":[{"fix":"Only load YAML files from trusted sources. Review any YAML configuration before using it with HyperPyYAML, especially files from external or untrusted origins.","message":"HyperPyYAML allows arbitrary code execution through its custom tags, which is a feature for flexible configuration. Treat all YAML files loaded with HyperPyYAML as you would Python code. Loading untrusted YAML files can lead to security vulnerabilities.","severity":"breaking","affected_versions":"All versions"},{"fix":"Upgrade HyperPyYAML to version 1.2.3 or newer, which explicitly pins `ruamel.yaml<0.19.0` in its dependencies to ensure compatibility. If manually managing dependencies, ensure `ruamel.yaml` is below `0.19.0`.","message":"Compatibility issues with `ruamel.yaml` versions have occurred. Specifically, versions of `ruamel.yaml` 0.19.0 and above can cause breakage due to API changes.","severity":"breaking","affected_versions":"<1.2.3"},{"fix":"Upgrade to HyperPyYAML 1.2.3 or higher, where this issue has been resolved.","message":"The `!include` tag in older versions could break due to incorrect handling of overrides, particularly when no overrides were provided or the structure was unexpected.","severity":"gotcha","affected_versions":"<1.2.3"},{"fix":"Always use `!copy` when you need an independent instance of an object or value, ensuring that modifications to one do not unexpectedly alter others.","message":"The `!ref` tag creates a shallow reference to the original YAML node, meaning changes to the referenced object will affect all references. If a deep copy is desired, use the `!copy` tag instead.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to HyperPyYAML 1.2.3 or higher for full Python 3.8+ compatibility.","message":"Older versions of HyperPyYAML had issues with Python 3.8+ compatibility, particularly concerning `ast.Constant`.","severity":"deprecated","affected_versions":"<1.2.3"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}