Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure root dir exists when saving all adapters/heads/fusions. #375

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/transformers/adapters/model_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ def save_all_adapters(
Args:
save_directory (str): Path to a directory where the adapters should be saved.
"""
os.makedirs(save_directory, exist_ok=True)
for name in self.config.adapters:
adapter_config = self.config.adapters.get(name)
h = get_adapter_config_hash(adapter_config)
Expand All @@ -705,6 +706,7 @@ def save_all_adapter_fusions(
Args:
save_directory (str): Path to a directory where the AdapterFusion layers should be saved.
"""
os.makedirs(save_directory, exist_ok=True)
for name in self.config.adapters.fusions:
adapter_fusion_config = self.config.adapters.get_fusion(name)
h = get_adapter_config_hash(adapter_fusion_config)
Expand Down Expand Up @@ -1033,6 +1035,7 @@ def save_all_adapters(
meta_dict: dict = None,
custom_weights_loaders: Optional[List[WeightsLoader]] = None,
):
os.makedirs(save_directory, exist_ok=True)
for name in self.config.adapters:
adapter_config = self.config.adapters.get(name)
h = get_adapter_config_hash(adapter_config)
Expand Down Expand Up @@ -1104,6 +1107,7 @@ def load_adapter_fusion(
super().load_adapter_fusion(adapter_fusion_name_or_path, load_as, custom_weights_loaders, set_active)

def save_all_heads(self, save_directory):
os.makedirs(save_directory, exist_ok=True)
for head_name in self.heads:
save_path = join(save_directory, head_name)
self.save_head(save_path, head_name)
Expand Down