Пример #1
0
 def test_markdown_with_missing_metadata(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/text-embedding-model/1.md",
                           MARKDOWN_WITH_MISSING_METADATA)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                ".*missing.*fine-tunable.*module-type.*"):
     validator.validate_documentation_files(
         documentation_dir="root", filesystem=filesystem)
Пример #2
0
 def test_invalid_markdown_fails(self):
     filesystem = MockFilesystem()
     filesystem.set_contents("root/publisher/model/1.md",
                             "INVALID MARKDOWN")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*First line.*"):
         validator.validate_documentation_files(documentation_dir="root",
                                                filesystem=filesystem)
Пример #3
0
 def test_markdown_without_description(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/text-embedding-model/1.md",
                           MARKDOWN_WITHOUT_DESCRIPTION)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                ".*has to contain a short description.*"):
     validator.validate_documentation_files(
         documentation_dir="root", filesystem=filesystem)
Пример #4
0
 def test_publisher_markdown_at_incorrect_location_fails(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/publisher.md",
                           MINIMAL_PUBLISHER_MARKDOWN)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                r".*some-publisher\.md.*"):
     validator.validate_documentation_files(
         documentation_dir="root", filesystem=filesystem)
Пример #5
0
 def test_markdown_with_unexpected_lines(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/text-embedding-model/1.md",
                           MARKDOWN_WITH_UNEXPECTED_LINES)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                ".*Unexpected line.*"):
     validator.validate_documentation_files(
         documentation_dir="root", filesystem=filesystem)
Пример #6
0
 def test_minimal_markdown_does_not_end_with_md_fails(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/wrong-extension/1.mdz",
                           self.minimal_markdown)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                r".*end with \"\.md.\"*"):
     validator.validate_documentation_files(
         documentation_dir="root", filesystem=filesystem)
Пример #7
0
 def test_minimal_markdown_not_in_publisher_dir(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/gooogle/models/wrong-location/1.md",
                           self.minimal_markdown)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                ".*placed in the publisher directory.*"):
     validator.validate_documentation_files(
         documentation_dir="root", filesystem=filesystem)
Пример #8
0
 def test_markdown_with_unknown_license(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/model/1.md",
                           MINIMAL_MARKDOWN_WITH_UNKNOWN_LICENSE)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                ".*specify a license id from list.*"):
     validator.validate_documentation_files(
         documentation_dir="root", filesystem=filesystem)
 def test_minimal_collection_markdown_parsed(self):
   filesystem = MockFilesystem()
   filesystem.set_contents(
       "root/google/collections/text-embedding-collection/1.md",
       MINIMAL_COLLECTION_MARKDOWN)
   self.set_up_publisher_page(filesystem, "google")
   validator.validate_documentation_files(
       documentation_dir="root", filesystem=filesystem)
Пример #10
0
 def test_markdown_with_duplicate_metadata(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/text-embedding-model/1.md",
                           MARKDOWN_WITH_DUPLICATE_METADATA)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                ".*duplicate.*asset-path.*"):
     validator.validate_documentation_files(
         documentation_dir="root", filesystem=filesystem)
Пример #11
0
 def test_markdown_with_bad_module_type(self):
     filesystem = MockFilesystem()
     filesystem.set_contents("root/google/models/model/1.md",
                             MINIMAL_MARKDOWN_WITH_BAD_MODULE_TYPE)
     self.set_up_publisher_page(filesystem, "google")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*metadata has to start with.*"):
         validator.validate_documentation_files(documentation_dir="root",
                                                filesystem=filesystem)
Пример #12
0
 def test_fails_if_publisher_page_does_not_exist(self):
     filesystem = MockFilesystem()
     filesystem.set_contents(
         "root/publisher-without-page/models/text-embedding-model/1.md",
         MINIMAL_MARKDOWN_WITH_UNKNOWN_PUBLISHER)
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*Publisher documentation does not.*"):
         validator.validate_documentation_files(documentation_dir="root",
                                                filesystem=filesystem)
Пример #13
0
 def test_bad_model_does_not_pass_smoke_test(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/text-embedding-model/1.md",
                           self.minimal_markdown_with_bad_model)
   with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                ".*failed to parse.*"):
     validator.validate_documentation_files(
         documentation_dir="root",
         files_to_validate=["google/models/text-embedding-model/1.md"],
         filesystem=filesystem)
 def test_markdown_with_bad_handle(self):
   for markdown in [
       MARKDOWN_WITH_DOUBLE_SLASH_IN_HANDLE, MARKDOWN_WITH_BAD_CHARS_IN_HANDLE,
       MARKDOWN_WITH_MISSING_MODEL_IN_HANDLE
   ]:
     filesystem = MockFilesystem()
     filesystem.set_contents("root/google/models/model/1.md", markdown)
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*First line of the documentation*"):
       validator.validate_documentation_files(
           documentation_dir="root", filesystem=filesystem)
Пример #15
0
 def test_minimal_markdown_parsed_with_selected_files(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/text-embedding-model/1.md",
                           self.minimal_markdown)
   num_validated = validator.validate_documentation_files(
       documentation_dir="root",
       files_to_validate=["google/models/text-embedding-model/1.md"],
       filesystem=filesystem)
   self.assertEqual(1, num_validated)
Пример #16
0
 def test_publisher_markdown_at_correct_location(self):
     filesystem = MockFilesystem()
     self.set_up_publisher_page(filesystem, "some-publisher")
     validator.validate_documentation_files(documentation_dir="root",
                                            filesystem=filesystem)
Пример #17
0
 def test_minimal_publisher_markdown_parsed(self):
     filesystem = MockFilesystem()
     self.set_up_publisher_page(filesystem, "some-publisher")
     validator.validate_documentation_files(documentation_dir="root",
                                            filesystem=filesystem)
Пример #18
0
 def test_markdown_with_allowed_license(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/model/1.md",
                           MINIMAL_MARKDOWN_WITH_ALLOWED_LICENSE)
   validator.validate_documentation_files(
       documentation_dir="root", filesystem=filesystem)
Пример #19
0
 def test_publisher_markdown_at_correct_location(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/some-publisher/some-publisher.md",
                           MINIMAL_PUBLISHER_MARKDOWN)
   validator.validate_documentation_files(
       documentation_dir="root", filesystem=filesystem)
Пример #20
0
 def test_minimal_markdown_parsed(self):
   filesystem = MockFilesystem()
   filesystem.set_contents("root/google/models/text-embedding-model/1.md",
                           self.minimal_markdown)
   validator.validate_documentation_files(
       documentation_dir="root", filesystem=filesystem)