MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / normalize_submodule_declarations

Function normalize_submodule_declarations

src/harness/submodules/loader.py:9–37  ·  view source on GitHub ↗

Normalize submodule declarations from YAML data to a standard format.

(
    yaml_data: Dict[str, Any],
    yaml_file_path: str,
)

Source from the content-addressed store, hash-verified

7
8
9def normalize_submodule_declarations(
10 yaml_data: Dict[str, Any],
11 yaml_file_path: str,
12) -> List[Dict[str, Any]]:
13 """Normalize submodule declarations from YAML data to a standard format."""
14 submodules = yaml_data.get("submodules", [])
15 if not submodules:
16 return []
17 if isinstance(submodules, dict):
18 submodules = [{"name": name, "path": path} for name, path in submodules.items()]
19 if not isinstance(submodules, list):
20 raise ValueError("submodules must be a list or mapping")
21
22 base_dir = Path(yaml_file_path).resolve().parent
23 normalized = []
24 for entry in submodules:
25 if isinstance(entry, str):
26 entry = {"path": entry}
27 if not isinstance(entry, dict):
28 raise ValueError("Each submodule entry must be a mapping or string path")
29 name = entry.get("name")
30 path = entry.get("path") or entry.get("file") or entry.get("filepath")
31 if not path:
32 raise ValueError("Submodule entry must include a file path")
33 module_path = (
34 str((base_dir / path).resolve()) if not os.path.isabs(path) else path
35 )
36 normalized.append({"name": name, "path": module_path})
37 return normalized
38
39
40def parse_submodule_function_declaration(

Callers 9

test_empty_submodulesMethod · 0.90
test_list_formatMethod · 0.90
test_dict_formatMethod · 0.90
test_string_formatMethod · 0.90
_collect_submodule_pathsFunction · 0.85

Calls 2

getMethod · 0.80
resolveMethod · 0.80

Tested by 7

test_empty_submodulesMethod · 0.72
test_list_formatMethod · 0.72
test_dict_formatMethod · 0.72
test_string_formatMethod · 0.72