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,1365 @@
1
+ # Copyright 2019 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
+ """Experimental framework for generic TensorBoard data providers."""
16
+
17
+ from typing import Collection, Sequence, Tuple, Union
18
+ import abc
19
+ import dataclasses
20
+ import enum
21
+
22
+ import numpy as np
23
+
24
+
25
+ class DataProvider(metaclass=abc.ABCMeta):
26
+ """Interface for reading TensorBoard scalar, tensor, and blob data.
27
+
28
+ These APIs are under development and subject to change. For instance,
29
+ providers may be asked to implement more filtering mechanisms, such as
30
+ downsampling strategies or domain restriction by step or wall time.
31
+
32
+ The data provider interface specifies three *data classes*: scalars,
33
+ tensors, and blob sequences. All data is stored in *time series* for
34
+ one of these data classes. A time series is identified by run name and
35
+ tag name (each a non-empty text string), as well as an experiment ID
36
+ and plugin name (see below). Points in a time series are uniquely
37
+ indexed by *step*, an arbitrary non-negative integer. Each point in a
38
+ time series also has an associated wall time, plus its actual value,
39
+ which is drawn from the corresponding data class.
40
+
41
+ Each point in a scalar time series contains a single scalar value, as
42
+ a 64-bit floating point number. Scalars are "privileged" rather than
43
+ being subsumed under tensors because there are useful operations on
44
+ scalars that don't make sense in the general tensor case: e.g., "list
45
+ all scalar time series with tag name `accuracy` whose exponentially
46
+ weighted moving average is at least 0.999".
47
+
48
+ Each point in a tensor time series contains a tensor of arbitrary
49
+ dtype (including byte strings and text strings) and shape (including
50
+ rank-0 tensors, a.k.a. scalars). Each tensor is expected to be
51
+ "reasonably small" to accommodate common database cell size limits.
52
+ For instance, a histogram with a bounded number of buckets (say, 30)
53
+ occupies about 500 bytes, and a PR curve with a bounded number of
54
+ thresholds (say, 201) occupies about 5000 bytes. These are both well
55
+ within typical database tolerances (Google Cloud Spanner: 10 MiB;
56
+ MySQL: 64 KiB), and would be appropriate to store as tensors. By
57
+ contrast, image, audio, or model graph data may easily be multiple
58
+ megabytes in size, and so should be stored as blobs instead. The
59
+ tensors at each step in a time series need not have the same dtype or
60
+ shape.
61
+
62
+ Each point in a blob sequence time series contains an ordered sequence
63
+ of zero or more blobs, which are arbitrary data with no tensor
64
+ structure. These might represent PNG-encoded image data, protobuf wire
65
+ encodings of TensorFlow graphs, or PLY-format 3D mesh data, for some
66
+ examples. This data class provides blob *sequences* rather than just
67
+ blobs because it's common to want to take multiple homogeneous samples
68
+ of a given time series: say, "show me the bounding box classifications
69
+ for 3 random inputs from this batch". A single blob can of course be
70
+ represented as a blob sequence that always has exactly one element.
71
+
72
+ When reading time series, *downsampling* refers to selecting a
73
+ subset of the points in each time series. Downsampling only occurs
74
+ across the step axis (rather than, e.g., the blobs in a single blob
75
+ sequence datum), and occurs individually within each time series.
76
+ When downsampling, the latest datum should always be included in the
77
+ sample, so that clients have a view of metrics that is maximally up
78
+ to date. Implementations may choose to force the first (oldest)
79
+ datum to be included in each sample as well, but this is not
80
+ required; clients should not make assumptions either way. The
81
+ remainder of the points in the sample should be selected uniformly
82
+ at random from available points. Downsampling should be
83
+ deterministic within a time series. It is also useful for the
84
+ downsampling behavior to depend only on the set of step values
85
+ within a time series, such that two "parallel" time series with data
86
+ at exactly the same steps also retain the same steps after
87
+ downsampling.
88
+
89
+ Every time series belongs to a specific experiment and is owned by a
90
+ specific plugin. (Thus, the "primary key" for a time series has four
91
+ components: experiment, plugin, run, tag.) The experiment ID is an
92
+ arbitrary URL-safe non-empty text string, whose interpretation is at
93
+ the discretion of the data provider. As a special case, the empty
94
+ string as an experiment ID denotes that no experiment was given. Data
95
+ providers may or may not fully support an empty experiment ID. The
96
+ plugin name should correspond to the `plugin_data.plugin_name` field
97
+ of the `SummaryMetadata` proto passed to `tf.summary.write`.
98
+
99
+ Additionally, the data provider interface specifies one *hyperparameter*
100
+ class, which is metadata about the parameters used to generate the data for
101
+ one or more runs within one or more experiments. Each hyperparameter has a
102
+ value type -- one of string, bool, and float. Each one also has a domain,
103
+ which describes the set of known values for that hyperparameter across the
104
+ given set of experiments.
105
+
106
+ There is a corresponding *hyperparameter value* class, which describes an
107
+ actual value of a hyperparameter that was logged during experiment
108
+ execution.
109
+
110
+ Each run within an experiment may specify its own value for a
111
+ hyperparameter. Runs that were logically executed together with the same set
112
+ of hyperparameter values form a hyperparameter `session`. Sessions that
113
+ include the same hyperparameter values can be grouped together in a
114
+ hyperparameter `session group`. Often a session group will contain only a
115
+ single session. However, in some scenarios, the same hyperparameters will be
116
+ used to execute multiple jobs with the idea to aggregate the metrics across
117
+ those jobs and analyze non-deterministic factors. In that case, a session
118
+ group will contain multiple sessions. The result will group runs by
119
+ hyperparameter session group and provide one set of hyperparameter values
120
+ for each group.
121
+
122
+ All methods on this class take a `RequestContext` parameter as the
123
+ first positional argument. This argument is temporarily optional to
124
+ facilitate migration, but will be required in the future.
125
+
126
+ Unless otherwise noted, any methods on this class may raise errors
127
+ defined in `tensorboard.errors`, like `tensorboard.errors.NotFoundError`.
128
+
129
+ If not implemented, optional methods may return `None`.
130
+ """
131
+
132
+ def experiment_metadata(self, ctx=None, *, experiment_id):
133
+ """Retrieve metadata of a given experiment.
134
+
135
+ The metadata may include fields such as name and description
136
+ of the experiment, as well as a timestamp for the experiment.
137
+
138
+ Args:
139
+ ctx: A TensorBoard `RequestContext` value.
140
+ experiment_id: ID of the experiment in question.
141
+
142
+ Returns:
143
+ An `ExperimentMetadata` object containing metadata about the
144
+ experiment.
145
+ """
146
+ return ExperimentMetadata()
147
+
148
+ def list_plugins(self, ctx=None, *, experiment_id):
149
+ """List all plugins that own data in a given experiment.
150
+
151
+ This should be the set of all plugin names `p` such that calling
152
+ `list_scalars`, `list_tensors`, or `list_blob_sequences` for the
153
+ given `experiment_id` and plugin name `p` gives a non-empty
154
+ result.
155
+
156
+ This operation is optional, but may later become required.
157
+
158
+ Args:
159
+ ctx: A TensorBoard `RequestContext` value.
160
+ experiment_id: ID of enclosing experiment.
161
+
162
+ Returns:
163
+ A collection of strings representing plugin names, or `None`
164
+ if this operation is not supported by this data provider.
165
+ """
166
+ return None
167
+
168
+ @abc.abstractmethod
169
+ def list_runs(self, ctx=None, *, experiment_id):
170
+ """List all runs within an experiment.
171
+
172
+ Args:
173
+ ctx: A TensorBoard `RequestContext` value.
174
+ experiment_id: ID of enclosing experiment.
175
+
176
+ Returns:
177
+ A collection of `Run` values.
178
+
179
+ Raises:
180
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
181
+ """
182
+ pass
183
+
184
+ @abc.abstractmethod
185
+ def list_scalars(
186
+ self, ctx=None, *, experiment_id, plugin_name, run_tag_filter=None
187
+ ):
188
+ """List metadata about scalar time series.
189
+
190
+ Args:
191
+ ctx: A TensorBoard `RequestContext` value.
192
+ experiment_id: ID of enclosing experiment.
193
+ plugin_name: String name of the TensorBoard plugin that created
194
+ the data to be queried. Required.
195
+ run_tag_filter: Optional `RunTagFilter` value. If omitted, all
196
+ runs and tags will be included.
197
+
198
+ The result will only contain keys for run-tag combinations that
199
+ actually exist, which may not include all entries in the
200
+ `run_tag_filter`.
201
+
202
+ Returns:
203
+ A nested map `d` such that `d[run][tag]` is a `ScalarTimeSeries`
204
+ value.
205
+
206
+ Raises:
207
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
208
+ """
209
+ pass
210
+
211
+ @abc.abstractmethod
212
+ def read_scalars(
213
+ self,
214
+ ctx=None,
215
+ *,
216
+ experiment_id,
217
+ plugin_name,
218
+ downsample=None,
219
+ run_tag_filter=None,
220
+ ):
221
+ """Read values from scalar time series.
222
+
223
+ Args:
224
+ ctx: A TensorBoard `RequestContext` value.
225
+ experiment_id: ID of enclosing experiment.
226
+ plugin_name: String name of the TensorBoard plugin that created
227
+ the data to be queried. Required.
228
+ downsample: Integer number of steps to which to downsample the
229
+ results (e.g., `1000`). The most recent datum (last scalar)
230
+ should always be included. See `DataProvider` class docstring
231
+ for details about this parameter. Required.
232
+ run_tag_filter: Optional `RunTagFilter` value. If provided, a time
233
+ series will only be included in the result if its run and tag
234
+ both pass this filter. If `None`, all time series will be
235
+ included.
236
+
237
+ The result will only contain keys for run-tag combinations that
238
+ actually exist, which may not include all entries in the
239
+ `run_tag_filter`.
240
+
241
+ Returns:
242
+ A nested map `d` such that `d[run][tag]` is a list of
243
+ `ScalarDatum` values sorted by step.
244
+
245
+ Raises:
246
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
247
+ """
248
+ pass
249
+
250
+ @abc.abstractmethod
251
+ def read_last_scalars(
252
+ self,
253
+ ctx=None,
254
+ *,
255
+ experiment_id,
256
+ plugin_name,
257
+ run_tag_filter=None,
258
+ ):
259
+ """Read the most recent values from scalar time series.
260
+
261
+ The most recent scalar value for each tag under each run is retrieved
262
+ from the latest event (at the latest timestamp). Note that this is
263
+ different from the sorting used in `read_scalars`, which is by step.
264
+ This was an accidental misalignment that would need considerable effort
265
+ to change across our implementations, so we're leaving it as is for now.
266
+ In most cases this should not matter, but if the same log dir is used
267
+ for multiple runs, this might not match the last data point returned by
268
+ the `read_scalars`.
269
+
270
+ Args:
271
+ ctx: A TensorBoard `RequestContext` value.
272
+ experiment_id: ID of enclosing experiment.
273
+ plugin_name: String name of the TensorBoard plugin that created
274
+ the data to be queried. Required.
275
+ run_tag_filter: Optional `RunTagFilter` value. If provided, a datum
276
+ series will only be included in the result if its run and tag
277
+ both pass this filter. If `None`, all time series will be
278
+ included.
279
+
280
+ The result will only contain keys for run-tag combinations that
281
+ actually exist, which may not include all entries in the
282
+ `run_tag_filter`.
283
+
284
+ Returns:
285
+ A nested map `d` such that `d[run][tag]` is a `ScalarDatum`
286
+ representing the latest scalar in the time series.
287
+
288
+ Raises:
289
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
290
+ """
291
+ pass
292
+
293
+ def list_tensors(
294
+ self, ctx=None, *, experiment_id, plugin_name, run_tag_filter=None
295
+ ):
296
+ """List metadata about tensor time series.
297
+
298
+ Args:
299
+ ctx: A TensorBoard `RequestContext` value.
300
+ experiment_id: ID of enclosing experiment.
301
+ plugin_name: String name of the TensorBoard plugin that created
302
+ the data to be queried. Required.
303
+ run_tag_filter: Optional `RunTagFilter` value. If omitted, all
304
+ runs and tags will be included.
305
+
306
+ The result will only contain keys for run-tag combinations that
307
+ actually exist, which may not include all entries in the
308
+ `run_tag_filter`.
309
+
310
+ Returns:
311
+ A nested map `d` such that `d[run][tag]` is a `TensorTimeSeries`
312
+ value.
313
+
314
+ Raises:
315
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
316
+ """
317
+ pass
318
+
319
+ def read_tensors(
320
+ self,
321
+ ctx=None,
322
+ *,
323
+ experiment_id,
324
+ plugin_name,
325
+ downsample=None,
326
+ run_tag_filter=None,
327
+ ):
328
+ """Read values from tensor time series.
329
+
330
+ Args:
331
+ ctx: A TensorBoard `RequestContext` value.
332
+ experiment_id: ID of enclosing experiment.
333
+ plugin_name: String name of the TensorBoard plugin that created
334
+ the data to be queried. Required.
335
+ downsample: Integer number of steps to which to downsample the
336
+ results (e.g., `1000`). See `DataProvider` class docstring
337
+ for details about this parameter. Required.
338
+ run_tag_filter: Optional `RunTagFilter` value. If provided, a time
339
+ series will only be included in the result if its run and tag
340
+ both pass this filter. If `None`, all time series will be
341
+ included.
342
+
343
+ The result will only contain keys for run-tag combinations that
344
+ actually exist, which may not include all entries in the
345
+ `run_tag_filter`.
346
+
347
+ Returns:
348
+ A nested map `d` such that `d[run][tag]` is a list of
349
+ `TensorDatum` values sorted by step.
350
+
351
+ Raises:
352
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
353
+ """
354
+ pass
355
+
356
+ def list_blob_sequences(
357
+ self, ctx=None, *, experiment_id, plugin_name, run_tag_filter=None
358
+ ):
359
+ """List metadata about blob sequence time series.
360
+
361
+ Args:
362
+ ctx: A TensorBoard `RequestContext` value.
363
+ experiment_id: ID of enclosing experiment.
364
+ plugin_name: String name of the TensorBoard plugin that created the data
365
+ to be queried. Required.
366
+ run_tag_filter: Optional `RunTagFilter` value. If omitted, all runs and
367
+ tags will be included. The result will only contain keys for run-tag
368
+ combinations that actually exist, which may not include all entries in
369
+ the `run_tag_filter`.
370
+
371
+ Returns:
372
+ A nested map `d` such that `d[run][tag]` is a `BlobSequenceTimeSeries`
373
+ value.
374
+
375
+ Raises:
376
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
377
+ """
378
+ pass
379
+
380
+ def read_blob_sequences(
381
+ self,
382
+ ctx=None,
383
+ *,
384
+ experiment_id,
385
+ plugin_name,
386
+ downsample=None,
387
+ run_tag_filter=None,
388
+ ):
389
+ """Read values from blob sequence time series.
390
+
391
+ Args:
392
+ ctx: A TensorBoard `RequestContext` value.
393
+ experiment_id: ID of enclosing experiment.
394
+ plugin_name: String name of the TensorBoard plugin that created the data
395
+ to be queried. Required.
396
+ downsample: Integer number of steps to which to downsample the
397
+ results (e.g., `1000`). See `DataProvider` class docstring
398
+ for details about this parameter. Required.
399
+ run_tag_filter: Optional `RunTagFilter` value. If provided, a time series
400
+ will only be included in the result if its run and tag both pass this
401
+ filter. If `None`, all time series will be included. The result will
402
+ only contain keys for run-tag combinations that actually exist, which
403
+ may not include all entries in the `run_tag_filter`.
404
+
405
+ Returns:
406
+ A nested map `d` such that `d[run][tag]` is a list of
407
+ `BlobSequenceDatum` values sorted by step.
408
+
409
+ Raises:
410
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
411
+ """
412
+ pass
413
+
414
+ def read_blob(self, ctx=None, *, blob_key):
415
+ """Read data for a single blob.
416
+
417
+ Args:
418
+ ctx: A TensorBoard `RequestContext` value.
419
+ blob_key: A key identifying the desired blob, as provided by
420
+ `read_blob_sequences(...)`.
421
+
422
+ Returns:
423
+ Raw binary data as `bytes`.
424
+
425
+ Raises:
426
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
427
+ """
428
+ pass
429
+
430
+ def list_hyperparameters(self, ctx=None, *, experiment_ids, limit=None):
431
+ """List hyperparameters metadata.
432
+
433
+ Args:
434
+ ctx: A TensorBoard `RequestContext` value.
435
+ experiment_ids: A Collection[string] of IDs of the enclosing
436
+ experiments.
437
+ limit: Optional number of hyperparameter metadata to include in the
438
+ result. If unset or zero, all metadata will be included.
439
+
440
+ Returns:
441
+ A ListHyperparametersResult describing the hyperparameter-related
442
+ metadata for the experiments.
443
+
444
+ Raises:
445
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
446
+ """
447
+ return ListHyperparametersResult(hyperparameters=[], session_groups=[])
448
+
449
+ def read_hyperparameters(
450
+ self,
451
+ ctx=None,
452
+ *,
453
+ experiment_ids,
454
+ filters=None,
455
+ sort=None,
456
+ hparams_to_include=None,
457
+ ):
458
+ """Read hyperparameter values.
459
+
460
+ Args:
461
+ ctx: A TensorBoard `RequestContext` value.
462
+ experiment_ids: A Collection[string] of IDs of the enclosing
463
+ experiments.
464
+ filters: A Collection[HyperparameterFilter] that constrain the
465
+ returned session groups based on hyperparameter value.
466
+ sort: A Sequence[HyperparameterSort] that specify how the results
467
+ should be sorted.
468
+ hparams_to_include: An optional Collection[str] of the full names of
469
+ hyperparameters to include in the results. This collection will be
470
+ augmented to include all the hyperparameters specified in `filters`
471
+ and `sort`. If None, all hyperparameters will be returned.
472
+
473
+ Returns:
474
+ A Sequence[HyperparameterSessionGroup] describing the groups and
475
+ their hyperparameter values.
476
+
477
+ Raises:
478
+ tensorboard.errors.PublicError: See `DataProvider` class docstring.
479
+ """
480
+ return []
481
+
482
+
483
+ class ExperimentMetadata:
484
+ """Metadata about an experiment.
485
+
486
+ All fields have default values: i.e., they will always be present on
487
+ the object, but may be omitted in a constructor call.
488
+
489
+ Attributes:
490
+ data_location: A human-readable description of the data source, such as a
491
+ path to a directory on disk.
492
+ experiment_name: A user-facing name for the experiment (as a `str`).
493
+ experiment_description: A user-facing description for the experiment
494
+ (as a `str`).
495
+ creation_time: A timestamp for the creation of the experiment, as `float`
496
+ seconds since the epoch.
497
+ """
498
+
499
+ def __init__(
500
+ self,
501
+ *,
502
+ data_location="",
503
+ experiment_name="",
504
+ experiment_description="",
505
+ creation_time=0,
506
+ ):
507
+ self._data_location = data_location
508
+ self._experiment_name = experiment_name
509
+ self._experiment_description = experiment_description
510
+ self._creation_time = creation_time
511
+
512
+ @property
513
+ def data_location(self):
514
+ return self._data_location
515
+
516
+ @property
517
+ def experiment_name(self):
518
+ return self._experiment_name
519
+
520
+ @property
521
+ def experiment_description(self):
522
+ return self._experiment_description
523
+
524
+ @property
525
+ def creation_time(self):
526
+ return self._creation_time
527
+
528
+ def _as_tuple(self):
529
+ """Helper for `__eq__` and `__hash__`."""
530
+ return (
531
+ self._data_location,
532
+ self._experiment_name,
533
+ self._experiment_description,
534
+ self._creation_time,
535
+ )
536
+
537
+ def __eq__(self, other):
538
+ if not isinstance(other, ExperimentMetadata):
539
+ return False
540
+ return self._as_tuple() == other._as_tuple()
541
+
542
+ def __hash__(self):
543
+ return hash(self._as_tuple())
544
+
545
+ def __repr__(self):
546
+ return "ExperimentMetadata(%s)" % ", ".join(
547
+ (
548
+ "data_location=%r" % (self.data_location,),
549
+ "experiment_name=%r" % (self._experiment_name,),
550
+ "experiment_description=%r" % (self._experiment_description,),
551
+ "creation_time=%r" % (self._creation_time,),
552
+ )
553
+ )
554
+
555
+
556
+ class Run:
557
+ """Metadata about a run.
558
+
559
+ Attributes:
560
+ run_id: A unique opaque string identifier for this run.
561
+ run_name: A user-facing name for this run (as a `str`).
562
+ start_time: The wall time of the earliest recorded event in this
563
+ run, as `float` seconds since epoch, or `None` if this run has no
564
+ recorded events.
565
+ """
566
+
567
+ __slots__ = ("_run_id", "_run_name", "_start_time")
568
+
569
+ def __init__(self, run_id, run_name, start_time):
570
+ self._run_id = run_id
571
+ self._run_name = run_name
572
+ self._start_time = start_time
573
+
574
+ @property
575
+ def run_id(self):
576
+ return self._run_id
577
+
578
+ @property
579
+ def run_name(self):
580
+ return self._run_name
581
+
582
+ @property
583
+ def start_time(self):
584
+ return self._start_time
585
+
586
+ def __eq__(self, other):
587
+ if not isinstance(other, Run):
588
+ return False
589
+ if self._run_id != other._run_id:
590
+ return False
591
+ if self._run_name != other._run_name:
592
+ return False
593
+ if self._start_time != other._start_time:
594
+ return False
595
+ return True
596
+
597
+ def __hash__(self):
598
+ return hash((self._run_id, self._run_name, self._start_time))
599
+
600
+ def __repr__(self):
601
+ return "Run(%s)" % ", ".join(
602
+ (
603
+ "run_id=%r" % (self._run_id,),
604
+ "run_name=%r" % (self._run_name,),
605
+ "start_time=%r" % (self._start_time,),
606
+ )
607
+ )
608
+
609
+
610
+ class HyperparameterDomainType(enum.Enum):
611
+ """Describes how to represent the set of known values for a hyperparameter."""
612
+
613
+ # A range of numeric values. Normally represented as Tuple[float, float].
614
+ INTERVAL = "interval"
615
+ # A finite set of numeric values. Normally represented as Collection[float].
616
+ DISCRETE_FLOAT = "discrete_float"
617
+ # A finite set of string values. Normally represented as Collection[string].
618
+ DISCRETE_STRING = "discrete_string"
619
+ # A finite set of bool values. Normally represented as Collection[bool].
620
+ DISCRETE_BOOL = "discrete_bool"
621
+
622
+
623
+ @dataclasses.dataclass(frozen=True)
624
+ class Hyperparameter:
625
+ """Metadata about a hyperparameter.
626
+
627
+ Attributes:
628
+ hyperparameter_name: A string identifier for the hyperparameter that
629
+ should be unique in any result set of Hyperparameter objects.
630
+ hyperparameter_display_name: A displayable name for the hyperparameter.
631
+ Unlike hyperparameter_name, there is no uniqueness constraint.
632
+ domain_type: A HyperparameterDomainType describing how we represent the
633
+ set of known values in the `domain` attribute.
634
+ domain: A representation of the set of known values for the
635
+ hyperparameter.
636
+
637
+ If domain_type is INTERVAL, a Tuple[float, float] describing the
638
+ range of numeric values.
639
+ If domain_type is DISCRETE_FLOAT, a Collection[float] describing the
640
+ finite set of numeric values.
641
+ If domain_type is DISCRETE_STRING, a Collection[string] describing the
642
+ finite set of string values.
643
+ If domain_type is DISCRETE_BOOL, a Collection[bool] describing the
644
+ finite set of bool values.
645
+
646
+ differs: Describes whether there are two or more known values for the
647
+ hyperparameter for the set of experiments specified in the
648
+ list_hyperparameters() request. Hyperparameters for which this is
649
+ true are made more prominent or easier to discover in the UI.
650
+ """
651
+
652
+ hyperparameter_name: str
653
+ hyperparameter_display_name: str
654
+ domain_type: Union[HyperparameterDomainType, None] = None
655
+ domain: Union[
656
+ Tuple[float, float],
657
+ Collection[float],
658
+ Collection[str],
659
+ Collection[bool],
660
+ None,
661
+ ] = None
662
+ differs: bool = False
663
+
664
+
665
+ @dataclasses.dataclass(frozen=True)
666
+ class HyperparameterValue:
667
+ """A hyperparameter value.
668
+
669
+ Attributes:
670
+ hyperparameter_name: A string identifier for the hyperparameters. It
671
+ corresponds to the hyperparameter_name field in the Hyperparameter
672
+ class.
673
+ domain_type: A HyperparameterDomainType describing how we represent the
674
+ set of known values in the `domain` attribute.
675
+ value: The value of the hyperparameter.
676
+
677
+ If domain_type is INTERVAL or DISCRETE_FLOAT, value is a float.
678
+ If domain_type is DISCRETE_STRING, value is a str.
679
+ If domain_type is DISCRETE_BOOL, value is a bool.
680
+ If domain_type is unknown (None), value is None.
681
+ """
682
+
683
+ hyperparameter_name: str
684
+ domain_type: Union[HyperparameterDomainType, None] = None
685
+ value: Union[float, str, bool, None] = None
686
+
687
+
688
+ @dataclasses.dataclass(frozen=True)
689
+ class HyperparameterSessionRun:
690
+ """A single run in a HyperparameterSessionGroup.
691
+
692
+ Attributes:
693
+ experiment_id: The id of the experiment to which the run belongs.
694
+ run: The name of the run.
695
+ """
696
+
697
+ experiment_id: str
698
+ run: str
699
+
700
+
701
+ @dataclasses.dataclass(frozen=True)
702
+ class HyperparameterSessionGroup:
703
+ """A group of sessions logically executed together with the same hparam values.
704
+
705
+ A `session` generally represents a particular execution of a job with a given
706
+ set of hyperparameter values. A session may contain multiple related runs
707
+ executed together to train and/or validate a model.
708
+
709
+ Often a `session group` will contain only a single session. However, in some
710
+ scenarios, the same hyperparameters will be used to execute multiple jobs
711
+ with the idea to aggregate the metrics across those jobs and analyze
712
+ non-deterministic factors. In that case, a session group will contain multiple
713
+ sessions.
714
+
715
+ Attributes:
716
+ root: A descriptor of the common ancestor of all sessions in this
717
+ group.
718
+
719
+ In the case where the group contains all runs in the experiment, this
720
+ would just be a HyperparameterSessionRun with the experiment_id property
721
+ set to the experiment's id but run property set to empty.
722
+
723
+ In the case where the group contains a subset of runs in the experiment,
724
+ this would be a HyperparameterSessionRun with the experiment_id property
725
+ set and the run property set to the largest common prefix for runs.
726
+
727
+ The root might correspond to a session within the group but it is not
728
+ necessary.
729
+ sessions: A sequence of all sessions in this group.
730
+ hyperparameter_values: A collection of all hyperparameter values in this
731
+ group.
732
+ """
733
+
734
+ root: HyperparameterSessionRun
735
+ sessions: Sequence[HyperparameterSessionRun]
736
+ hyperparameter_values: Collection[HyperparameterValue]
737
+
738
+
739
+ class HyperparameterFilterType(enum.Enum):
740
+ """Describes how to represent filter values."""
741
+
742
+ # A regular expression string. Normally represented as str.
743
+ REGEX = "regex"
744
+ # A range of numeric values. Normally represented as Tuple[float, float].
745
+ INTERVAL = "interval"
746
+ # A finite set of values. Normally represented as Collection[float|str|bool].
747
+ DISCRETE = "discrete"
748
+
749
+
750
+ @dataclasses.dataclass(frozen=True)
751
+ class HyperparameterFilter:
752
+ """A constraint based on hyperparameter value.
753
+
754
+ Attributes:
755
+ hyperparameter_name: A string identifier for the hyperparameter to use for
756
+ the filter. It corresponds to the hyperparameter_name field in the
757
+ Hyperparameter class.
758
+ filter_type: A HyperparameterFilterType describing how we represent the
759
+ filter values in the 'filter' attribute.
760
+ filter: A representation of the set of the filter values.
761
+
762
+ If filter_type is REGEX, a str containing the regular expression.
763
+ If filter_type is INTERVAL, a Tuple[float, float] describing the min and
764
+ max values of the filter interval.
765
+ If filter_type is DISCRETE a Collection[float|str|bool] describing the
766
+ finite set of filter values.
767
+ """
768
+
769
+ hyperparameter_name: str
770
+ filter_type: HyperparameterFilterType
771
+ filter: Union[
772
+ str,
773
+ Tuple[float, float],
774
+ Collection[Union[float, str, bool]],
775
+ ]
776
+
777
+
778
+ class HyperparameterSortDirection(enum.Enum):
779
+ """Describes which direction to sort a value."""
780
+
781
+ # Sort values ascending.
782
+ ASCENDING = "ascending"
783
+ # Sort values descending.
784
+ DESCENDING = "descending"
785
+
786
+
787
+ @dataclasses.dataclass(frozen=True)
788
+ class HyperparameterSort:
789
+ """A sort criterium based on hyperparameter value.
790
+
791
+ Attributes:
792
+ hyperparameter_name: A string identifier for the hyperparameter to use for
793
+ the sort. It corresponds to the hyperparameter_name field in the
794
+ Hyperparameter class.
795
+ sort_direction: The direction to sort.
796
+ """
797
+
798
+ hyperparameter_name: str
799
+ sort_direction: HyperparameterSortDirection
800
+
801
+
802
+ @dataclasses.dataclass(frozen=True)
803
+ class ListHyperparametersResult:
804
+ """The result from calling list_hyperparameters().
805
+
806
+ Attributes:
807
+ hyperparameters: The hyperparameteres belonging to the experiments in the
808
+ request.
809
+ session_groups: The session groups present in the experiments in the
810
+ request.
811
+ """
812
+
813
+ hyperparameters: Collection[Hyperparameter]
814
+ session_groups: Collection[HyperparameterSessionGroup]
815
+
816
+
817
+ class _TimeSeries:
818
+ """Metadata about time series data for a particular run and tag.
819
+
820
+ Superclass of `ScalarTimeSeries`, `TensorTimeSeries`, and
821
+ `BlobSequenceTimeSeries`.
822
+ """
823
+
824
+ __slots__ = (
825
+ "_max_step",
826
+ "_max_wall_time",
827
+ "_plugin_content",
828
+ "_description",
829
+ "_display_name",
830
+ "_last_value",
831
+ )
832
+
833
+ def __init__(
834
+ self,
835
+ *,
836
+ max_step,
837
+ max_wall_time,
838
+ plugin_content,
839
+ description,
840
+ display_name,
841
+ last_value=None,
842
+ ):
843
+ self._max_step = max_step
844
+ self._max_wall_time = max_wall_time
845
+ self._plugin_content = plugin_content
846
+ self._description = description
847
+ self._display_name = display_name
848
+ self._last_value = last_value
849
+
850
+ @property
851
+ def max_step(self):
852
+ return self._max_step
853
+
854
+ @property
855
+ def max_wall_time(self):
856
+ return self._max_wall_time
857
+
858
+ @property
859
+ def plugin_content(self):
860
+ return self._plugin_content
861
+
862
+ @property
863
+ def description(self):
864
+ return self._description
865
+
866
+ @property
867
+ def display_name(self):
868
+ return self._display_name
869
+
870
+ @property
871
+ def last_value(self):
872
+ return self._last_value
873
+
874
+
875
+ class ScalarTimeSeries(_TimeSeries):
876
+ """Metadata about a scalar time series for a particular run and tag.
877
+
878
+ Attributes:
879
+ max_step: The largest step value of any datum in this scalar time series; a
880
+ nonnegative integer.
881
+ max_wall_time: The largest wall time of any datum in this time series, as
882
+ `float` seconds since epoch.
883
+ plugin_content: A bytestring of arbitrary plugin-specific metadata for this
884
+ time series, as provided to `tf.summary.write` in the
885
+ `plugin_data.content` field of the `metadata` argument.
886
+ description: An optional long-form Markdown description, as a `str` that is
887
+ empty if no description was specified.
888
+ display_name: An optional long-form Markdown description, as a `str` that is
889
+ empty if no description was specified. Deprecated; may be removed soon.
890
+ last_value: An optional value for the latest scalar in the time series,
891
+ corresponding to the scalar at `max_step`. Note that this field might NOT
892
+ be populated by all data provider implementations.
893
+ """
894
+
895
+ def __eq__(self, other):
896
+ if not isinstance(other, ScalarTimeSeries):
897
+ return False
898
+ if self._max_step != other._max_step:
899
+ return False
900
+ if self._max_wall_time != other._max_wall_time:
901
+ return False
902
+ if self._plugin_content != other._plugin_content:
903
+ return False
904
+ if self._description != other._description:
905
+ return False
906
+ if self._display_name != other._display_name:
907
+ return False
908
+ if self._last_value != other._last_value:
909
+ return False
910
+ return True
911
+
912
+ def __hash__(self):
913
+ return hash(
914
+ (
915
+ self._max_step,
916
+ self._max_wall_time,
917
+ self._plugin_content,
918
+ self._description,
919
+ self._display_name,
920
+ self._last_value,
921
+ )
922
+ )
923
+
924
+ def __repr__(self):
925
+ return "ScalarTimeSeries(%s)" % ", ".join(
926
+ (
927
+ "max_step=%r" % (self._max_step,),
928
+ "max_wall_time=%r" % (self._max_wall_time,),
929
+ "plugin_content=%r" % (self._plugin_content,),
930
+ "description=%r" % (self._description,),
931
+ "display_name=%r" % (self._display_name,),
932
+ "last_value=%r" % (self._last_value,),
933
+ )
934
+ )
935
+
936
+
937
+ class ScalarDatum:
938
+ """A single datum in a scalar time series for a run and tag.
939
+
940
+ Attributes:
941
+ step: The global step at which this datum occurred; an integer. This
942
+ is a unique key among data of this time series.
943
+ wall_time: The real-world time at which this datum occurred, as
944
+ `float` seconds since epoch.
945
+ value: The scalar value for this datum; a `float`.
946
+ """
947
+
948
+ __slots__ = ("_step", "_wall_time", "_value")
949
+
950
+ def __init__(self, step, wall_time, value):
951
+ self._step = step
952
+ self._wall_time = wall_time
953
+ self._value = value
954
+
955
+ @property
956
+ def step(self):
957
+ return self._step
958
+
959
+ @property
960
+ def wall_time(self):
961
+ return self._wall_time
962
+
963
+ @property
964
+ def value(self):
965
+ return self._value
966
+
967
+ def __eq__(self, other):
968
+ if not isinstance(other, ScalarDatum):
969
+ return False
970
+ if self._step != other._step:
971
+ return False
972
+ if self._wall_time != other._wall_time:
973
+ return False
974
+ if self._value != other._value:
975
+ return False
976
+ return True
977
+
978
+ def __hash__(self):
979
+ return hash((self._step, self._wall_time, self._value))
980
+
981
+ def __repr__(self):
982
+ return "ScalarDatum(%s)" % ", ".join(
983
+ (
984
+ "step=%r" % (self._step,),
985
+ "wall_time=%r" % (self._wall_time,),
986
+ "value=%r" % (self._value,),
987
+ )
988
+ )
989
+
990
+
991
+ class TensorTimeSeries(_TimeSeries):
992
+ """Metadata about a tensor time series for a particular run and tag.
993
+
994
+ Attributes:
995
+ max_step: The largest step value of any datum in this tensor time series; a
996
+ nonnegative integer.
997
+ max_wall_time: The largest wall time of any datum in this time series, as
998
+ `float` seconds since epoch.
999
+ plugin_content: A bytestring of arbitrary plugin-specific metadata for this
1000
+ time series, as provided to `tf.summary.write` in the
1001
+ `plugin_data.content` field of the `metadata` argument.
1002
+ description: An optional long-form Markdown description, as a `str` that is
1003
+ empty if no description was specified.
1004
+ display_name: An optional long-form Markdown description, as a `str` that is
1005
+ empty if no description was specified. Deprecated; may be removed soon.
1006
+ """
1007
+
1008
+ def __eq__(self, other):
1009
+ if not isinstance(other, TensorTimeSeries):
1010
+ return False
1011
+ if self._max_step != other._max_step:
1012
+ return False
1013
+ if self._max_wall_time != other._max_wall_time:
1014
+ return False
1015
+ if self._plugin_content != other._plugin_content:
1016
+ return False
1017
+ if self._description != other._description:
1018
+ return False
1019
+ if self._display_name != other._display_name:
1020
+ return False
1021
+ return True
1022
+
1023
+ def __hash__(self):
1024
+ return hash(
1025
+ (
1026
+ self._max_step,
1027
+ self._max_wall_time,
1028
+ self._plugin_content,
1029
+ self._description,
1030
+ self._display_name,
1031
+ )
1032
+ )
1033
+
1034
+ def __repr__(self):
1035
+ return "TensorTimeSeries(%s)" % ", ".join(
1036
+ (
1037
+ "max_step=%r" % (self._max_step,),
1038
+ "max_wall_time=%r" % (self._max_wall_time,),
1039
+ "plugin_content=%r" % (self._plugin_content,),
1040
+ "description=%r" % (self._description,),
1041
+ "display_name=%r" % (self._display_name,),
1042
+ )
1043
+ )
1044
+
1045
+
1046
+ class TensorDatum:
1047
+ """A single datum in a tensor time series for a run and tag.
1048
+
1049
+ Attributes:
1050
+ step: The global step at which this datum occurred; an integer. This
1051
+ is a unique key among data of this time series.
1052
+ wall_time: The real-world time at which this datum occurred, as
1053
+ `float` seconds since epoch.
1054
+ numpy: The `numpy.ndarray` value with the tensor contents of this
1055
+ datum.
1056
+ """
1057
+
1058
+ __slots__ = ("_step", "_wall_time", "_numpy")
1059
+
1060
+ def __init__(self, step, wall_time, numpy):
1061
+ self._step = step
1062
+ self._wall_time = wall_time
1063
+ self._numpy = numpy
1064
+
1065
+ @property
1066
+ def step(self):
1067
+ return self._step
1068
+
1069
+ @property
1070
+ def wall_time(self):
1071
+ return self._wall_time
1072
+
1073
+ @property
1074
+ def numpy(self):
1075
+ return self._numpy
1076
+
1077
+ def __eq__(self, other):
1078
+ if not isinstance(other, TensorDatum):
1079
+ return False
1080
+ if self._step != other._step:
1081
+ return False
1082
+ if self._wall_time != other._wall_time:
1083
+ return False
1084
+ if not np.array_equal(self._numpy, other._numpy):
1085
+ return False
1086
+ return True
1087
+
1088
+ # Unhashable type: numpy arrays are mutable.
1089
+ __hash__ = None
1090
+
1091
+ def __repr__(self):
1092
+ return "TensorDatum(%s)" % ", ".join(
1093
+ (
1094
+ "step=%r" % (self._step,),
1095
+ "wall_time=%r" % (self._wall_time,),
1096
+ "numpy=%r" % (self._numpy,),
1097
+ )
1098
+ )
1099
+
1100
+
1101
+ class BlobSequenceTimeSeries(_TimeSeries):
1102
+ """Metadata about a blob sequence time series for a particular run and tag.
1103
+
1104
+ Attributes:
1105
+ max_step: The largest step value of any datum in this scalar time series; a
1106
+ nonnegative integer.
1107
+ max_wall_time: The largest wall time of any datum in this time series, as
1108
+ `float` seconds since epoch.
1109
+ max_length: The largest length (number of blobs) of any datum in
1110
+ this scalar time series, or `None` if this time series is empty.
1111
+ plugin_content: A bytestring of arbitrary plugin-specific metadata for this
1112
+ time series, as provided to `tf.summary.write` in the
1113
+ `plugin_data.content` field of the `metadata` argument.
1114
+ description: An optional long-form Markdown description, as a `str` that is
1115
+ empty if no description was specified.
1116
+ display_name: An optional long-form Markdown description, as a `str` that is
1117
+ empty if no description was specified. Deprecated; may be removed soon.
1118
+ """
1119
+
1120
+ __slots__ = ("_max_length",)
1121
+
1122
+ def __init__(
1123
+ self,
1124
+ *,
1125
+ max_step,
1126
+ max_wall_time,
1127
+ max_length,
1128
+ plugin_content,
1129
+ description,
1130
+ display_name,
1131
+ ):
1132
+ super().__init__(
1133
+ max_step=max_step,
1134
+ max_wall_time=max_wall_time,
1135
+ plugin_content=plugin_content,
1136
+ description=description,
1137
+ display_name=display_name,
1138
+ )
1139
+ self._max_length = max_length
1140
+
1141
+ @property
1142
+ def max_length(self):
1143
+ return self._max_length
1144
+
1145
+ def __eq__(self, other):
1146
+ if not isinstance(other, BlobSequenceTimeSeries):
1147
+ return False
1148
+ if self._max_step != other._max_step:
1149
+ return False
1150
+ if self._max_wall_time != other._max_wall_time:
1151
+ return False
1152
+ if self._max_length != other._max_length:
1153
+ return False
1154
+ if self._plugin_content != other._plugin_content:
1155
+ return False
1156
+ if self._description != other._description:
1157
+ return False
1158
+ if self._display_name != other._display_name:
1159
+ return False
1160
+ return True
1161
+
1162
+ def __hash__(self):
1163
+ return hash(
1164
+ (
1165
+ self._max_step,
1166
+ self._max_wall_time,
1167
+ self._max_length,
1168
+ self._plugin_content,
1169
+ self._description,
1170
+ self._display_name,
1171
+ )
1172
+ )
1173
+
1174
+ def __repr__(self):
1175
+ return "BlobSequenceTimeSeries(%s)" % ", ".join(
1176
+ (
1177
+ "max_step=%r" % (self._max_step,),
1178
+ "max_wall_time=%r" % (self._max_wall_time,),
1179
+ "max_length=%r" % (self._max_length,),
1180
+ "plugin_content=%r" % (self._plugin_content,),
1181
+ "description=%r" % (self._description,),
1182
+ "display_name=%r" % (self._display_name,),
1183
+ )
1184
+ )
1185
+
1186
+
1187
+ class BlobReference:
1188
+ """A reference to a blob.
1189
+
1190
+ Attributes:
1191
+ blob_key: A string containing a key uniquely identifying a blob, which
1192
+ may be dereferenced via `provider.read_blob(blob_key)`.
1193
+
1194
+ These keys must be constructed such that they can be included directly in
1195
+ a URL, with no further encoding. Concretely, this means that they consist
1196
+ exclusively of "unreserved characters" per RFC 3986, namely
1197
+ [a-zA-Z0-9._~-]. These keys are case-sensitive; it may be wise for
1198
+ implementations to normalize case to reduce confusion. The empty string
1199
+ is not a valid key.
1200
+
1201
+ Blob keys must not contain information that should be kept secret.
1202
+ Privacy-sensitive applications should use random keys (e.g. UUIDs), or
1203
+ encrypt keys containing secret fields.
1204
+ url: (optional) A string containing a URL from which the blob data may be
1205
+ fetched directly, bypassing the data provider. URLs may be a vector
1206
+ for data leaks (e.g. via browser history, web proxies, etc.), so these
1207
+ URLs should not expose secret information.
1208
+ """
1209
+
1210
+ __slots__ = ("_url", "_blob_key")
1211
+
1212
+ def __init__(self, blob_key, url=None):
1213
+ self._blob_key = blob_key
1214
+ self._url = url
1215
+
1216
+ @property
1217
+ def blob_key(self):
1218
+ """Provide a key uniquely identifying a blob.
1219
+
1220
+ Callers should consider these keys to be opaque-- i.e., to have
1221
+ no intrinsic meaning. Some data providers may use random IDs;
1222
+ but others may encode information into the key, in which case
1223
+ callers must make no attempt to decode it.
1224
+ """
1225
+ return self._blob_key
1226
+
1227
+ @property
1228
+ def url(self):
1229
+ """Provide the direct-access URL for this blob, if available.
1230
+
1231
+ Note that this method is *not* expected to construct a URL to
1232
+ the data-loading endpoint provided by TensorBoard. If this
1233
+ method returns None, then the caller should proceed to use
1234
+ `blob_key()` to build the URL, as needed.
1235
+ """
1236
+ return self._url
1237
+
1238
+ def __eq__(self, other):
1239
+ if not isinstance(other, BlobReference):
1240
+ return False
1241
+ if self._blob_key != other._blob_key:
1242
+ return False
1243
+ if self._url != other._url:
1244
+ return False
1245
+ return True
1246
+
1247
+ def __hash__(self):
1248
+ return hash((self._blob_key, self._url))
1249
+
1250
+ def __repr__(self):
1251
+ return "BlobReference(%s)" % ", ".join(
1252
+ ("blob_key=%r" % (self._blob_key,), "url=%r" % (self._url,))
1253
+ )
1254
+
1255
+
1256
+ class BlobSequenceDatum:
1257
+ """A single datum in a blob sequence time series for a run and tag.
1258
+
1259
+ Attributes:
1260
+ step: The global step at which this datum occurred; an integer. This is a
1261
+ unique key among data of this time series.
1262
+ wall_time: The real-world time at which this datum occurred, as `float`
1263
+ seconds since epoch.
1264
+ values: A tuple of `BlobReference` objects, providing access to elements of
1265
+ this sequence.
1266
+ """
1267
+
1268
+ __slots__ = ("_step", "_wall_time", "_values")
1269
+
1270
+ def __init__(self, step, wall_time, values):
1271
+ self._step = step
1272
+ self._wall_time = wall_time
1273
+ self._values = values
1274
+
1275
+ @property
1276
+ def step(self):
1277
+ return self._step
1278
+
1279
+ @property
1280
+ def wall_time(self):
1281
+ return self._wall_time
1282
+
1283
+ @property
1284
+ def values(self):
1285
+ return self._values
1286
+
1287
+ def __eq__(self, other):
1288
+ if not isinstance(other, BlobSequenceDatum):
1289
+ return False
1290
+ if self._step != other._step:
1291
+ return False
1292
+ if self._wall_time != other._wall_time:
1293
+ return False
1294
+ if self._values != other._values:
1295
+ return False
1296
+ return True
1297
+
1298
+ def __hash__(self):
1299
+ return hash((self._step, self._wall_time, self._values))
1300
+
1301
+ def __repr__(self):
1302
+ return "BlobSequenceDatum(%s)" % ", ".join(
1303
+ (
1304
+ "step=%r" % (self._step,),
1305
+ "wall_time=%r" % (self._wall_time,),
1306
+ "values=%r" % (self._values,),
1307
+ )
1308
+ )
1309
+
1310
+
1311
+ class RunTagFilter:
1312
+ """Filters data by run and tag names."""
1313
+
1314
+ def __init__(self, runs=None, tags=None):
1315
+ """Construct a `RunTagFilter`.
1316
+
1317
+ A time series passes this filter if both its run *and* its tag are
1318
+ included in the corresponding whitelists.
1319
+
1320
+ Order and multiplicity are ignored; `runs` and `tags` are treated as
1321
+ sets.
1322
+
1323
+ Args:
1324
+ runs: Collection of run names, as strings, or `None` to admit all
1325
+ runs.
1326
+ tags: Collection of tag names, as strings, or `None` to admit all
1327
+ tags.
1328
+ """
1329
+ self._runs = self._parse_optional_string_set("runs", runs)
1330
+ self._tags = self._parse_optional_string_set("tags", tags)
1331
+
1332
+ def _parse_optional_string_set(self, name, value):
1333
+ if value is None:
1334
+ return None
1335
+ if isinstance(value, str):
1336
+ # Prevent confusion: strings _are_ iterable, but as
1337
+ # sequences of characters, so this likely signals an error.
1338
+ raise TypeError(
1339
+ "%s: expected `None` or collection of strings; got %r: %r"
1340
+ % (name, type(value), value)
1341
+ )
1342
+ value = frozenset(value)
1343
+ for item in value:
1344
+ if not isinstance(item, str):
1345
+ raise TypeError(
1346
+ "%s: expected `None` or collection of strings; "
1347
+ "got item of type %r: %r" % (name, type(item), item)
1348
+ )
1349
+ return value
1350
+
1351
+ @property
1352
+ def runs(self):
1353
+ return self._runs
1354
+
1355
+ @property
1356
+ def tags(self):
1357
+ return self._tags
1358
+
1359
+ def __repr__(self):
1360
+ return "RunTagFilter(%s)" % ", ".join(
1361
+ (
1362
+ "runs=%r" % (self._runs,),
1363
+ "tags=%r" % (self._tags,),
1364
+ )
1365
+ )