Skip to content

Commit 3774010

Browse files
authored
Automate check for new pipelines and metadata update (#19029)
* Automate check for new pipelines and metadata update * Add Datasets to quality extra
1 parent 0efbb6e commit 3774010

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ jobs:
982982
- run: python utils/check_config_docstrings.py
983983
- run: make deps_table_check_updated
984984
- run: python utils/tests_fetcher.py --sanity_check
985+
- run: python utils/update_metadata.py --check-only
985986

986987
run_tests_layoutlmv2_and_v3:
987988
working_directory: ~/transformers

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ repo-consistency:
4141
python utils/check_inits.py
4242
python utils/check_config_docstrings.py
4343
python utils/tests_fetcher.py --sanity_check
44+
python utils/update_metadata.py --check-only
4445

4546
# this target runs checks on all files
4647

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def run(self):
307307

308308
extras["deepspeed-testing"] = extras["deepspeed"] + extras["testing"] + extras["optuna"]
309309

310-
extras["quality"] = deps_list("black", "isort", "flake8", "GitPython", "hf-doc-builder")
310+
extras["quality"] = deps_list("black", "datasets", "isort", "flake8", "GitPython", "hf-doc-builder")
311311

312312
extras["all"] = (
313313
extras["tf"]

utils/update_metadata.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
"MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES",
8686
"AutoModelForDocumentQuestionAnswering",
8787
),
88+
(
89+
"visual-question-answering",
90+
"MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING_NAMES",
91+
"AutoModelForVisualQuestionAnswering",
92+
),
93+
("image-to-text", "MODEL_FOR_FOR_VISION_2_SEQ_MAPPING_NAMES", "AutoModelForVision2Seq"),
8894
]
8995

9096

@@ -236,10 +242,35 @@ def update_metadata(token, commit_sha):
236242
repo.push_to_hub(commit_message)
237243

238244

245+
def check_pipeline_tags():
246+
in_table = {tag: cls for tag, _, cls in PIPELINE_TAGS_AND_AUTO_MODELS}
247+
pipeline_tasks = transformers_module.pipelines.SUPPORTED_TASKS
248+
missing = []
249+
for key in pipeline_tasks:
250+
if key not in in_table:
251+
model = pipeline_tasks[key]["pt"]
252+
if isinstance(model, (list, tuple)):
253+
model = model[0]
254+
model = model.__name__
255+
if model not in in_table.values():
256+
missing.append(key)
257+
258+
if len(missing) > 0:
259+
msg = ", ".join(missing)
260+
raise ValueError(
261+
"The following pipeline tags are not present in the `PIPELINE_TAGS_AND_AUTO_MODELS` constant inside "
262+
f"`utils/update_metadata.py`: {msg}. Please add them!"
263+
)
264+
265+
239266
if __name__ == "__main__":
240267
parser = argparse.ArgumentParser()
241268
parser.add_argument("--token", type=str, help="The token to use to push to the transformers-metadata dataset.")
242269
parser.add_argument("--commit_sha", type=str, help="The sha of the commit going with this update.")
270+
parser.add_argument("--check-only", action="store_true", help="Activate to just check all pipelines are present.")
243271
args = parser.parse_args()
244272

245-
update_metadata(args.token, args.commit_sha)
273+
if args.check_only:
274+
check_pipeline_tags()
275+
else:
276+
update_metadata(args.token, args.commit_sha)

0 commit comments

Comments
 (0)