Example #1
0
    def test_givenAIntCheckpoint_whenHandleCheckpoint_thenReturn1(self):
        checkpoint = 1

        actual = handle_checkpoint(checkpoint)
        expected = checkpoint

        self.assertEqual(actual, expected)
Example #2
0
    def test_givenAStringCheckpoint_whenHandleCheckpoint_thenReturnSamePath(self):
        pickle_checkpoint = "/a/path/to/a/model.ckpt"

        actual = handle_checkpoint(pickle_checkpoint)
        expected = pickle_checkpoint

        self.assertEqual(actual, expected)
Example #3
0
    def test_givenALastCheckpoint_whenHandleCheckpoint_thenReturnLast(self):
        checkpoint = "last"

        actual = handle_checkpoint(checkpoint)
        expected = checkpoint

        self.assertEqual(actual, expected)
Example #4
0
    def test_givenABPEmbCheckpoint_whenHandleCheckpoint_thenReturnCachedBPEmbPath(self, latest_version_check):
        checkpoint = "bpemb"

        actual = handle_checkpoint(checkpoint)
        expected = os.path.join(CACHE_PATH, checkpoint + ".ckpt")

        self.assertEqual(actual, expected)
Example #5
0
    def test_givenBadNamesCheckpoint_whenHandleCheckpoint_thenRaiseErrors(
            self):
        with self.assertRaises(ValueError):
            bad_best_checkpoint = "bests"
            handle_checkpoint(bad_best_checkpoint)

        with self.assertRaises(ValueError):
            bad_last_checkpoint = "lasts"
            handle_checkpoint(bad_last_checkpoint)

        with self.assertRaises(ValueError):
            string_int_bad_checkpoint = "1"
            handle_checkpoint(string_int_bad_checkpoint)

        with self.assertRaises(ValueError):
            bad_fasttext_checkpoint = "fasttexts"
            handle_checkpoint(bad_fasttext_checkpoint)

        with self.assertRaises(ValueError):
            bad_bpemb_checkpoint = "bpembds"
            handle_checkpoint(bad_bpemb_checkpoint)

        with self.assertRaises(ValueError):
            bad_pickle_extension_checkpoint = "/a/path/to/a/model.pck"
            handle_checkpoint(bad_pickle_extension_checkpoint)