MCPcopy Create free account
hub / github.com/google-research/language / export_paths

Function export_paths

language/common/utils/export_utils.py:26–50  ·  view source on GitHub ↗

Gets a list of exported paths, ordered by timestamp (ascending). The two patterns are necessary since glob doesn't support general regexes that are required for stricter matches that avoid temporary files. Args: glob_pattern (string): Input to tf.gfile.Glob. regex_pattern (string): R

(glob_pattern, regex_pattern)

Source from the content-addressed store, hash-verified

24
25
26def export_paths(glob_pattern, regex_pattern):
27 """Gets a list of exported paths, ordered by timestamp (ascending).
28
29 The two patterns are necessary since glob doesn't support general regexes that
30 are required for stricter matches that avoid temporary files.
31
32 Args:
33 glob_pattern (string): Input to tf.gfile.Glob.
34 regex_pattern (string): Regular expression for additional filtering. This
35 should have a match group named "timestamp".
36
37 Returns:
38 Filenames sorted by timestamp (later paths at the end).
39 """
40 matcher = re.compile(regex_pattern)
41 filtered_exports = [] # (int timestamp, string path) pairs
42
43 for filename in tf.gfile.Glob(glob_pattern):
44 match = matcher.match(filename)
45 if match:
46 # Gets the timestamp as an integer, instead of comparing it lexically.
47 timestamp = int(match.groupdict().get("timestamp", "0"))
48 filtered_exports.append((timestamp, filename))
49
50 return [filename for timestamp, filename in sorted(filtered_exports)]
51
52
53def latest_export_path(glob_pattern, regex_pattern):

Callers 2

latest_export_pathFunction · 0.85
clean_tfhub_exportsFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…