Gets a list of Paths in a given directory. Args: base_dir: directory. parser: a function which gets the raw Path and can augment it with information such as the export_version, or ignore the path by returning None. An example parser may extract the export version from a path
(base_dir, parser)
| 189 | @deprecated('2017-06-30', |
| 190 | 'No longer supported. Switch to SavedModel immediately.') |
| 191 | def get_paths(base_dir, parser): |
| 192 | """Gets a list of Paths in a given directory. |
| 193 | |
| 194 | Args: |
| 195 | base_dir: directory. |
| 196 | parser: a function which gets the raw Path and can augment it with |
| 197 | information such as the export_version, or ignore the path by returning |
| 198 | None. An example parser may extract the export version from a path |
| 199 | such as "/tmp/exports/100" an another may extract from a full file |
| 200 | name such as "/tmp/checkpoint-99.out". |
| 201 | |
| 202 | Returns: |
| 203 | A list of Paths contained in the base directory with the parsing function |
| 204 | applied. |
| 205 | By default the following fields are populated, |
| 206 | - Path.path |
| 207 | The parsing function is responsible for populating, |
| 208 | - Path.export_version |
| 209 | """ |
| 210 | raw_paths = gfile.ListDirectory(base_dir) |
| 211 | paths = [] |
| 212 | for r in raw_paths: |
| 213 | p = parser(Path(os.path.join(base_dir, r), None)) |
| 214 | if p: |
| 215 | paths.append(p) |
| 216 | return sorted(paths) |