Beispiel #1
0
 def test_minimal_markdown_does_not_end_with_md_fails(self):
     self.set_content("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=self.tmp_root_dir)
Beispiel #2
0
 def test_publisher_markdown_at_incorrect_location_fails(self):
     self.set_content("root/google/publisher.md",
                      MINIMAL_PUBLISHER_MARKDOWN % "some-publisher")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  r".*some-publisher\.md.*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #3
0
 def test_markdown_with_forbidden_duplicate_metadata(self):
     self.set_content("root/google/models/text-embedding-model/1.md",
                      MARKDOWN_WITH_FORBIDDEN_DUPLICATE_METADATA)
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*duplicate.*asset-path.*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #4
0
 def test_markdown_with_unexpected_lines(self):
     self.set_content("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=self.tmp_root_dir)
Beispiel #5
0
 def test_minimal_markdown_not_in_publisher_dir(self):
     self.set_content("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=self.tmp_root_dir)
Beispiel #6
0
 def test_markdown_with_missing_metadata(self):
     self.set_content("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=self.tmp_root_dir)
Beispiel #7
0
 def test_minimal_markdown_parsed_with_selected_files(self):
     self.set_content(
         "root/assets/docs/google/models/text-embedding-model/1.md",
         self.minimal_markdown)
     self.set_up_publisher_page("google")
     validator.validate_documentation_files(
         root_dir=self.tmp_root_dir,
         files_to_validate=["google/models/text-embedding-model/1.md"])
Beispiel #8
0
 def test_fails_if_publisher_page_does_not_exist(self):
     self.set_content(
         "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=self.tmp_root_dir)
Beispiel #9
0
 def test_markdown_with_unknown_license(self):
     self.set_content("root/google/models/model/1.md",
                      MINIMAL_MARKDOWN_WITH_UNKNOWN_LICENSE)
     self.set_up_publisher_page("google")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*specify a license id from list.*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #10
0
 def test_markdown_with_bad_module_type(self):
     self.set_content("root/google/models/model/1.md",
                      MINIMAL_MARKDOWN_WITH_BAD_MODULE_TYPE)
     self.set_up_publisher_page("google")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*metadata has to start with.*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #11
0
 def test_markdown_with_unsupported_format_metadata(self):
     self.set_content("root/google/models/text-embedding-model/1.md",
                      MINIMAL_MARKDOWN_WITH_UNSUPPORTED_FORMAT)
     with self.assertRaisesRegexp(
             validator.MarkdownDocumentationError,
             "The 'format' metadata.*but "
             "was 'unsupported'."):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #12
0
 def test_markdown_with_forbidden_format_metadata(self):
     self.set_content("root/google/models/model/1.md",
                      MINIMAL_MARKDOWN_LITE_WITH_FORBIDDEN_FORMAT)
     self.set_up_publisher_page("google")
     with self.assertRaisesRegexp(
             validator.MarkdownDocumentationError,
             r".*contains unsupported metadata properties: \['format'\].*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #13
0
 def test_asset_path_is_legacy_and_modified(self):
     self.set_content("root/google/models/text-embedding-model/1.md",
                      MARKDOWN_WITH_LEGACY_TAG)
     self.set_up_publisher_page("google")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*failed to parse.*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir,
             files_to_validate=["google/models/text-embedding-model/1.md"],
         )
Beispiel #14
0
 def test_bad_model_does_not_pass_smoke_test(self):
     self.set_content("root/google/models/text-embedding-model/1.md",
                      self.minimal_markdown_with_bad_model)
     self.set_up_publisher_page("google")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*failed to parse.*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir,
             files_to_validate=["google/models/text-embedding-model/1.md"],
         )
Beispiel #15
0
 def test_markdown_parsed_saved_model(self):
     for markdown in [
             self.minimal_markdown, self.maximal_markdown,
             MARKDOWN_WITH_EMPTY_SECOND_LINE % self.model_path
     ]:
         self.set_up_publisher_page("google")
         self.set_content("root/google/models/text-embedding-model/1.md",
                          markdown)
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #16
0
 def test_collection_markdown_parsed(self):
     self.set_up_publisher_page("google")
     for markdown in [
             MINIMAL_COLLECTION_MARKDOWN, MAXIMAL_COLLECTION_MARKDOWN
     ]:
         self.set_content(
             "root/google/collections/text-embedding-collection/1.md",
             markdown)
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #17
0
 def test_markdown_parsed_placeholder(self):
     self.set_up_publisher_page("google")
     for markdown in [
             MINIMAL_MARKDOWN_PLACEHOLDER_TEMPLATE,
             MAXIMAL_MARKDOWN_PLACEHOLDER_TEMPLATE
     ]:
         self.set_content("root/google/models/text-embedding-model/1.md",
                          markdown)
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #18
0
 def test_asset_path_is_github_download_url_test(self):
     self.set_content(
         "root/google/models/text-embedding-model/1.md",
         MINIMAL_MARKDOWN_SAVED_MODEL_TEMPLATE %
         "https://github.com/some_repo/releases/download/some_path")
     self.set_up_publisher_page("google")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*cannot be automatically fetched.*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir,
             files_to_validate=["google/models/text-embedding-model/1.md"],
         )
Beispiel #19
0
 def test_markdown_without_description(self):
     for markdown in [
             MARKDOWN_WITHOUT_DESCRIPTION,
             MARKDOWN_WITHOUT_DESCRIPTION_WITHOUT_LINEBREAK
     ]:
         self.set_content("root/google/models/text-embedding-model/1.md",
                          markdown)
         with self.assertRaisesRegexp(
                 validator.MarkdownDocumentationError,
                 ".*has to contain a short description.*"):
             validator.validate_documentation_files(
                 documentation_dir=self.tmp_root_dir)
Beispiel #20
0
 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,
             MARKDOWN_WITH_MISSING_VERSION_IN_HANDLE
     ]:
         self.set_content("root/google/models/model/1.md", markdown)
         with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                      ".*First line of the documentation*"):
             validator.validate_documentation_files(
                 documentation_dir=self.tmp_root_dir)
Beispiel #21
0
 def test_asset_path_is_legacy_and_unmodified(self):
     self.asset_path_modified = mock.patch.object(
         validator.DocumentationParser,
         "_is_asset_path_modified",
         return_value=False)
     self.asset_path_modified.start()
     self.set_content("root/google/models/text-embedding-model/1.md",
                      MARKDOWN_WITH_LEGACY_TAG)
     self.set_up_publisher_page("google")
     validator.validate_documentation_files(
         documentation_dir=self.tmp_root_dir,
         files_to_validate=["google/models/text-embedding-model/1.md"],
     )
Beispiel #22
0
 def test_markdown_with_unsupported_metadata(self):
     self.set_up_publisher_page("google")
     for markdown in [
             MARKDOWN_SAVED_MODEL_UNSUPPORTED_TAG,
             MARKDOWN_PLACEHOLDER_UNSUPPORTED_TAG,
             MINIMAL_MARKDOWN_LITE_WITH_UNSUPPORTED_TAG
     ]:
         self.set_content("root/google/models/model/1.md", markdown)
         with self.assertRaisesRegexp(
                 validator.MarkdownDocumentationError,
                 r".*contains unsupported metadata properties: \['unsupported_tag'\].*"
         ):
             validator.validate_documentation_files(
                 documentation_dir=self.tmp_root_dir)
Beispiel #23
0
 def test_minimal_publisher_markdown_parsed(self):
     self.set_up_publisher_page("some-publisher")
     validator.validate_documentation_files(
         documentation_dir=self.tmp_root_dir)
Beispiel #24
0
 def test_invalid_markdown_fails(self):
     self.set_content("root/publisher/model/1.md", "INVALID MARKDOWN")
     with self.assertRaisesRegexp(validator.MarkdownDocumentationError,
                                  ".*First line.*"):
         validator.validate_documentation_files(
             documentation_dir=self.tmp_root_dir)
Beispiel #25
0
 def test_publisher_markdown_at_correct_location(self):
     self.set_up_publisher_page("some-publisher")
     validator.validate_documentation_files(
         documentation_dir=self.tmp_root_dir)
Beispiel #26
0
 def test_minimal_markdown_parsed_coral(self):
     self.set_content("root/google/models/text-embedding-model/1.md",
                      (MINIMAL_MARKDOWN_CORAL_TEMPLATE % self.model_path))
     self.set_up_publisher_page("google")
     validator.validate_documentation_files(
         documentation_dir=self.tmp_root_dir)
Beispiel #27
0
 def test_markdown_demo_button(self):
     self.set_content("root/google/models/model/1.md",
                      MARKDOWN_WITH_DEMO_BUTTON)
     self.set_up_publisher_page("google")
     validator.validate_documentation_files(
         documentation_dir=self.tmp_root_dir)
Beispiel #28
0
 def test_markdown_with_allowed_license(self):
     self.set_content("root/google/models/model/1.md",
                      MINIMAL_MARKDOWN_WITH_ALLOWED_LICENSE)
     self.set_up_publisher_page("google")
     validator.validate_documentation_files(
         documentation_dir=self.tmp_root_dir)
Beispiel #29
0
 def test_markdown_with_allowed_duplicate_metadata(self):
     self.set_up_publisher_page("google")
     self.set_content("root/google/models/model/1.md",
                      MARKDOWN_WITH_ALLOWED_DUPLICATE_METADATA)
     validator.validate_documentation_files(
         documentation_dir=self.tmp_root_dir)