yaml_loader
utils.yaml_loader
YAML loader wrapper used by every Network.from_file / SimulationExperiment.from_file / SimulationStudy.from_file entry point in TVBO.
Extends :class:linkml_runtime.utils.yamlutils.DupCheckYamlLoader (the default LinkML loader, which already disallows duplicate keys) with two generally-useful YAML idioms:
Merge keys (
<<: *anchor) — standard YAML 1.1 semantics. Lets an inline override reuse another block with one slot changed:.. code-block:: yaml
kuramoto_10hz: &kuramoto_10hz name: Kuramoto parameters: {omega: 0.0628} kuramoto_20hz: <<: *kuramoto_10hz parameters: {omega: 0.1257}!include— substitute the value at a directive’s position with the contents of another YAML file. Paths are resolved relative to the directory of the file containing the directive; absolute paths are accepted as-is. Anchors in the included document are scoped to that document only (each include uses a fresh loader instance), so fragments are readable in isolation... code-block:: yaml
experiments: - !include _experiments/exp1.yaml - !include _experiments/exp2.yaml
Both idioms are pure data-format machinery; they don’t introduce any TVBO-specific semantics into user YAMLs. The wrapper is transparent — any LinkML class can still load through yaml_loader.load and get back the same datamodel instance it would have produced before.
Functions
| Name | Description |
|---|---|
| load | Drop-in replacement for linkml_runtime.loaders.yaml_loader.load. |
| load_as_dict | Drop-in replacement for yaml_loader.load_as_dict. |
| loads | Drop-in replacement for linkml_runtime.loaders.yaml_loader.loads. |
load
utils.yaml_loader.load(source, target_class, **kwargs)Drop-in replacement for linkml_runtime.loaders.yaml_loader.load.
Accepts the same arguments as the LinkML loader. Expands TVBO YAML extensions (<<: merge keys, !include) before delegating to LinkML’s constructor-class machinery. Relative !include paths are resolved against the directory of source when source is a path; otherwise against the current working directory.
load_as_dict
utils.yaml_loader.load_as_dict(source, **kwargs)Drop-in replacement for yaml_loader.load_as_dict.
Returns a plain Python dict (or list of dicts) after applying the TVBO YAML extensions. Useful for callers that need to inspect or mutate the parsed structure before handing it to LinkML.
loads
utils.yaml_loader.loads(source, target_class, **kwargs)Drop-in replacement for linkml_runtime.loaders.yaml_loader.loads.