from pathlib import Path
from typing import Union
from typing import Optional


def get_sample_fp(sample_dir: Path,
                  ckpt_path: Union[Path,str],
                  prefix: Optional[str] = None) -> Path:
    """Returns the file-path to the pickled file of sample,
    generated from the model at ckpt_path state"""
    if isinstance(ckpt_path, str):
        ckpt_path = Path(ckpt_path)
    prefix = '' if prefix is None else f'{prefix}-'
    fp = sample_dir/f'{prefix}{ckpt_path.stem}.pkl'
    return fp