loader
loader
¶
Instrument profile loader.
Scans directories for YAML instrument profiles and parses them into validated InstrumentProfile instances. This is the entry point for the instrument plugin system — the conductor calls the loader at startup to discover available instruments.
Loading order matters
- Built-in profiles (shipped with Marianne, lowest precedence)
- Organization profiles (~/.marianne/instruments/)
- Venue profiles (.marianne/instruments/, highest precedence)
Later directories override earlier ones on name collision. This lets venue-specific profiles customize organization-wide defaults, which in turn customize built-in defaults.
Invalid YAML files, validation failures, and other errors are logged and skipped — one broken profile should not prevent other instruments from loading. This is a reliability-first design: degrade gracefully, log clearly, continue operating.
Usage
from marianne.instruments.loader import InstrumentProfileLoader
profiles = InstrumentProfileLoader.load_directories([ Path.home() / ".marianne" / "instruments", Path(".marianne/instruments"), ])
Classes¶
InstrumentProfileLoader
¶
Loads InstrumentProfile instances from YAML files in directories.
The loader is deliberately simple: scan a directory for YAML files, parse each one, validate via Pydantic, and collect the results. No recursion into subdirectories. No implicit file discovery magic.
Error handling: every failure is logged with the file path and reason. The loader continues past failures — one broken YAML file should not prevent other instruments from loading.
Functions¶
load_directory
staticmethod
¶
Load all instrument profiles from a single directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Path to scan for .yaml and .yml files. If the directory does not exist, returns empty dict. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, InstrumentProfile]
|
Dict of profile name → InstrumentProfile. When two files in |
dict[str, InstrumentProfile]
|
the same directory define the same name, the last one |
dict[str, InstrumentProfile]
|
(alphabetically by filename) wins. |
Source code in src/marianne/instruments/loader.py
load_directories
staticmethod
¶
Load profiles from multiple directories with override semantics.
Later directories override earlier ones on name collision. The intended loading order: 1. Built-in profiles (lowest precedence) 2. Organization profiles (~/.marianne/instruments/) 3. Venue profiles (.marianne/instruments/, highest precedence)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directories
|
list[str | Path]
|
Ordered list of directories to scan. Missing directories are silently skipped. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, InstrumentProfile]
|
Merged dict of profile name → InstrumentProfile. |
Source code in src/marianne/instruments/loader.py
Functions¶
load_all_profiles
¶
Load all instrument profiles from all standard sources.
Convenience function that encapsulates the standard loading order
- Native instruments (4 built-in backends)
- Built-in YAML profiles (shipped with Marianne)
- Organization profiles (~/.marianne/instruments/)
- Venue profiles (.marianne/instruments/)
Later sources override earlier ones on name collision.
Returns:
| Type | Description |
|---|---|
dict[str, InstrumentProfile]
|
Dict of profile name → InstrumentProfile. |