def main(args=None) -> None: """ CLI function to manually download all the dependencies for a pre-trained model. Example of usage: .. code-block:: sh download_model fasttext """ if args is None: args = sys.argv[1:] parsed_args = get_args(args) model_type = parsed_args.model_type if "fasttext" in model_type and "fasttext-light" not in model_type: download_fasttext_embeddings(saving_dir=CACHE_PATH) elif model_type == "fasttext-light": download_fasttext_magnitude_embeddings(saving_dir=CACHE_PATH) elif "bpemb" in model_type: BPEmb( lang="multi", vs=100000, dim=300 ) # The class manage the download of the pre-trained words embedding model_path = os.path.join(CACHE_PATH, f"{model_type}.ckpt") version_path = os.path.join(CACHE_PATH, f"{model_type}.version") if not os.path.isfile(model_path) or not os.path.isfile(version_path): download_weights(model_type, CACHE_PATH) elif not latest_version(model_type, cache_path=CACHE_PATH): print( "A new version of the pre-trained model is available. The newest model will be downloaded." ) download_weights(model_type, CACHE_PATH)
def test_givenABPEmbNotTheLatestVersion_whenVerifyIfLastVersion_thenReturnFalse( self, ): self.create_cache_version("bpemb", "not_the_last_version") self.assertFalse(latest_version("bpemb", self.fake_cache_path))
def test_givenABPEmbLatestVersion_whenVerifyIfLastVersion_thenReturnTrue( self): self.create_cache_version("bpemb", self.latest_bpemb_version) self.assertTrue(latest_version("bpemb", self.fake_cache_path))
def test_givenAFasttextLatestVersion_whenVerifyIfLastVersion_thenReturnTrue( self): self.create_cache_version("fasttext", self.latest_fasttext_version) self.assertTrue(latest_version("fasttext", self.fake_cache_path))
def test_givenAFasttextNotTheLatestVersion_whenVerifyIfLastVersion_thenReturnFalse( self): self.create_cache_version("fasttext", "not_the_last_version") self.assertFalse(latest_version("fasttext", self.fake_cache_path))