From 57c78f77c30186e1d4b91bda2c325fe3a03c8b51 Mon Sep 17 00:00:00 2001 From: calpt <36051308+calpt@users.noreply.github.com> Date: Wed, 29 Jun 2022 20:49:51 +0200 Subject: [PATCH 1/2] Avoid attempting to set head if non-existent --- src/transformers/adapters/heads/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/transformers/adapters/heads/base.py b/src/transformers/adapters/heads/base.py index d80db556d3..359ef8ae9c 100644 --- a/src/transformers/adapters/heads/base.py +++ b/src/transformers/adapters/heads/base.py @@ -642,10 +642,12 @@ def set_active_adapters( # use last adapter name as name of prediction head if self.active_adapters: head_setup = parse_heads_from_composition(self.active_adapters) - if head_setup: + if isinstance(head_setup, str): + head_setup = [head_setup] + if head_setup and all(head in self.heads for head in head_setup): self.active_head = head_setup else: - logger.info("Could not identify a valid prediction head from setup '{}'.".format(self.active_adapters)) + logger.info("Could not identify valid prediction head(s) from setup '{}'.".format(self.active_adapters)) def add_custom_head(self, head_type, head_name, overwrite_ok=False, set_active=True, **kwargs): if head_type in self.config.custom_heads: From 27b173d0812d83a1a53a5e4c55a6250a3dc50954 Mon Sep 17 00:00:00 2001 From: calpt <36051308+calpt@users.noreply.github.com> Date: Wed, 29 Jun 2022 21:01:30 +0200 Subject: [PATCH 2/2] style --- src/transformers/adapters/heads/base.py | 4 +++- src/transformers/dependency_versions_table.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/transformers/adapters/heads/base.py b/src/transformers/adapters/heads/base.py index 359ef8ae9c..251b2ffd43 100644 --- a/src/transformers/adapters/heads/base.py +++ b/src/transformers/adapters/heads/base.py @@ -647,7 +647,9 @@ def set_active_adapters( if head_setup and all(head in self.heads for head in head_setup): self.active_head = head_setup else: - logger.info("Could not identify valid prediction head(s) from setup '{}'.".format(self.active_adapters)) + logger.info( + "Could not identify valid prediction head(s) from setup '{}'.".format(self.active_adapters) + ) def add_custom_head(self, head_type, head_name, overwrite_ok=False, set_active=True, **kwargs): if head_type in self.config.custom_heads: diff --git a/src/transformers/dependency_versions_table.py b/src/transformers/dependency_versions_table.py index 07450986c1..7cac1371a7 100644 --- a/src/transformers/dependency_versions_table.py +++ b/src/transformers/dependency_versions_table.py @@ -21,7 +21,7 @@ "fugashi": "fugashi>=1.0", "GitPython": "GitPython<3.1.19", "hf-doc-builder": "hf-doc-builder>=0.3.0", - "huggingface-hub": "huggingface-hub>=0.1.0,<1.0", + "huggingface-hub": "huggingface-hub>=0.1.0,<0.8.0", "importlib_metadata": "importlib_metadata", "ipadic": "ipadic>=1.0.0,<2.0", "isort": "isort>=5.5.4",