Exemple #1
0
    def _check_directory(self,
                         listname,
                         thing_list,
                         thing_dir,
                         thing_key,
                         ignore=None):
        if ignore is None:
            ignore = []
        dirs = testing_utils.git_ls_dirs()
        # get only directories directly in the thing directory
        dirs = [d for d in dirs if os.path.dirname(d) == thing_dir]
        # just the folder names
        dirs = [os.path.basename(d) for d in dirs]
        # skip the allowlist
        dirs = [d for d in dirs if d not in ignore]
        # make it a set
        dirs = set(dirs)

        # and the list of thing names
        thing_names = {thing[thing_key].split(':')[0] for thing in thing_list}

        errors = []
        # items with a directory but not a listing
        for name in dirs - thing_names:
            errors.append("Directory {}/{} exists, but isn't in {}".format(
                thing_dir, name, listname))
        for name in thing_names - dirs:
            errors.append(
                "{} exists in {}, but {}/{} isn't a directory".format(
                    name, listname, thing_dir, name))

        if errors:
            self.assertTrue(False, "\n".join(errors))
Exemple #2
0
 def test_init_everywhere(self):
     for folder_path in testing_utils.git_ls_dirs('parlai'):
         excluded_folders = [
             'conf',
             'frontend',
             'mturk',
             'task_config',
             'webapp',
             'opt_presets',
         ]
         # conf: contains YAML files for Hydra
         # frontend, mturk, webapp: contains frontend code for crowdsourcing tasks
         # task_config: contains JSONs, HTML files, etc. for MTurk/Mephisto tasks
         if any(folder_name in folder_path
                for folder_name in excluded_folders):
             continue
         if folder_path.endswith("test") and folder_path.startswith(
                 "parlai/tasks/"):
             # yml regression files in parlai/tasks/X/test/
             continue
         self.assertIn(
             '__init__.py',
             os.listdir(folder_path),
             '{} does not contain __init__.py'.format(folder_path),
         )
Exemple #3
0
 def test_init_everywhere(self):
     for folder in testing_utils.git_ls_dirs('parlai'):
         if 'mturk' in folder:
             continue
         self.assertIn(
             '__init__.py',
             os.listdir(folder),
             '{} does not contain __init__.py'.format(folder),
         )
Exemple #4
0
 def test_init_everywhere(self):
     for folder_path in testing_utils.git_ls_dirs('parlai'):
         excluded_folders = ['mturk', 'webapp']
         if any(folder_name in folder_path for folder_name in excluded_folders):
             continue
         self.assertIn(
             '__init__.py',
             os.listdir(folder_path),
             '{} does not contain __init__.py'.format(folder_path),
         )
Exemple #5
0
 def test_init_everywhere(self):
     for folder_path in testing_utils.git_ls_dirs('parlai'):
         excluded_folders = ['conf', 'mturk', 'task_config', 'webapp']
         # conf: contains YAML files for Hydra
         # task_config: contains JSONs, HTML files, etc. for MTurk/Mephisto tasks
         if any(folder_name in folder_path for folder_name in excluded_folders):
             continue
         self.assertIn(
             '__init__.py',
             os.listdir(folder_path),
             '{} does not contain __init__.py'.format(folder_path),
         )