INNER CODE UNIT · Python
validate_references
awslabs/awsome-distributed-ai · .github/scripts/stage-template-publish.py:91
def validate_references(cfn_sources: list[Path], destination_keys: set[str]) -> list[str]:
errors: list[str] = []
for source in cfn_sources:
text = source.read_text(encoding="utf-8")
refs = set(PREFIX_REF_RE.findall(text)) | set(PUBLIC_URL_RE.findall(text))
namespace = architecture_namespace(source)
for ref in sorted(refs):
namespaced_ref = f"{namespace}/{ref}" if namespace else None
if ref not in destination_keys and namespaced_ref not in destination_keys:
errors.append(f"{source}: references '{ref}', but no manifest entry publishes that key")
return errors
def write_list(path: Path, files: list[Path]) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("".join(f"{file}\n" for file in files), encoding="utf-8")