code: def _cli_check_data_dir(data_dir):
      '''Checks that the data dir exists and contains METADATA.json'''
  
      if data_dir is None:
          return None
  
      data_dir = os.path.expanduser(data_dir)
      data_dir = os.path.expandvars(data_dir)
      if not os.path.isdir(data_dir):
          raise RuntimeError("Data directory '{}' does not exist or is not a directory".format(data_dir))
      if not os.path.isfile(os.path.join(data_dir, 'METADATA.json')):
          raise RuntimeError("Data directory '{}' does not contain a METADATA.json file".format(data_dir))
  
      return data_dif _cli_check_data_dir(data_dir):
      '''Checks that the data dir exists and contains METADATA.json'''
  
      if data_dir is None:
          return None
  
      data_dir = os.path.expanduser(data_dir)
      data_dir = os.path.expandvars(data_dir)
      if not os.path.isdir(data_dir):
          raise RuntimeError("Data directory '{}' does not exist or is not a directory".format(data_dir))
      if not os.path.isfile(os.path.join(data_dir, 'METADATA.json')):
          raise RuntimeError("Data directory '{}' does not contain a METADATA.json file".format(data_dir))
  
      return data_dir
docs: Checks that the data dir exists and contains METADATA.json