Skip to content

Commit

Permalink
Fix gated test (#2993)
Browse files Browse the repository at this point in the history
* Fix gated test

* Clean

* Finally, adjust test
  • Loading branch information
muellerzr authored Aug 6, 2024
1 parent 288accc commit 95edc68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/accelerate/commands/estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def verify_on_hub(repo: str, token: str = None):
"Verifies that the model is on the hub and returns the model info."
try:
return model_info(repo, token=token)
except GatedRepoError:
except (OSError, GatedRepoError):
return "gated"
except RepositoryNotFoundError:
return "repo"
Expand Down
5 changes: 4 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,10 @@ def test_no_metadata(self):
estimate_command(args)

def test_gated(self):
with self.assertRaises(GatedRepoError, msg="Repo for model `meta-llama/Llama-2-7b-hf` is gated"):
with self.assertRaises(
(GatedRepoError, EnvironmentError),
msg="Repo for model `meta-llama/Llama-2-7b-hf` is gated or environment error occurred",
):
args = self.parser.parse_args(["meta-llama/Llama-2-7b-hf"])
with patch_environment(hf_hub_disable_implicit_token="1"):
estimate_command(args)
Expand Down

0 comments on commit 95edc68

Please sign in to comment.