MCPcopy
hub / github.com/nari-labs/dia / load

Method load

dia/config.py:157–176  ·  view source on GitHub ↗

Load and validate a Dia configuration from a JSON file. Args: path: The path to the configuration file. Returns: A validated DiaConfig instance if the file exists and is valid, otherwise None if the file is not found. Raises:

(cls, path: str)

Source from the content-addressed store, hash-verified

155
156 @classmethod
157 def load(cls, path: str) -> "DiaConfig | None":
158 """Load and validate a Dia configuration from a JSON file.
159
160 Args:
161 path: The path to the configuration file.
162
163 Returns:
164 A validated DiaConfig instance if the file exists and is valid,
165 otherwise None if the file is not found.
166
167 Raises:
168 ValueError: If the path does not point to an existing .json file.
169 pydantic.ValidationError: If the JSON content fails validation against the DiaConfig schema.
170 """
171 try:
172 with open(path, "r") as f:
173 content = f.read()
174 return cls.model_validate_json(content)
175 except FileNotFoundError:
176 return None

Callers 3

from_localMethod · 0.80
_load_dac_modelMethod · 0.80
load_audioMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected