Simplify conditional code (#39781)
* Use != Signed-off-by: cyy <cyyever@outlook.com> * Use get Signed-off-by: cyy <cyyever@outlook.com> * Format * Simplify bool operations Signed-off-by: cyy <cyyever@outlook.com> --------- Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
@@ -1193,7 +1193,7 @@ def check_model_type_doc_match():
|
||||
model_docs = [m.stem for m in model_doc_folder.glob("*.md")]
|
||||
|
||||
model_types = list(transformers.models.auto.configuration_auto.MODEL_NAMES_MAPPING.keys())
|
||||
model_types = [MODEL_TYPE_TO_DOC_MAPPING[m] if m in MODEL_TYPE_TO_DOC_MAPPING else m for m in model_types]
|
||||
model_types = [MODEL_TYPE_TO_DOC_MAPPING.get(m, m) for m in model_types]
|
||||
|
||||
errors = []
|
||||
for m in model_docs:
|
||||
|
||||
@@ -1059,7 +1059,7 @@ if __name__ == "__main__":
|
||||
runner_not_available = False
|
||||
runner_failed = False
|
||||
# Some jobs don't depend (`needs`) on the job `setup`: in this case, the status of the job `setup` is `skipped`.
|
||||
setup_failed = False if setup_status in ["skipped", "success"] else True
|
||||
setup_failed = setup_status not in ["skipped", "success"]
|
||||
|
||||
org = "huggingface"
|
||||
repo = "transformers"
|
||||
|
||||
@@ -371,7 +371,7 @@ if __name__ == "__main__":
|
||||
file_path, test = line, line
|
||||
|
||||
job_result["failed"].append(test)
|
||||
failure = all_failures[test] if test in all_failures else "N/A"
|
||||
failure = all_failures.get(test, "N/A")
|
||||
job_result["failures"][test] = failure
|
||||
|
||||
# Save and to be uploaded as artifact
|
||||
|
||||
@@ -1057,9 +1057,9 @@ def infer_tests_to_run(
|
||||
test_files_to_run.extend(test_map[f])
|
||||
test_files_to_run = sorted(set(test_files_to_run))
|
||||
# Remove repo utils tests
|
||||
test_files_to_run = [f for f in test_files_to_run if not f.split(os.path.sep)[1] == "repo_utils"]
|
||||
test_files_to_run = [f for f in test_files_to_run if f.split(os.path.sep)[1] != "repo_utils"]
|
||||
# Remove SageMaker tests
|
||||
test_files_to_run = [f for f in test_files_to_run if not f.split(os.path.sep)[1] == "sagemaker"]
|
||||
test_files_to_run = [f for f in test_files_to_run if f.split(os.path.sep)[1] != "sagemaker"]
|
||||
# Make sure we did not end up with a test file that was removed
|
||||
test_files_to_run = [f for f in test_files_to_run if (PATH_TO_REPO / f).exists()]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user