docs: def restore_artifact(src_path: str, artifact_hash: str, conf: Config):
      """Restore the artifact whose hash is `artifact_hash` to `src_path`.
  
      Return True if cached artifact is found, valid, and restored successfully.
      Otherwise return False.
      """
      cache_dir = conf.get_artifacts_cache_dir()
      if not isdir(cache_dir):
          return False
      cached_artifact_path = join(cache_dir, artifact_hash)
      if isfile(cached_artifact_path) or isdir(cached_artifact_path):
          # verify cached item hash matches expected hash
          actual_hash = hash_tree(cached_artifact_path)
          if actual_hash != artifact_hash:
              logger.warning(
                  'Cached artifact {} expected hash {} != actual hash {}',
                  src_path, artifact_hash, actual_hash)
              rmnode(cached_artifact_path)
              return False
          # if something exists in src_path, check if it matches the cached item
          abs_src_path = join(conf.project_root, src_path)
          if isfile(abs_src_path) or isdir(abs_src_path):
              existing_hash = hash_tree(src_path)
              if existing_hash == artifact_hash:
                  logger.debug('Existing artifact {} matches cached hash {}',
                               src_path, artifact_hash)
                  return True
              logger.debug('Replacing existing artifact {} with cached one',
                           src_path)
              rmnode(abs_src_path)
          logger.debug('Restoring cached artifact {} to {}',
                       artifact_hash, src_path)
          shutil.copy(cached_artifact_path, abs_src_path)
          return True
      logger.debug('No cached artifact for {} with hash {}',
                   src_path, artifact_hash)
      return False