예제 #1
0
def push(args: argparse.Namespace):
    push_to_hf(
        args.repo_name,
        serialization_dir=args.serialization_dir,
        archive_path=args.archive_path,
        organization=args.organization,
        commit_message=args.commit_message,
        local_repo_path=args.local_repo_path,
    )
예제 #2
0
 def test_push_to_hub_fails_with_invalid_token(self):
     serialization_dir = self.FIXTURES_ROOT / "simple_tagger" / "serialization"
     with pytest.raises(requests.exceptions.HTTPError):
         push_to_hf(
             repo_name=REPO_NAME,
             serialization_dir=serialization_dir,
             local_repo_path=self.local_repo_path,
             use_auth_token="invalid token",
         )
예제 #3
0
    def test_push_to_hub_serialization_dir(self):
        serialization_dir = self.FIXTURES_ROOT / "simple_tagger" / "serialization"
        url = push_to_hf(
            repo_name=REPO_NAME,
            serialization_dir=serialization_dir,
            local_repo_path=self.local_repo_path,
            use_auth_token=self.token,
        )

        # Check that the returned commit url
        # actually exists.
        r = requests.head(url)
        r.raise_for_status()

        Repository(
            self.clone_path,
            clone_from=f"{ENDPOINT_STAGING}/{USER}/{REPO_NAME}",
            use_auth_token=self.token,
        )
        assert "model.th" in os.listdir(self.clone_path)
        shutil.rmtree(self.clone_path)