INNER CODE UNIT · Python

normalize_key

awslabs/awsome-distributed-ai · .github/scripts/stage-template-publish.py:55

def normalize_key(key: str) -> str:
    key = key.strip().lstrip("/")
    if not key:
        raise ValueError("empty S3 key")
    if ".." in Path(key).parts:
        raise ValueError(f"destination key must not contain '..': {key}")
    if not S3_KEY_RE.match(key):
        raise ValueError(f"destination key contains unsupported characters: {key}")
    return key


def load_manifest(path: Path) -> dict[str, Any]:
    data = load_yaml(path)
    if not isinstance(data, dict):
        raise ValueError("manifest must be a YAML mapping")
    entries = data.get("entries")
    if not isinstance(entries, list) or not entries:
        raise ValueError("manifest must contain a non-empty entries list")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…