from datetime import datetime


def make_output_dir_name(args):
    """Constructs a unique name for a directory in ./output using
    current time and script arguments"""
    prefix = datetime.now().strftime('%Y%m%d-%H%M')
    dir_name = f'./output/{prefix}_epochs={args.epochs}_lr={args.lr}'
    dir_name += '_with-pretrained-backbone' if args.pretrained_backbone else '_no-pretrained-backbone'

    if args.no_geometry_loss:
        dir_name += '_no-geometry-loss'
    if args.resume:
        # Extract date prefix from checkpoint path:
        # e.g. 20210320-1439 in output/20210320-1439_epochs=1_lr=0.005/checkpoint.pth
        dir_name += f'_resume={str(args.resume.parent.name).split("_")[0]}'
    return dir_name