Skip to content

Commit

Permalink
Relax the metadata pattern in validator.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 293763161
  • Loading branch information
TensorFlow Hub Authors authored and vbardiovskyg committed Feb 11, 2020
1 parent 24e6ed6 commit 485783c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions tfhub_dev/tools/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
r"# Collection (?P<publisher>[\w-]+)/(?P<name>(\w|-|/|&|;|\.)+)/(\d+)")
# Regex pattern for the line of the documentation describing model metadata.
# Example: "<!-- finetunable: true -->"
METADATA_LINE_PATTERN = r"^<!-- (?P<key>(\w|\s|-)+): (?P<value>.+) -->$"
# Note: Both key and value consumes free space characters, but later on these
# are stripped.
METADATA_LINE_PATTERN = r"^<!--(?P<key>(\w|\s|-)+):(?P<value>.+)-->$"


class Filesystem(object):
Expand Down Expand Up @@ -271,8 +273,9 @@ def consume_metadata(self):
match = re.match(METADATA_LINE_PATTERN, self._lines[self._current_index])
if match:
# Add found metadata.
key = match.group(1)
value = match.group(3)
groups = match.groupdict()
key = groups.get("key").strip()
value = groups.get("value").strip()
if key not in self._parsed_metadata:
self._parsed_metadata[key] = set()
self._parsed_metadata[key].add(value)
Expand Down
4 changes: 2 additions & 2 deletions tfhub_dev/tools/validator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def recursive_list_dir(self, root_dir):
multiple lines.
<!-- asset-path: %s -->
<!-- module-type: text-embedding -->
<!-- fine-tunable: true -->
<!-- module-type: text-embedding -->
<!-- fine-tunable:true -->
<!-- format: saved_model_2 -->
## Overview
Expand Down

0 comments on commit 485783c

Please sign in to comment.