from pathlib import Path
from typing import Dict
from typing import Any
import yaml


def read_metadata(path_job: Path) -> Dict[str, Any]:
    """Read the jobs metadata information from the job's workdir."""
    path_metadata = path_job / "metadata.yml"
    if not path_metadata.exists():
        msg = f"There is no file with metadata: {path_metadata}"
        raise FileNotFoundError(msg)
    with open(path_metadata, 'r') as handler:
        return yaml.load(handler.read(), Loader=yaml.FullLoader)