MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / gfile_copy_callback

Function gfile_copy_callback

tensorflow/contrib/session_bundle/exporter.py:46–72  ·  view source on GitHub ↗

Callback to copy files using `gfile.copy` to an export directory. This method is used as the default `assets_callback` in `Exporter.init` to copy assets from the `assets_collection`. It can also be invoked directly to copy additional supplementary files into the export directory (in which cas

(files_to_copy, export_dir_path)

Source from the content-addressed store, hash-verified

44@deprecated("2017-06-30",
45 "No longer supported. Switch to SavedModel immediately.")
46def gfile_copy_callback(files_to_copy, export_dir_path):
47 """Callback to copy files using `gfile.copy` to an export directory.
48
49 This method is used as the default `assets_callback` in `Exporter.init` to
50 copy assets from the `assets_collection`. It can also be invoked directly to
51 copy additional supplementary files into the export directory (in which case
52 it is not a callback).
53
54 Args:
55 files_to_copy: A dictionary that maps original file paths to desired
56 basename in the export directory.
57 export_dir_path: Directory to copy the files to.
58 """
59 logging.info("Write assets into: %s using gfile_copy.", export_dir_path)
60 gfile.MakeDirs(export_dir_path)
61 for source_filepath, basename in files_to_copy.items():
62 new_path = os.path.join(
63 compat.as_bytes(export_dir_path), compat.as_bytes(basename))
64 logging.info("Copying asset %s to path %s.", source_filepath, new_path)
65
66 if gfile.Exists(new_path):
67 # Guard against being restarted while copying assets, and the file
68 # existing and being in an unknown state.
69 # TODO(b/28676216): Do some file checks before deleting.
70 logging.info("Removing file %s.", new_path)
71 gfile.Remove(new_path)
72 gfile.Copy(source_filepath, new_path)
73
74
75@deprecated("2017-06-30",

Callers

nothing calls this directly

Calls 5

infoMethod · 0.80
joinMethod · 0.45
ExistsMethod · 0.45
RemoveMethod · 0.45
CopyMethod · 0.45

Tested by

no test coverage detected