tensorbored 2.21.0rc1769983804__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. tensorbored/__init__.py +112 -0
  2. tensorbored/_vendor/__init__.py +0 -0
  3. tensorbored/_vendor/bleach/__init__.py +125 -0
  4. tensorbored/_vendor/bleach/_vendor/__init__.py +0 -0
  5. tensorbored/_vendor/bleach/_vendor/html5lib/__init__.py +35 -0
  6. tensorbored/_vendor/bleach/_vendor/html5lib/_ihatexml.py +289 -0
  7. tensorbored/_vendor/bleach/_vendor/html5lib/_inputstream.py +918 -0
  8. tensorbored/_vendor/bleach/_vendor/html5lib/_tokenizer.py +1735 -0
  9. tensorbored/_vendor/bleach/_vendor/html5lib/_trie/__init__.py +5 -0
  10. tensorbored/_vendor/bleach/_vendor/html5lib/_trie/_base.py +40 -0
  11. tensorbored/_vendor/bleach/_vendor/html5lib/_trie/py.py +67 -0
  12. tensorbored/_vendor/bleach/_vendor/html5lib/_utils.py +159 -0
  13. tensorbored/_vendor/bleach/_vendor/html5lib/constants.py +2946 -0
  14. tensorbored/_vendor/bleach/_vendor/html5lib/filters/__init__.py +0 -0
  15. tensorbored/_vendor/bleach/_vendor/html5lib/filters/alphabeticalattributes.py +29 -0
  16. tensorbored/_vendor/bleach/_vendor/html5lib/filters/base.py +12 -0
  17. tensorbored/_vendor/bleach/_vendor/html5lib/filters/inject_meta_charset.py +73 -0
  18. tensorbored/_vendor/bleach/_vendor/html5lib/filters/lint.py +93 -0
  19. tensorbored/_vendor/bleach/_vendor/html5lib/filters/optionaltags.py +207 -0
  20. tensorbored/_vendor/bleach/_vendor/html5lib/filters/sanitizer.py +916 -0
  21. tensorbored/_vendor/bleach/_vendor/html5lib/filters/whitespace.py +38 -0
  22. tensorbored/_vendor/bleach/_vendor/html5lib/html5parser.py +2795 -0
  23. tensorbored/_vendor/bleach/_vendor/html5lib/serializer.py +409 -0
  24. tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/__init__.py +30 -0
  25. tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/genshi.py +54 -0
  26. tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/sax.py +50 -0
  27. tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/__init__.py +88 -0
  28. tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/base.py +417 -0
  29. tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/dom.py +239 -0
  30. tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree.py +343 -0
  31. tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree_lxml.py +392 -0
  32. tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/__init__.py +154 -0
  33. tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/base.py +252 -0
  34. tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/dom.py +43 -0
  35. tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree.py +131 -0
  36. tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree_lxml.py +215 -0
  37. tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/genshi.py +69 -0
  38. tensorbored/_vendor/bleach/_vendor/parse.py +1078 -0
  39. tensorbored/_vendor/bleach/callbacks.py +32 -0
  40. tensorbored/_vendor/bleach/html5lib_shim.py +757 -0
  41. tensorbored/_vendor/bleach/linkifier.py +633 -0
  42. tensorbored/_vendor/bleach/parse_shim.py +1 -0
  43. tensorbored/_vendor/bleach/sanitizer.py +638 -0
  44. tensorbored/_vendor/bleach/six_shim.py +19 -0
  45. tensorbored/_vendor/webencodings/__init__.py +342 -0
  46. tensorbored/_vendor/webencodings/labels.py +231 -0
  47. tensorbored/_vendor/webencodings/mklabels.py +59 -0
  48. tensorbored/_vendor/webencodings/x_user_defined.py +325 -0
  49. tensorbored/assets.py +36 -0
  50. tensorbored/auth.py +102 -0
  51. tensorbored/backend/__init__.py +0 -0
  52. tensorbored/backend/application.py +604 -0
  53. tensorbored/backend/auth_context_middleware.py +38 -0
  54. tensorbored/backend/client_feature_flags.py +113 -0
  55. tensorbored/backend/empty_path_redirect.py +46 -0
  56. tensorbored/backend/event_processing/__init__.py +0 -0
  57. tensorbored/backend/event_processing/data_ingester.py +276 -0
  58. tensorbored/backend/event_processing/data_provider.py +535 -0
  59. tensorbored/backend/event_processing/directory_loader.py +142 -0
  60. tensorbored/backend/event_processing/directory_watcher.py +272 -0
  61. tensorbored/backend/event_processing/event_accumulator.py +950 -0
  62. tensorbored/backend/event_processing/event_file_inspector.py +463 -0
  63. tensorbored/backend/event_processing/event_file_loader.py +292 -0
  64. tensorbored/backend/event_processing/event_multiplexer.py +521 -0
  65. tensorbored/backend/event_processing/event_util.py +68 -0
  66. tensorbored/backend/event_processing/io_wrapper.py +223 -0
  67. tensorbored/backend/event_processing/plugin_asset_util.py +104 -0
  68. tensorbored/backend/event_processing/plugin_event_accumulator.py +721 -0
  69. tensorbored/backend/event_processing/plugin_event_multiplexer.py +522 -0
  70. tensorbored/backend/event_processing/reservoir.py +266 -0
  71. tensorbored/backend/event_processing/tag_types.py +29 -0
  72. tensorbored/backend/experiment_id.py +71 -0
  73. tensorbored/backend/experimental_plugin.py +51 -0
  74. tensorbored/backend/http_util.py +263 -0
  75. tensorbored/backend/json_util.py +70 -0
  76. tensorbored/backend/path_prefix.py +67 -0
  77. tensorbored/backend/process_graph.py +74 -0
  78. tensorbored/backend/security_validator.py +202 -0
  79. tensorbored/compat/__init__.py +69 -0
  80. tensorbored/compat/proto/__init__.py +0 -0
  81. tensorbored/compat/proto/allocation_description_pb2.py +35 -0
  82. tensorbored/compat/proto/api_def_pb2.py +82 -0
  83. tensorbored/compat/proto/attr_value_pb2.py +80 -0
  84. tensorbored/compat/proto/cluster_pb2.py +58 -0
  85. tensorbored/compat/proto/config_pb2.py +271 -0
  86. tensorbored/compat/proto/coordination_config_pb2.py +45 -0
  87. tensorbored/compat/proto/cost_graph_pb2.py +87 -0
  88. tensorbored/compat/proto/cpp_shape_inference_pb2.py +70 -0
  89. tensorbored/compat/proto/debug_pb2.py +65 -0
  90. tensorbored/compat/proto/event_pb2.py +149 -0
  91. tensorbored/compat/proto/full_type_pb2.py +74 -0
  92. tensorbored/compat/proto/function_pb2.py +157 -0
  93. tensorbored/compat/proto/graph_debug_info_pb2.py +111 -0
  94. tensorbored/compat/proto/graph_pb2.py +41 -0
  95. tensorbored/compat/proto/histogram_pb2.py +39 -0
  96. tensorbored/compat/proto/meta_graph_pb2.py +254 -0
  97. tensorbored/compat/proto/node_def_pb2.py +61 -0
  98. tensorbored/compat/proto/op_def_pb2.py +81 -0
  99. tensorbored/compat/proto/resource_handle_pb2.py +48 -0
  100. tensorbored/compat/proto/rewriter_config_pb2.py +93 -0
  101. tensorbored/compat/proto/rpc_options_pb2.py +35 -0
  102. tensorbored/compat/proto/saved_object_graph_pb2.py +193 -0
  103. tensorbored/compat/proto/saver_pb2.py +38 -0
  104. tensorbored/compat/proto/step_stats_pb2.py +116 -0
  105. tensorbored/compat/proto/struct_pb2.py +144 -0
  106. tensorbored/compat/proto/summary_pb2.py +111 -0
  107. tensorbored/compat/proto/tensor_description_pb2.py +38 -0
  108. tensorbored/compat/proto/tensor_pb2.py +68 -0
  109. tensorbored/compat/proto/tensor_shape_pb2.py +46 -0
  110. tensorbored/compat/proto/tfprof_log_pb2.py +307 -0
  111. tensorbored/compat/proto/trackable_object_graph_pb2.py +90 -0
  112. tensorbored/compat/proto/types_pb2.py +105 -0
  113. tensorbored/compat/proto/variable_pb2.py +62 -0
  114. tensorbored/compat/proto/verifier_config_pb2.py +38 -0
  115. tensorbored/compat/proto/versions_pb2.py +35 -0
  116. tensorbored/compat/tensorflow_stub/__init__.py +38 -0
  117. tensorbored/compat/tensorflow_stub/app.py +124 -0
  118. tensorbored/compat/tensorflow_stub/compat/__init__.py +131 -0
  119. tensorbored/compat/tensorflow_stub/compat/v1/__init__.py +20 -0
  120. tensorbored/compat/tensorflow_stub/dtypes.py +692 -0
  121. tensorbored/compat/tensorflow_stub/error_codes.py +169 -0
  122. tensorbored/compat/tensorflow_stub/errors.py +507 -0
  123. tensorbored/compat/tensorflow_stub/flags.py +124 -0
  124. tensorbored/compat/tensorflow_stub/io/__init__.py +17 -0
  125. tensorbored/compat/tensorflow_stub/io/gfile.py +1011 -0
  126. tensorbored/compat/tensorflow_stub/pywrap_tensorflow.py +285 -0
  127. tensorbored/compat/tensorflow_stub/tensor_shape.py +1035 -0
  128. tensorbored/context.py +129 -0
  129. tensorbored/data/__init__.py +0 -0
  130. tensorbored/data/grpc_provider.py +365 -0
  131. tensorbored/data/ingester.py +46 -0
  132. tensorbored/data/proto/__init__.py +0 -0
  133. tensorbored/data/proto/data_provider_pb2.py +517 -0
  134. tensorbored/data/proto/data_provider_pb2_grpc.py +374 -0
  135. tensorbored/data/provider.py +1365 -0
  136. tensorbored/data/server_ingester.py +301 -0
  137. tensorbored/data_compat.py +159 -0
  138. tensorbored/dataclass_compat.py +224 -0
  139. tensorbored/default.py +124 -0
  140. tensorbored/errors.py +130 -0
  141. tensorbored/lazy.py +99 -0
  142. tensorbored/main.py +48 -0
  143. tensorbored/main_lib.py +62 -0
  144. tensorbored/manager.py +487 -0
  145. tensorbored/notebook.py +441 -0
  146. tensorbored/plugin_util.py +266 -0
  147. tensorbored/plugins/__init__.py +0 -0
  148. tensorbored/plugins/audio/__init__.py +0 -0
  149. tensorbored/plugins/audio/audio_plugin.py +229 -0
  150. tensorbored/plugins/audio/metadata.py +69 -0
  151. tensorbored/plugins/audio/plugin_data_pb2.py +37 -0
  152. tensorbored/plugins/audio/summary.py +230 -0
  153. tensorbored/plugins/audio/summary_v2.py +124 -0
  154. tensorbored/plugins/base_plugin.py +367 -0
  155. tensorbored/plugins/core/__init__.py +0 -0
  156. tensorbored/plugins/core/core_plugin.py +981 -0
  157. tensorbored/plugins/custom_scalar/__init__.py +0 -0
  158. tensorbored/plugins/custom_scalar/custom_scalars_plugin.py +320 -0
  159. tensorbored/plugins/custom_scalar/layout_pb2.py +85 -0
  160. tensorbored/plugins/custom_scalar/metadata.py +35 -0
  161. tensorbored/plugins/custom_scalar/summary.py +79 -0
  162. tensorbored/plugins/debugger_v2/__init__.py +0 -0
  163. tensorbored/plugins/debugger_v2/debug_data_multiplexer.py +631 -0
  164. tensorbored/plugins/debugger_v2/debug_data_provider.py +634 -0
  165. tensorbored/plugins/debugger_v2/debugger_v2_plugin.py +504 -0
  166. tensorbored/plugins/distribution/__init__.py +0 -0
  167. tensorbored/plugins/distribution/compressor.py +158 -0
  168. tensorbored/plugins/distribution/distributions_plugin.py +116 -0
  169. tensorbored/plugins/distribution/metadata.py +19 -0
  170. tensorbored/plugins/graph/__init__.py +0 -0
  171. tensorbored/plugins/graph/graph_util.py +129 -0
  172. tensorbored/plugins/graph/graphs_plugin.py +336 -0
  173. tensorbored/plugins/graph/keras_util.py +328 -0
  174. tensorbored/plugins/graph/metadata.py +42 -0
  175. tensorbored/plugins/histogram/__init__.py +0 -0
  176. tensorbored/plugins/histogram/histograms_plugin.py +144 -0
  177. tensorbored/plugins/histogram/metadata.py +63 -0
  178. tensorbored/plugins/histogram/plugin_data_pb2.py +34 -0
  179. tensorbored/plugins/histogram/summary.py +234 -0
  180. tensorbored/plugins/histogram/summary_v2.py +292 -0
  181. tensorbored/plugins/hparams/__init__.py +14 -0
  182. tensorbored/plugins/hparams/_keras.py +93 -0
  183. tensorbored/plugins/hparams/api.py +130 -0
  184. tensorbored/plugins/hparams/api_pb2.py +208 -0
  185. tensorbored/plugins/hparams/backend_context.py +606 -0
  186. tensorbored/plugins/hparams/download_data.py +158 -0
  187. tensorbored/plugins/hparams/error.py +26 -0
  188. tensorbored/plugins/hparams/get_experiment.py +71 -0
  189. tensorbored/plugins/hparams/hparams_plugin.py +206 -0
  190. tensorbored/plugins/hparams/hparams_util_pb2.py +69 -0
  191. tensorbored/plugins/hparams/json_format_compat.py +38 -0
  192. tensorbored/plugins/hparams/list_metric_evals.py +57 -0
  193. tensorbored/plugins/hparams/list_session_groups.py +1040 -0
  194. tensorbored/plugins/hparams/metadata.py +125 -0
  195. tensorbored/plugins/hparams/metrics.py +41 -0
  196. tensorbored/plugins/hparams/plugin_data_pb2.py +69 -0
  197. tensorbored/plugins/hparams/summary.py +205 -0
  198. tensorbored/plugins/hparams/summary_v2.py +597 -0
  199. tensorbored/plugins/image/__init__.py +0 -0
  200. tensorbored/plugins/image/images_plugin.py +232 -0
  201. tensorbored/plugins/image/metadata.py +65 -0
  202. tensorbored/plugins/image/plugin_data_pb2.py +34 -0
  203. tensorbored/plugins/image/summary.py +159 -0
  204. tensorbored/plugins/image/summary_v2.py +130 -0
  205. tensorbored/plugins/mesh/__init__.py +14 -0
  206. tensorbored/plugins/mesh/mesh_plugin.py +292 -0
  207. tensorbored/plugins/mesh/metadata.py +152 -0
  208. tensorbored/plugins/mesh/plugin_data_pb2.py +37 -0
  209. tensorbored/plugins/mesh/summary.py +251 -0
  210. tensorbored/plugins/mesh/summary_v2.py +214 -0
  211. tensorbored/plugins/metrics/__init__.py +0 -0
  212. tensorbored/plugins/metrics/metadata.py +17 -0
  213. tensorbored/plugins/metrics/metrics_plugin.py +623 -0
  214. tensorbored/plugins/pr_curve/__init__.py +0 -0
  215. tensorbored/plugins/pr_curve/metadata.py +75 -0
  216. tensorbored/plugins/pr_curve/plugin_data_pb2.py +34 -0
  217. tensorbored/plugins/pr_curve/pr_curves_plugin.py +241 -0
  218. tensorbored/plugins/pr_curve/summary.py +574 -0
  219. tensorbored/plugins/profile_redirect/__init__.py +0 -0
  220. tensorbored/plugins/profile_redirect/profile_redirect_plugin.py +49 -0
  221. tensorbored/plugins/projector/__init__.py +67 -0
  222. tensorbored/plugins/projector/metadata.py +26 -0
  223. tensorbored/plugins/projector/projector_config_pb2.py +54 -0
  224. tensorbored/plugins/projector/projector_plugin.py +795 -0
  225. tensorbored/plugins/projector/tf_projector_plugin/index.js +32 -0
  226. tensorbored/plugins/projector/tf_projector_plugin/projector_binary.html +524 -0
  227. tensorbored/plugins/projector/tf_projector_plugin/projector_binary.js +15536 -0
  228. tensorbored/plugins/scalar/__init__.py +0 -0
  229. tensorbored/plugins/scalar/metadata.py +60 -0
  230. tensorbored/plugins/scalar/plugin_data_pb2.py +34 -0
  231. tensorbored/plugins/scalar/scalars_plugin.py +181 -0
  232. tensorbored/plugins/scalar/summary.py +109 -0
  233. tensorbored/plugins/scalar/summary_v2.py +124 -0
  234. tensorbored/plugins/text/__init__.py +0 -0
  235. tensorbored/plugins/text/metadata.py +62 -0
  236. tensorbored/plugins/text/plugin_data_pb2.py +34 -0
  237. tensorbored/plugins/text/summary.py +114 -0
  238. tensorbored/plugins/text/summary_v2.py +124 -0
  239. tensorbored/plugins/text/text_plugin.py +288 -0
  240. tensorbored/plugins/wit_redirect/__init__.py +0 -0
  241. tensorbored/plugins/wit_redirect/wit_redirect_plugin.py +49 -0
  242. tensorbored/program.py +910 -0
  243. tensorbored/summary/__init__.py +35 -0
  244. tensorbored/summary/_output.py +124 -0
  245. tensorbored/summary/_tf/__init__.py +14 -0
  246. tensorbored/summary/_tf/summary/__init__.py +178 -0
  247. tensorbored/summary/_writer.py +105 -0
  248. tensorbored/summary/v1.py +51 -0
  249. tensorbored/summary/v2.py +25 -0
  250. tensorbored/summary/writer/__init__.py +13 -0
  251. tensorbored/summary/writer/event_file_writer.py +291 -0
  252. tensorbored/summary/writer/record_writer.py +50 -0
  253. tensorbored/util/__init__.py +0 -0
  254. tensorbored/util/encoder.py +116 -0
  255. tensorbored/util/grpc_util.py +311 -0
  256. tensorbored/util/img_mime_type_detector.py +40 -0
  257. tensorbored/util/io_util.py +20 -0
  258. tensorbored/util/lazy_tensor_creator.py +110 -0
  259. tensorbored/util/op_evaluator.py +104 -0
  260. tensorbored/util/platform_util.py +20 -0
  261. tensorbored/util/tb_logging.py +24 -0
  262. tensorbored/util/tensor_util.py +617 -0
  263. tensorbored/util/timing.py +122 -0
  264. tensorbored/version.py +21 -0
  265. tensorbored/webfiles.zip +0 -0
  266. tensorbored-2.21.0rc1769983804.dist-info/METADATA +49 -0
  267. tensorbored-2.21.0rc1769983804.dist-info/RECORD +271 -0
  268. tensorbored-2.21.0rc1769983804.dist-info/WHEEL +5 -0
  269. tensorbored-2.21.0rc1769983804.dist-info/entry_points.txt +6 -0
  270. tensorbored-2.21.0rc1769983804.dist-info/licenses/LICENSE +739 -0
  271. tensorbored-2.21.0rc1769983804.dist-info/top_level.txt +1 -0
@@ -0,0 +1,169 @@
1
+ # Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+
16
+ # Contains error codes defined in tensorflow/core/lib/core/error_codes.proto
17
+
18
+ # Not an error; returned on success
19
+ OK = 0
20
+
21
+ # The operation was cancelled (typically by the caller).
22
+ CANCELLED = 1
23
+
24
+ """
25
+ Unknown error. An example of where this error may be returned is
26
+ if a Status value received from another address space belongs to
27
+ an error-space that is not known in this address space. Also
28
+ errors raised by APIs that do not return enough error information
29
+ may be converted to this error.
30
+ """
31
+ UNKNOWN = 2
32
+
33
+ """
34
+ Client specified an invalid argument. Note that this differs
35
+ from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
36
+ that are problematic regardless of the state of the system
37
+ (e.g., a malformed file name).
38
+ """
39
+ INVALID_ARGUMENT = 3
40
+
41
+ """
42
+ Deadline expired before operation could complete. For operations
43
+ that change the state of the system, this error may be returned
44
+ even if the operation has completed successfully. For example, a
45
+ successful response from a server could have been delayed long
46
+ enough for the deadline to expire.
47
+ """
48
+ DEADLINE_EXCEEDED = 4
49
+
50
+ """
51
+ Some requested entity (e.g., file or directory) was not found.
52
+ For privacy reasons, this code *may* be returned when the client
53
+ does not have the access right to the entity.
54
+ """
55
+ NOT_FOUND = 5
56
+
57
+ """
58
+ Some entity that we attempted to create (e.g., file or directory)
59
+ already exists.
60
+ """
61
+ ALREADY_EXISTS = 6
62
+
63
+ """
64
+ The caller does not have permission to execute the specified
65
+ operation. PERMISSION_DENIED must not be used for rejections
66
+ caused by exhausting some resource (use RESOURCE_EXHAUSTED
67
+ instead for those errors). PERMISSION_DENIED must not be
68
+ used if the caller can not be identified (use UNAUTHENTICATED
69
+ instead for those errors).
70
+ """
71
+ PERMISSION_DENIED = 7
72
+
73
+ """
74
+ Some resource has been exhausted, perhaps a per-user quota, or
75
+ perhaps the entire file system is out of space.
76
+ """
77
+ RESOURCE_EXHAUSTED = 8
78
+
79
+ """
80
+ Operation was rejected because the system is not in a state
81
+ required for the operation's execution. For example, directory
82
+ to be deleted may be non-empty, an rmdir operation is applied to
83
+ a non-directory, etc.
84
+ A litmus test that may help a service implementor in deciding
85
+ between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:
86
+ (a) Use UNAVAILABLE if the client can retry just the failing call.
87
+ (b) Use ABORTED if the client should retry at a higher-level
88
+ (e.g., restarting a read-modify-write sequence).
89
+ (c) Use FAILED_PRECONDITION if the client should not retry until
90
+ the system state has been explicitly fixed. E.g., if an "rmdir"
91
+ fails because the directory is non-empty, FAILED_PRECONDITION
92
+ should be returned since the client should not retry unless
93
+ they have first fixed up the directory by deleting files from it.
94
+ (d) Use FAILED_PRECONDITION if the client performs conditional
95
+ REST Get/Update/Delete on a resource and the resource on the
96
+ server does not match the condition. E.g., conflicting
97
+ read-modify-write on the same resource.
98
+ """
99
+ FAILED_PRECONDITION = 9
100
+
101
+ """
102
+ The operation was aborted, typically due to a concurrency issue
103
+ like sequencer check failures, transaction aborts, etc.
104
+
105
+ See litmus test above for deciding between FAILED_PRECONDITION,
106
+ ABORTED, and UNAVAILABLE.
107
+ """
108
+ ABORTED = 10
109
+
110
+ """
111
+ Operation tried to iterate past the valid input range. E.g., seeking or
112
+ reading past end of file.
113
+
114
+ Unlike INVALID_ARGUMENT, this error indicates a problem that may
115
+ be fixed if the system state changes. For example, a 32-bit file
116
+ system will generate INVALID_ARGUMENT if asked to read at an
117
+ offset that is not in the range [0,2^32-1], but it will generate
118
+ OUT_OF_RANGE if asked to read from an offset past the current
119
+ file size.
120
+
121
+ There is a fair bit of overlap between FAILED_PRECONDITION and
122
+ OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
123
+ error) when it applies so that callers who are iterating through
124
+ a space can easily look for an OUT_OF_RANGE error to detect when
125
+ they are done.
126
+ """
127
+ OUT_OF_RANGE = 11
128
+
129
+ # Operation is not implemented or not supported/enabled in this service.
130
+ UNIMPLEMENTED = 12
131
+
132
+ """
133
+ Internal errors. Means some invariant expected by the underlying
134
+ system has been broken. If you see one of these errors,
135
+ something is very broken.
136
+ """
137
+ INTERNAL = 13
138
+
139
+ """
140
+ The service is currently unavailable. This is a most likely a
141
+ transient condition and may be corrected by retrying with
142
+ a backoff.
143
+
144
+ See litmus test above for deciding between FAILED_PRECONDITION,
145
+ ABORTED, and UNAVAILABLE.
146
+ """
147
+ UNAVAILABLE = 14
148
+
149
+ # Unrecoverable data loss or corruption.
150
+ DATA_LOSS = 15
151
+
152
+ """
153
+ The request does not have valid authentication credentials for the
154
+ operation.
155
+ """
156
+ UNAUTHENTICATED = 16
157
+
158
+ """
159
+ An extra enum entry to prevent people from writing code that
160
+ fails to compile when a new code is added.
161
+
162
+ Nobody should ever reference this enumeration entry. In particular,
163
+ if you write C++ code that switches on this enumeration, add a default:
164
+ case instead of a case that mentions this enumeration entry.
165
+
166
+ Nobody should rely on the value (currently 20) listed here. It
167
+ may change in the future.
168
+ """
169
+ DO_NOT_USE_RESERVED_FOR_FUTURE_EXPANSION_USE_DEFAULT_IN_SWITCH_INSTEAD_ = 20
@@ -0,0 +1,507 @@
1
+ # Copyright 2015 The TensorFlow Authors. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+ """Exception types for TensorFlow errors."""
16
+
17
+ import traceback
18
+ import warnings
19
+
20
+ from . import error_codes
21
+
22
+
23
+ # @tf_export("OpError", "errors.OpError")
24
+ class OpError(Exception):
25
+ """A generic error that is raised when TensorFlow execution fails.
26
+
27
+ Whenever possible, the session will raise a more specific subclass
28
+ of `OpError` from the `tf.errors` module.
29
+ """
30
+
31
+ def __init__(self, node_def, op, message, error_code):
32
+ """Creates a new `OpError` indicating that a particular op failed.
33
+
34
+ Args:
35
+ node_def: The `node_def_pb2.NodeDef` proto representing the op that
36
+ failed, if known; otherwise None.
37
+ op: The `ops.Operation` that failed, if known; otherwise None.
38
+ message: The message string describing the failure.
39
+ error_code: The `error_codes.Code` describing the error.
40
+ """
41
+ super().__init__()
42
+ self._message = message
43
+ self._node_def = node_def
44
+ self._op = op
45
+ self._error_code = error_code
46
+
47
+ @property
48
+ def message(self):
49
+ """The error message that describes the error."""
50
+ return self._message
51
+
52
+ @property
53
+ def op(self):
54
+ """The operation that failed, if known.
55
+
56
+ *N.B.* If the failed op was synthesized at runtime, e.g. a `Send`
57
+ or `Recv` op, there will be no corresponding
58
+ @{tf.Operation}
59
+ object. In that case, this will return `None`, and you should
60
+ instead use the @{tf.OpError.node_def} to
61
+ discover information about the op.
62
+
63
+ Returns:
64
+ The `Operation` that failed, or None.
65
+ """
66
+ return self._op
67
+
68
+ @property
69
+ def error_code(self):
70
+ """The integer error code that describes the error."""
71
+ return self._error_code
72
+
73
+ @property
74
+ def node_def(self):
75
+ """The `NodeDef` proto representing the op that failed."""
76
+ return self._node_def
77
+
78
+ def __str__(self):
79
+ if self._op is not None:
80
+ output = [
81
+ "%s\n\nCaused by op %r, defined at:\n"
82
+ % (self.message, self._op.name)
83
+ ]
84
+ curr_traceback_list = traceback.format_list(self._op.traceback)
85
+ output.extend(curr_traceback_list)
86
+ # pylint: disable=protected-access
87
+ original_op = self._op._original_op
88
+ # pylint: enable=protected-access
89
+ while original_op is not None:
90
+ output.append(
91
+ "\n...which was originally created as op %r, defined at:\n"
92
+ % (original_op.name,)
93
+ )
94
+ prev_traceback_list = curr_traceback_list
95
+ curr_traceback_list = traceback.format_list(
96
+ original_op.traceback
97
+ )
98
+
99
+ # Attempt to elide large common subsequences of the subsequent
100
+ # stack traces.
101
+ #
102
+ # TODO(mrry): Consider computing the actual longest common subsequence.
103
+ is_eliding = False
104
+ elide_count = 0
105
+ last_elided_line = None
106
+ for line, line_in_prev in zip(
107
+ curr_traceback_list, prev_traceback_list
108
+ ):
109
+ if line == line_in_prev:
110
+ if is_eliding:
111
+ elide_count += 1
112
+ last_elided_line = line
113
+ else:
114
+ output.append(line)
115
+ is_eliding = True
116
+ elide_count = 0
117
+ else:
118
+ if is_eliding:
119
+ if elide_count > 0:
120
+ output.extend(
121
+ [
122
+ "[elided %d identical lines from previous traceback]\n"
123
+ % (elide_count - 1,),
124
+ last_elided_line,
125
+ ]
126
+ )
127
+ is_eliding = False
128
+ output.extend(line)
129
+
130
+ # pylint: disable=protected-access
131
+ original_op = original_op._original_op
132
+ # pylint: enable=protected-access
133
+ output.append(
134
+ "\n%s (see above for traceback): %s\n"
135
+ % (type(self).__name__, self.message)
136
+ )
137
+ return "".join(output)
138
+ else:
139
+ return self.message
140
+
141
+
142
+ OK = error_codes.OK
143
+ # tf_export("errors.OK").export_constant(__name__, "OK")
144
+ CANCELLED = error_codes.CANCELLED
145
+ # tf_export("errors.CANCELLED").export_constant(__name__, "CANCELLED")
146
+ UNKNOWN = error_codes.UNKNOWN
147
+ # tf_export("errors.UNKNOWN").export_constant(__name__, "UNKNOWN")
148
+ INVALID_ARGUMENT = error_codes.INVALID_ARGUMENT
149
+ # tf_export("errors.INVALID_ARGUMENT").export_constant(__name__,
150
+ # "INVALID_ARGUMENT")
151
+ DEADLINE_EXCEEDED = error_codes.DEADLINE_EXCEEDED
152
+ # tf_export("errors.DEADLINE_EXCEEDED").export_constant(__name__,
153
+ # "DEADLINE_EXCEEDED")
154
+ NOT_FOUND = error_codes.NOT_FOUND
155
+ # tf_export("errors.NOT_FOUND").export_constant(__name__, "NOT_FOUND")
156
+ ALREADY_EXISTS = error_codes.ALREADY_EXISTS
157
+ # tf_export("errors.ALREADY_EXISTS").export_constant(__name__, "ALREADY_EXISTS")
158
+ PERMISSION_DENIED = error_codes.PERMISSION_DENIED
159
+ # tf_export("errors.PERMISSION_DENIED").export_constant(__name__,
160
+ # "PERMISSION_DENIED")
161
+ UNAUTHENTICATED = error_codes.UNAUTHENTICATED
162
+ # tf_export("errors.UNAUTHENTICATED").export_constant(__name__, "UNAUTHENTICATED")
163
+ RESOURCE_EXHAUSTED = error_codes.RESOURCE_EXHAUSTED
164
+ # tf_export("errors.RESOURCE_EXHAUSTED").export_constant(__name__,
165
+ # "RESOURCE_EXHAUSTED")
166
+ FAILED_PRECONDITION = error_codes.FAILED_PRECONDITION
167
+ # tf_export("errors.FAILED_PRECONDITION").export_constant(__name__,
168
+ # "FAILED_PRECONDITION")
169
+ ABORTED = error_codes.ABORTED
170
+ # tf_export("errors.ABORTED").export_constant(__name__, "ABORTED")
171
+ OUT_OF_RANGE = error_codes.OUT_OF_RANGE
172
+ # tf_export("errors.OUT_OF_RANGE").export_constant(__name__, "OUT_OF_RANGE")
173
+ UNIMPLEMENTED = error_codes.UNIMPLEMENTED
174
+ # tf_export("errors.UNIMPLEMENTED").export_constant(__name__, "UNIMPLEMENTED")
175
+ INTERNAL = error_codes.INTERNAL
176
+ # tf_export("errors.INTERNAL").export_constant(__name__, "INTERNAL")
177
+ UNAVAILABLE = error_codes.UNAVAILABLE
178
+ # tf_export("errors.UNAVAILABLE").export_constant(__name__, "UNAVAILABLE")
179
+ DATA_LOSS = error_codes.DATA_LOSS
180
+ # tf_export("errors.DATA_LOSS").export_constant(__name__, "DATA_LOSS")
181
+
182
+
183
+ # @tf_export("errors.CancelledError")
184
+ class CancelledError(OpError):
185
+ """Raised when an operation or step is cancelled.
186
+
187
+ For example, a long-running operation (e.g.
188
+ @{tf.QueueBase.enqueue} may be
189
+ cancelled by running another operation (e.g.
190
+ @{tf.QueueBase.close},
191
+ or by @{tf.Session.close}.
192
+ A step that is running such a long-running operation will fail by raising
193
+ `CancelledError`.
194
+
195
+ @@__init__
196
+ """
197
+
198
+ def __init__(self, node_def, op, message):
199
+ """Creates a `CancelledError`."""
200
+ super().__init__(node_def, op, message, CANCELLED)
201
+
202
+
203
+ # @tf_export("errors.UnknownError")
204
+ class UnknownError(OpError):
205
+ """Unknown error.
206
+
207
+ An example of where this error may be returned is if a Status value
208
+ received from another address space belongs to an error-space that
209
+ is not known to this address space. Also errors raised by APIs that
210
+ do not return enough error information may be converted to this
211
+ error.
212
+
213
+ @@__init__
214
+ """
215
+
216
+ def __init__(self, node_def, op, message, error_code=UNKNOWN):
217
+ """Creates an `UnknownError`."""
218
+ super().__init__(node_def, op, message, error_code)
219
+
220
+
221
+ # @tf_export("errors.InvalidArgumentError")
222
+ class InvalidArgumentError(OpError):
223
+ """Raised when an operation receives an invalid argument.
224
+
225
+ This may occur, for example, if an operation is receives an input
226
+ tensor that has an invalid value or shape. For example, the
227
+ @{tf.matmul} op will raise this
228
+ error if it receives an input that is not a matrix, and the
229
+ @{tf.reshape} op will raise
230
+ this error if the new shape does not match the number of elements in the input
231
+ tensor.
232
+
233
+ @@__init__
234
+ """
235
+
236
+ def __init__(self, node_def, op, message):
237
+ """Creates an `InvalidArgumentError`."""
238
+ super().__init__(node_def, op, message, INVALID_ARGUMENT)
239
+
240
+
241
+ # @tf_export("errors.DeadlineExceededError")
242
+ class DeadlineExceededError(OpError):
243
+ """Raised when a deadline expires before an operation could complete.
244
+
245
+ This exception is not currently used.
246
+
247
+ @@__init__
248
+ """
249
+
250
+ def __init__(self, node_def, op, message):
251
+ """Creates a `DeadlineExceededError`."""
252
+ super().__init__(node_def, op, message, DEADLINE_EXCEEDED)
253
+
254
+
255
+ # @tf_export("errors.NotFoundError")
256
+ class NotFoundError(OpError):
257
+ """Raised when a requested entity (e.g., a file or directory) was not
258
+ found.
259
+
260
+ For example, running the
261
+ @{tf.WholeFileReader.read}
262
+ operation could raise `NotFoundError` if it receives the name of a file that
263
+ does not exist.
264
+
265
+ @@__init__
266
+ """
267
+
268
+ def __init__(self, node_def, op, message):
269
+ """Creates a `NotFoundError`."""
270
+ super().__init__(node_def, op, message, NOT_FOUND)
271
+
272
+
273
+ # @tf_export("errors.AlreadyExistsError")
274
+ class AlreadyExistsError(OpError):
275
+ """Raised when an entity that we attempted to create already exists.
276
+
277
+ For example, running an operation that saves a file
278
+ (e.g. @{tf.train.Saver.save})
279
+ could potentially raise this exception if an explicit filename for an
280
+ existing file was passed.
281
+
282
+ @@__init__
283
+ """
284
+
285
+ def __init__(self, node_def, op, message):
286
+ """Creates an `AlreadyExistsError`."""
287
+ super().__init__(node_def, op, message, ALREADY_EXISTS)
288
+
289
+
290
+ # @tf_export("errors.PermissionDeniedError")
291
+ class PermissionDeniedError(OpError):
292
+ """Raised when the caller does not have permission to run an operation.
293
+
294
+ For example, running the
295
+ @{tf.WholeFileReader.read}
296
+ operation could raise `PermissionDeniedError` if it receives the name of a
297
+ file for which the user does not have the read file permission.
298
+
299
+ @@__init__
300
+ """
301
+
302
+ def __init__(self, node_def, op, message):
303
+ """Creates a `PermissionDeniedError`."""
304
+ super().__init__(node_def, op, message, PERMISSION_DENIED)
305
+
306
+
307
+ # @tf_export("errors.UnauthenticatedError")
308
+ class UnauthenticatedError(OpError):
309
+ """The request does not have valid authentication credentials.
310
+
311
+ This exception is not currently used.
312
+
313
+ @@__init__
314
+ """
315
+
316
+ def __init__(self, node_def, op, message):
317
+ """Creates an `UnauthenticatedError`."""
318
+ super().__init__(node_def, op, message, UNAUTHENTICATED)
319
+
320
+
321
+ # @tf_export("errors.ResourceExhaustedError")
322
+ class ResourceExhaustedError(OpError):
323
+ """Some resource has been exhausted.
324
+
325
+ For example, this error might be raised if a per-user quota is
326
+ exhausted, or perhaps the entire file system is out of space.
327
+
328
+ @@__init__
329
+ """
330
+
331
+ def __init__(self, node_def, op, message):
332
+ """Creates a `ResourceExhaustedError`."""
333
+ super().__init__(node_def, op, message, RESOURCE_EXHAUSTED)
334
+
335
+
336
+ # @tf_export("errors.FailedPreconditionError")
337
+ class FailedPreconditionError(OpError):
338
+ """Operation was rejected because the system is not in a state to execute
339
+ it.
340
+
341
+ This exception is most commonly raised when running an operation
342
+ that reads a @{tf.Variable}
343
+ before it has been initialized.
344
+
345
+ @@__init__
346
+ """
347
+
348
+ def __init__(self, node_def, op, message):
349
+ """Creates a `FailedPreconditionError`."""
350
+ super().__init__(node_def, op, message, FAILED_PRECONDITION)
351
+
352
+
353
+ # @tf_export("errors.AbortedError")
354
+ class AbortedError(OpError):
355
+ """The operation was aborted, typically due to a concurrent action.
356
+
357
+ For example, running a
358
+ @{tf.QueueBase.enqueue}
359
+ operation may raise `AbortedError` if a
360
+ @{tf.QueueBase.close} operation
361
+ previously ran.
362
+
363
+ @@__init__
364
+ """
365
+
366
+ def __init__(self, node_def, op, message):
367
+ """Creates an `AbortedError`."""
368
+ super().__init__(node_def, op, message, ABORTED)
369
+
370
+
371
+ # @tf_export("errors.OutOfRangeError")
372
+ class OutOfRangeError(OpError):
373
+ """Raised when an operation iterates past the valid input range.
374
+
375
+ This exception is raised in "end-of-file" conditions, such as when a
376
+ @{tf.QueueBase.dequeue}
377
+ operation is blocked on an empty queue, and a
378
+ @{tf.QueueBase.close}
379
+ operation executes.
380
+
381
+ @@__init__
382
+ """
383
+
384
+ def __init__(self, node_def, op, message):
385
+ """Creates an `OutOfRangeError`."""
386
+ super().__init__(node_def, op, message, OUT_OF_RANGE)
387
+
388
+
389
+ # @tf_export("errors.UnimplementedError")
390
+ class UnimplementedError(OpError):
391
+ """Raised when an operation has not been implemented.
392
+
393
+ Some operations may raise this error when passed otherwise-valid
394
+ arguments that it does not currently support. For example, running
395
+ the @{tf.nn.max_pool} operation
396
+ would raise this error if pooling was requested on the batch dimension,
397
+ because this is not yet supported.
398
+
399
+ @@__init__
400
+ """
401
+
402
+ def __init__(self, node_def, op, message):
403
+ """Creates an `UnimplementedError`."""
404
+ super().__init__(node_def, op, message, UNIMPLEMENTED)
405
+
406
+
407
+ # @tf_export("errors.InternalError")
408
+ class InternalError(OpError):
409
+ """Raised when the system experiences an internal error.
410
+
411
+ This exception is raised when some invariant expected by the runtime
412
+ has been broken. Catching this exception is not recommended.
413
+
414
+ @@__init__
415
+ """
416
+
417
+ def __init__(self, node_def, op, message):
418
+ """Creates an `InternalError`."""
419
+ super().__init__(node_def, op, message, INTERNAL)
420
+
421
+
422
+ # @tf_export("errors.UnavailableError")
423
+ class UnavailableError(OpError):
424
+ """Raised when the runtime is currently unavailable.
425
+
426
+ This exception is not currently used.
427
+
428
+ @@__init__
429
+ """
430
+
431
+ def __init__(self, node_def, op, message):
432
+ """Creates an `UnavailableError`."""
433
+ super().__init__(node_def, op, message, UNAVAILABLE)
434
+
435
+
436
+ # @tf_export("errors.DataLossError")
437
+ class DataLossError(OpError):
438
+ """Raised when unrecoverable data loss or corruption is encountered.
439
+
440
+ For example, this may be raised by running a
441
+ @{tf.WholeFileReader.read}
442
+ operation, if the file is truncated while it is being read.
443
+
444
+ @@__init__
445
+ """
446
+
447
+ def __init__(self, node_def, op, message):
448
+ """Creates a `DataLossError`."""
449
+ super().__init__(node_def, op, message, DATA_LOSS)
450
+
451
+
452
+ _CODE_TO_EXCEPTION_CLASS = {
453
+ CANCELLED: CancelledError,
454
+ UNKNOWN: UnknownError,
455
+ INVALID_ARGUMENT: InvalidArgumentError,
456
+ DEADLINE_EXCEEDED: DeadlineExceededError,
457
+ NOT_FOUND: NotFoundError,
458
+ ALREADY_EXISTS: AlreadyExistsError,
459
+ PERMISSION_DENIED: PermissionDeniedError,
460
+ UNAUTHENTICATED: UnauthenticatedError,
461
+ RESOURCE_EXHAUSTED: ResourceExhaustedError,
462
+ FAILED_PRECONDITION: FailedPreconditionError,
463
+ ABORTED: AbortedError,
464
+ OUT_OF_RANGE: OutOfRangeError,
465
+ UNIMPLEMENTED: UnimplementedError,
466
+ INTERNAL: InternalError,
467
+ UNAVAILABLE: UnavailableError,
468
+ DATA_LOSS: DataLossError,
469
+ }
470
+
471
+ _EXCEPTION_CLASS_TO_CODE = dict(
472
+ ((class_, code) for (code, class_) in _CODE_TO_EXCEPTION_CLASS.items())
473
+ )
474
+
475
+
476
+ # @tf_export("errors.exception_type_from_error_code")
477
+ def exception_type_from_error_code(error_code):
478
+ return _CODE_TO_EXCEPTION_CLASS[error_code]
479
+
480
+
481
+ # @tf_export("errors.error_code_from_exception_type")
482
+ def error_code_from_exception_type(cls):
483
+ return _EXCEPTION_CLASS_TO_CODE[cls]
484
+
485
+
486
+ def _make_specific_exception(node_def, op, message, error_code):
487
+ try:
488
+ exc_type = exception_type_from_error_code(error_code)
489
+ return exc_type(node_def, op, message)
490
+ except KeyError:
491
+ warnings.warn("Unknown error code: %d" % error_code)
492
+ return UnknownError(node_def, op, message, error_code)
493
+
494
+
495
+ # Named like a function for backwards compatibility with the
496
+ # @tf_contextlib.contextmanager version, which was switched to a class to avoid
497
+ # some object creation overhead.
498
+ # TODO(b/77295559): expand use of TF_Status* SWIG typemap and deprecate this.
499
+ # @tf_export("errors.raise_exception_on_not_ok_status") # pylint: disable=invalid-name
500
+ class raise_exception_on_not_ok_status:
501
+ """Context manager to check for C API status."""
502
+
503
+ def __enter__(self):
504
+ return "Status not OK"
505
+
506
+ def __exit__(self, type_arg, value_arg, traceback_arg):
507
+ return False # False values do not suppress exceptions