def maybe_download_ckpt_from_url(cfg):
    """If the checkpoint is an S3 or https path, the main process download the weight under, by default, `/tmp/`.

    NOTE: All workers must update `cfg.MODEL.CKPT` to use the new path.
    """
    ckpt_path = cfg.MODEL.CKPT

    if ckpt_path.startswith("s3://") or ckpt_path.startswith("https://"):
        os.makedirs(cfg.TMP_DIR, exist_ok=True)
        _, ext = os.path.splitext(ckpt_path)
        tmp_path = tempfile.NamedTemporaryFile(dir=cfg.TMP_DIR, suffix=ext).name

        LOG.info("Downloading initial weights:")
        LOG.info(f"  src: {ckpt_path}")
        LOG.info(f"  dst: {tmp_path}")

        if ckpt_path.startswith("s3://"):
            if not aws_credential_is_available():
                raise ValueError('AWS credentials are undefined in environment variables.')
            s3_copy(ckpt_path, tmp_path)
        else:  # https://
            req = requests.get(ckpt_path)
            with open(tmp_path, 'wb') as f:
                for chunk in tqdm(req.iter_content(100000)):
                    f.write(chunk)
        return tmp_path

    else:
        return ckpt_path
If the checkpoint is an S3 or https path, the main process download the weight under, by default, `/tmp/`.

    NOTE: All workers must update `cfg.MODEL.CKPT` to use the new path.
    
tridet/utils/s3.py