-
Notifications
You must be signed in to change notification settings - Fork 793
Support Snappy compression and a configurable GZIP level for make_examples output #1088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tfenne
wants to merge
2
commits into
google:r1.10
Choose a base branch
from
tfenne:tf_examples-compression
base: r1.10
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1207,7 +1207,7 @@ def __init__(self, options, suffix=None): | |
|
|
||
| if options.examples_filename: | ||
| clean_basename = re.sub( | ||
| r'(\@[0-9]+|-\*?\d*-of-\*?\d*|\.gz)', | ||
| r'(\@[0-9]+|-\*?\d*-of-\*?\d*|\.gz|\.snappy)', | ||
| '', | ||
| os.path.basename(options.examples_filename.lower()), | ||
| ) | ||
|
|
@@ -1241,7 +1241,11 @@ def __init__(self, options, suffix=None): | |
| self._add_writer( | ||
| 'call_variant_outputs', | ||
| dv_utils.get_tf_record_writer( | ||
| self._add_suffix(self.examples_filename, 'call_variant_outputs') | ||
| self._as_gzip_path( | ||
| self._add_suffix( | ||
| self.examples_filename, 'call_variant_outputs' | ||
| ) | ||
| ) | ||
| ), | ||
| ) | ||
|
|
||
|
|
@@ -1289,7 +1293,9 @@ def __init__(self, options, suffix=None): | |
| self._add_writer( | ||
| 'small_model_examples', | ||
| dv_utils.get_tf_record_writer( | ||
| self._add_suffix(self.examples_filename, 'small_model') | ||
| self._as_gzip_path( | ||
| self._add_suffix(self.examples_filename, 'small_model') | ||
| ) | ||
| ), | ||
| ) | ||
|
|
||
|
|
@@ -1309,6 +1315,23 @@ def _add_suffix(self, file_path, suffix): | |
| new_file = os.path.join(file_dir, new_file_base) | ||
| return new_file | ||
|
|
||
| @staticmethod | ||
| def _as_gzip_path(file_path): | ||
| """Returns file_path with a '.gz' suffix in place of a '.snappy' one. | ||
|
|
||
| The auxiliary make_examples outputs (the small-model call_variant_outputs | ||
| and small_model_examples) are always GZIP-compressed, even when the main | ||
| examples output uses Snappy. They inherit their name from the examples | ||
| path, so swap a trailing '.snappy' for '.gz' to keep each file name | ||
| consistent with its actual codec. The suffix match is case-insensitive to | ||
| agree with the codec detection in | ||
| dv_utils.compression_type_for_examples_path and the C++ writer (both | ||
| lower-case the path before comparing). | ||
| """ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm adding more comment here: Args:
file_path: The file path to potentially rewrite.
Returns:
The path with '.snappy' replaced by '.gz', or the original path. |
||
| if file_path.lower().endswith('.snappy'): | ||
| return file_path[: -len('.snappy')] + '.gz' | ||
| return file_path | ||
|
|
||
| def write_examples(self, *examples): | ||
| self._write('examples', *examples) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm changing this part to be: