from typing import Union
import pathlib
from typing import Dict
from typing import Any
import json


def load(file_path_string: Union[str, pathlib.Path]) -> Dict[str, Any]:
    """Loads a workspace from a file.

    Args:
        file_path_string (Union[str, pathlib.Path]): path to the file to load the
            workspace from

    Returns:
        Dict[str, Any]: ``pyhf``-compatible `HistFactory` workspace
    """
    file_path = pathlib.Path(file_path_string)
    ws = json.loads(file_path.read_text())
    return ws