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.
- tensorbored/__init__.py +112 -0
- tensorbored/_vendor/__init__.py +0 -0
- tensorbored/_vendor/bleach/__init__.py +125 -0
- tensorbored/_vendor/bleach/_vendor/__init__.py +0 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/__init__.py +35 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_ihatexml.py +289 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_inputstream.py +918 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_tokenizer.py +1735 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/__init__.py +5 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/_base.py +40 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/py.py +67 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_utils.py +159 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/constants.py +2946 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/__init__.py +0 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/alphabeticalattributes.py +29 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/base.py +12 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/inject_meta_charset.py +73 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/lint.py +93 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/optionaltags.py +207 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/sanitizer.py +916 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/whitespace.py +38 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/html5parser.py +2795 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/serializer.py +409 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/__init__.py +30 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/genshi.py +54 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/sax.py +50 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/__init__.py +88 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/base.py +417 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/dom.py +239 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree.py +343 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree_lxml.py +392 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/__init__.py +154 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/base.py +252 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/dom.py +43 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree.py +131 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree_lxml.py +215 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/genshi.py +69 -0
- tensorbored/_vendor/bleach/_vendor/parse.py +1078 -0
- tensorbored/_vendor/bleach/callbacks.py +32 -0
- tensorbored/_vendor/bleach/html5lib_shim.py +757 -0
- tensorbored/_vendor/bleach/linkifier.py +633 -0
- tensorbored/_vendor/bleach/parse_shim.py +1 -0
- tensorbored/_vendor/bleach/sanitizer.py +638 -0
- tensorbored/_vendor/bleach/six_shim.py +19 -0
- tensorbored/_vendor/webencodings/__init__.py +342 -0
- tensorbored/_vendor/webencodings/labels.py +231 -0
- tensorbored/_vendor/webencodings/mklabels.py +59 -0
- tensorbored/_vendor/webencodings/x_user_defined.py +325 -0
- tensorbored/assets.py +36 -0
- tensorbored/auth.py +102 -0
- tensorbored/backend/__init__.py +0 -0
- tensorbored/backend/application.py +604 -0
- tensorbored/backend/auth_context_middleware.py +38 -0
- tensorbored/backend/client_feature_flags.py +113 -0
- tensorbored/backend/empty_path_redirect.py +46 -0
- tensorbored/backend/event_processing/__init__.py +0 -0
- tensorbored/backend/event_processing/data_ingester.py +276 -0
- tensorbored/backend/event_processing/data_provider.py +535 -0
- tensorbored/backend/event_processing/directory_loader.py +142 -0
- tensorbored/backend/event_processing/directory_watcher.py +272 -0
- tensorbored/backend/event_processing/event_accumulator.py +950 -0
- tensorbored/backend/event_processing/event_file_inspector.py +463 -0
- tensorbored/backend/event_processing/event_file_loader.py +292 -0
- tensorbored/backend/event_processing/event_multiplexer.py +521 -0
- tensorbored/backend/event_processing/event_util.py +68 -0
- tensorbored/backend/event_processing/io_wrapper.py +223 -0
- tensorbored/backend/event_processing/plugin_asset_util.py +104 -0
- tensorbored/backend/event_processing/plugin_event_accumulator.py +721 -0
- tensorbored/backend/event_processing/plugin_event_multiplexer.py +522 -0
- tensorbored/backend/event_processing/reservoir.py +266 -0
- tensorbored/backend/event_processing/tag_types.py +29 -0
- tensorbored/backend/experiment_id.py +71 -0
- tensorbored/backend/experimental_plugin.py +51 -0
- tensorbored/backend/http_util.py +263 -0
- tensorbored/backend/json_util.py +70 -0
- tensorbored/backend/path_prefix.py +67 -0
- tensorbored/backend/process_graph.py +74 -0
- tensorbored/backend/security_validator.py +202 -0
- tensorbored/compat/__init__.py +69 -0
- tensorbored/compat/proto/__init__.py +0 -0
- tensorbored/compat/proto/allocation_description_pb2.py +35 -0
- tensorbored/compat/proto/api_def_pb2.py +82 -0
- tensorbored/compat/proto/attr_value_pb2.py +80 -0
- tensorbored/compat/proto/cluster_pb2.py +58 -0
- tensorbored/compat/proto/config_pb2.py +271 -0
- tensorbored/compat/proto/coordination_config_pb2.py +45 -0
- tensorbored/compat/proto/cost_graph_pb2.py +87 -0
- tensorbored/compat/proto/cpp_shape_inference_pb2.py +70 -0
- tensorbored/compat/proto/debug_pb2.py +65 -0
- tensorbored/compat/proto/event_pb2.py +149 -0
- tensorbored/compat/proto/full_type_pb2.py +74 -0
- tensorbored/compat/proto/function_pb2.py +157 -0
- tensorbored/compat/proto/graph_debug_info_pb2.py +111 -0
- tensorbored/compat/proto/graph_pb2.py +41 -0
- tensorbored/compat/proto/histogram_pb2.py +39 -0
- tensorbored/compat/proto/meta_graph_pb2.py +254 -0
- tensorbored/compat/proto/node_def_pb2.py +61 -0
- tensorbored/compat/proto/op_def_pb2.py +81 -0
- tensorbored/compat/proto/resource_handle_pb2.py +48 -0
- tensorbored/compat/proto/rewriter_config_pb2.py +93 -0
- tensorbored/compat/proto/rpc_options_pb2.py +35 -0
- tensorbored/compat/proto/saved_object_graph_pb2.py +193 -0
- tensorbored/compat/proto/saver_pb2.py +38 -0
- tensorbored/compat/proto/step_stats_pb2.py +116 -0
- tensorbored/compat/proto/struct_pb2.py +144 -0
- tensorbored/compat/proto/summary_pb2.py +111 -0
- tensorbored/compat/proto/tensor_description_pb2.py +38 -0
- tensorbored/compat/proto/tensor_pb2.py +68 -0
- tensorbored/compat/proto/tensor_shape_pb2.py +46 -0
- tensorbored/compat/proto/tfprof_log_pb2.py +307 -0
- tensorbored/compat/proto/trackable_object_graph_pb2.py +90 -0
- tensorbored/compat/proto/types_pb2.py +105 -0
- tensorbored/compat/proto/variable_pb2.py +62 -0
- tensorbored/compat/proto/verifier_config_pb2.py +38 -0
- tensorbored/compat/proto/versions_pb2.py +35 -0
- tensorbored/compat/tensorflow_stub/__init__.py +38 -0
- tensorbored/compat/tensorflow_stub/app.py +124 -0
- tensorbored/compat/tensorflow_stub/compat/__init__.py +131 -0
- tensorbored/compat/tensorflow_stub/compat/v1/__init__.py +20 -0
- tensorbored/compat/tensorflow_stub/dtypes.py +692 -0
- tensorbored/compat/tensorflow_stub/error_codes.py +169 -0
- tensorbored/compat/tensorflow_stub/errors.py +507 -0
- tensorbored/compat/tensorflow_stub/flags.py +124 -0
- tensorbored/compat/tensorflow_stub/io/__init__.py +17 -0
- tensorbored/compat/tensorflow_stub/io/gfile.py +1011 -0
- tensorbored/compat/tensorflow_stub/pywrap_tensorflow.py +285 -0
- tensorbored/compat/tensorflow_stub/tensor_shape.py +1035 -0
- tensorbored/context.py +129 -0
- tensorbored/data/__init__.py +0 -0
- tensorbored/data/grpc_provider.py +365 -0
- tensorbored/data/ingester.py +46 -0
- tensorbored/data/proto/__init__.py +0 -0
- tensorbored/data/proto/data_provider_pb2.py +517 -0
- tensorbored/data/proto/data_provider_pb2_grpc.py +374 -0
- tensorbored/data/provider.py +1365 -0
- tensorbored/data/server_ingester.py +301 -0
- tensorbored/data_compat.py +159 -0
- tensorbored/dataclass_compat.py +224 -0
- tensorbored/default.py +124 -0
- tensorbored/errors.py +130 -0
- tensorbored/lazy.py +99 -0
- tensorbored/main.py +48 -0
- tensorbored/main_lib.py +62 -0
- tensorbored/manager.py +487 -0
- tensorbored/notebook.py +441 -0
- tensorbored/plugin_util.py +266 -0
- tensorbored/plugins/__init__.py +0 -0
- tensorbored/plugins/audio/__init__.py +0 -0
- tensorbored/plugins/audio/audio_plugin.py +229 -0
- tensorbored/plugins/audio/metadata.py +69 -0
- tensorbored/plugins/audio/plugin_data_pb2.py +37 -0
- tensorbored/plugins/audio/summary.py +230 -0
- tensorbored/plugins/audio/summary_v2.py +124 -0
- tensorbored/plugins/base_plugin.py +367 -0
- tensorbored/plugins/core/__init__.py +0 -0
- tensorbored/plugins/core/core_plugin.py +981 -0
- tensorbored/plugins/custom_scalar/__init__.py +0 -0
- tensorbored/plugins/custom_scalar/custom_scalars_plugin.py +320 -0
- tensorbored/plugins/custom_scalar/layout_pb2.py +85 -0
- tensorbored/plugins/custom_scalar/metadata.py +35 -0
- tensorbored/plugins/custom_scalar/summary.py +79 -0
- tensorbored/plugins/debugger_v2/__init__.py +0 -0
- tensorbored/plugins/debugger_v2/debug_data_multiplexer.py +631 -0
- tensorbored/plugins/debugger_v2/debug_data_provider.py +634 -0
- tensorbored/plugins/debugger_v2/debugger_v2_plugin.py +504 -0
- tensorbored/plugins/distribution/__init__.py +0 -0
- tensorbored/plugins/distribution/compressor.py +158 -0
- tensorbored/plugins/distribution/distributions_plugin.py +116 -0
- tensorbored/plugins/distribution/metadata.py +19 -0
- tensorbored/plugins/graph/__init__.py +0 -0
- tensorbored/plugins/graph/graph_util.py +129 -0
- tensorbored/plugins/graph/graphs_plugin.py +336 -0
- tensorbored/plugins/graph/keras_util.py +328 -0
- tensorbored/plugins/graph/metadata.py +42 -0
- tensorbored/plugins/histogram/__init__.py +0 -0
- tensorbored/plugins/histogram/histograms_plugin.py +144 -0
- tensorbored/plugins/histogram/metadata.py +63 -0
- tensorbored/plugins/histogram/plugin_data_pb2.py +34 -0
- tensorbored/plugins/histogram/summary.py +234 -0
- tensorbored/plugins/histogram/summary_v2.py +292 -0
- tensorbored/plugins/hparams/__init__.py +14 -0
- tensorbored/plugins/hparams/_keras.py +93 -0
- tensorbored/plugins/hparams/api.py +130 -0
- tensorbored/plugins/hparams/api_pb2.py +208 -0
- tensorbored/plugins/hparams/backend_context.py +606 -0
- tensorbored/plugins/hparams/download_data.py +158 -0
- tensorbored/plugins/hparams/error.py +26 -0
- tensorbored/plugins/hparams/get_experiment.py +71 -0
- tensorbored/plugins/hparams/hparams_plugin.py +206 -0
- tensorbored/plugins/hparams/hparams_util_pb2.py +69 -0
- tensorbored/plugins/hparams/json_format_compat.py +38 -0
- tensorbored/plugins/hparams/list_metric_evals.py +57 -0
- tensorbored/plugins/hparams/list_session_groups.py +1040 -0
- tensorbored/plugins/hparams/metadata.py +125 -0
- tensorbored/plugins/hparams/metrics.py +41 -0
- tensorbored/plugins/hparams/plugin_data_pb2.py +69 -0
- tensorbored/plugins/hparams/summary.py +205 -0
- tensorbored/plugins/hparams/summary_v2.py +597 -0
- tensorbored/plugins/image/__init__.py +0 -0
- tensorbored/plugins/image/images_plugin.py +232 -0
- tensorbored/plugins/image/metadata.py +65 -0
- tensorbored/plugins/image/plugin_data_pb2.py +34 -0
- tensorbored/plugins/image/summary.py +159 -0
- tensorbored/plugins/image/summary_v2.py +130 -0
- tensorbored/plugins/mesh/__init__.py +14 -0
- tensorbored/plugins/mesh/mesh_plugin.py +292 -0
- tensorbored/plugins/mesh/metadata.py +152 -0
- tensorbored/plugins/mesh/plugin_data_pb2.py +37 -0
- tensorbored/plugins/mesh/summary.py +251 -0
- tensorbored/plugins/mesh/summary_v2.py +214 -0
- tensorbored/plugins/metrics/__init__.py +0 -0
- tensorbored/plugins/metrics/metadata.py +17 -0
- tensorbored/plugins/metrics/metrics_plugin.py +623 -0
- tensorbored/plugins/pr_curve/__init__.py +0 -0
- tensorbored/plugins/pr_curve/metadata.py +75 -0
- tensorbored/plugins/pr_curve/plugin_data_pb2.py +34 -0
- tensorbored/plugins/pr_curve/pr_curves_plugin.py +241 -0
- tensorbored/plugins/pr_curve/summary.py +574 -0
- tensorbored/plugins/profile_redirect/__init__.py +0 -0
- tensorbored/plugins/profile_redirect/profile_redirect_plugin.py +49 -0
- tensorbored/plugins/projector/__init__.py +67 -0
- tensorbored/plugins/projector/metadata.py +26 -0
- tensorbored/plugins/projector/projector_config_pb2.py +54 -0
- tensorbored/plugins/projector/projector_plugin.py +795 -0
- tensorbored/plugins/projector/tf_projector_plugin/index.js +32 -0
- tensorbored/plugins/projector/tf_projector_plugin/projector_binary.html +524 -0
- tensorbored/plugins/projector/tf_projector_plugin/projector_binary.js +15536 -0
- tensorbored/plugins/scalar/__init__.py +0 -0
- tensorbored/plugins/scalar/metadata.py +60 -0
- tensorbored/plugins/scalar/plugin_data_pb2.py +34 -0
- tensorbored/plugins/scalar/scalars_plugin.py +181 -0
- tensorbored/plugins/scalar/summary.py +109 -0
- tensorbored/plugins/scalar/summary_v2.py +124 -0
- tensorbored/plugins/text/__init__.py +0 -0
- tensorbored/plugins/text/metadata.py +62 -0
- tensorbored/plugins/text/plugin_data_pb2.py +34 -0
- tensorbored/plugins/text/summary.py +114 -0
- tensorbored/plugins/text/summary_v2.py +124 -0
- tensorbored/plugins/text/text_plugin.py +288 -0
- tensorbored/plugins/wit_redirect/__init__.py +0 -0
- tensorbored/plugins/wit_redirect/wit_redirect_plugin.py +49 -0
- tensorbored/program.py +910 -0
- tensorbored/summary/__init__.py +35 -0
- tensorbored/summary/_output.py +124 -0
- tensorbored/summary/_tf/__init__.py +14 -0
- tensorbored/summary/_tf/summary/__init__.py +178 -0
- tensorbored/summary/_writer.py +105 -0
- tensorbored/summary/v1.py +51 -0
- tensorbored/summary/v2.py +25 -0
- tensorbored/summary/writer/__init__.py +13 -0
- tensorbored/summary/writer/event_file_writer.py +291 -0
- tensorbored/summary/writer/record_writer.py +50 -0
- tensorbored/util/__init__.py +0 -0
- tensorbored/util/encoder.py +116 -0
- tensorbored/util/grpc_util.py +311 -0
- tensorbored/util/img_mime_type_detector.py +40 -0
- tensorbored/util/io_util.py +20 -0
- tensorbored/util/lazy_tensor_creator.py +110 -0
- tensorbored/util/op_evaluator.py +104 -0
- tensorbored/util/platform_util.py +20 -0
- tensorbored/util/tb_logging.py +24 -0
- tensorbored/util/tensor_util.py +617 -0
- tensorbored/util/timing.py +122 -0
- tensorbored/version.py +21 -0
- tensorbored/webfiles.zip +0 -0
- tensorbored-2.21.0rc1769983804.dist-info/METADATA +49 -0
- tensorbored-2.21.0rc1769983804.dist-info/RECORD +271 -0
- tensorbored-2.21.0rc1769983804.dist-info/WHEEL +5 -0
- tensorbored-2.21.0rc1769983804.dist-info/entry_points.txt +6 -0
- tensorbored-2.21.0rc1769983804.dist-info/licenses/LICENSE +739 -0
- tensorbored-2.21.0rc1769983804.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright 2017 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
|
+
"""Internal information about the scalar plugin."""
|
|
16
|
+
|
|
17
|
+
from tensorbored.compat.proto import summary_pb2
|
|
18
|
+
from tensorbored.plugins.scalar import plugin_data_pb2
|
|
19
|
+
|
|
20
|
+
PLUGIN_NAME = "scalars"
|
|
21
|
+
|
|
22
|
+
# The most recent value for the `version` field of the
|
|
23
|
+
# `ScalarPluginData` proto.
|
|
24
|
+
PROTO_VERSION = 0
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def create_summary_metadata(display_name, description):
|
|
28
|
+
"""Create a `summary_pb2.SummaryMetadata` proto for scalar plugin data.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
A `summary_pb2.SummaryMetadata` protobuf object.
|
|
32
|
+
"""
|
|
33
|
+
content = plugin_data_pb2.ScalarPluginData(version=PROTO_VERSION)
|
|
34
|
+
metadata = summary_pb2.SummaryMetadata(
|
|
35
|
+
display_name=display_name,
|
|
36
|
+
summary_description=description,
|
|
37
|
+
plugin_data=summary_pb2.SummaryMetadata.PluginData(
|
|
38
|
+
plugin_name=PLUGIN_NAME, content=content.SerializeToString()
|
|
39
|
+
),
|
|
40
|
+
)
|
|
41
|
+
return metadata
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def parse_plugin_metadata(content):
|
|
45
|
+
"""Parse summary metadata to a Python object.
|
|
46
|
+
|
|
47
|
+
Arguments:
|
|
48
|
+
content: The `content` field of a `SummaryMetadata` proto
|
|
49
|
+
corresponding to the scalar plugin.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
A `ScalarPluginData` protobuf object.
|
|
53
|
+
"""
|
|
54
|
+
if not isinstance(content, bytes):
|
|
55
|
+
raise TypeError("Content type must be bytes")
|
|
56
|
+
result = plugin_data_pb2.ScalarPluginData.FromString(content)
|
|
57
|
+
if result.version == 0:
|
|
58
|
+
return result
|
|
59
|
+
# No other versions known at this time, so no migrations to do.
|
|
60
|
+
return result
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: tensorbored/plugins/scalar/plugin_data.proto
|
|
4
|
+
"""Generated protocol buffer code."""
|
|
5
|
+
from google.protobuf import descriptor as _descriptor
|
|
6
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
7
|
+
from google.protobuf import message as _message
|
|
8
|
+
from google.protobuf import reflection as _reflection
|
|
9
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
10
|
+
# @@protoc_insertion_point(imports)
|
|
11
|
+
|
|
12
|
+
_sym_db = _symbol_database.Default()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n,tensorbored/plugins/scalar/plugin_data.proto\x12\x0btensorbored\"#\n\x10ScalarPluginData\x12\x0f\n\x07version\x18\x01 \x01(\x05\x62\x06proto3')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
_SCALARPLUGINDATA = DESCRIPTOR.message_types_by_name['ScalarPluginData']
|
|
22
|
+
ScalarPluginData = _reflection.GeneratedProtocolMessageType('ScalarPluginData', (_message.Message,), {
|
|
23
|
+
'DESCRIPTOR' : _SCALARPLUGINDATA,
|
|
24
|
+
'__module__' : 'tensorbored.plugins.scalar.plugin_data_pb2'
|
|
25
|
+
# @@protoc_insertion_point(class_scope:tensorbored.ScalarPluginData)
|
|
26
|
+
})
|
|
27
|
+
_sym_db.RegisterMessage(ScalarPluginData)
|
|
28
|
+
|
|
29
|
+
if _descriptor._USE_C_DESCRIPTORS == False:
|
|
30
|
+
|
|
31
|
+
DESCRIPTOR._options = None
|
|
32
|
+
_SCALARPLUGINDATA._serialized_start=61
|
|
33
|
+
_SCALARPLUGINDATA._serialized_end=96
|
|
34
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Copyright 2017 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
|
+
"""The TensorBoard Scalars plugin.
|
|
16
|
+
|
|
17
|
+
See `http_api.md` in this directory for specifications of the routes for
|
|
18
|
+
this plugin.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import csv
|
|
22
|
+
import io
|
|
23
|
+
|
|
24
|
+
import werkzeug.exceptions
|
|
25
|
+
from werkzeug import wrappers
|
|
26
|
+
|
|
27
|
+
from tensorbored import errors
|
|
28
|
+
from tensorbored import plugin_util
|
|
29
|
+
from tensorbored.backend import http_util
|
|
30
|
+
from tensorbored.data import provider
|
|
31
|
+
from tensorbored.plugins import base_plugin
|
|
32
|
+
from tensorbored.plugins.scalar import metadata
|
|
33
|
+
|
|
34
|
+
_DEFAULT_DOWNSAMPLING = 1000 # scalars per time series
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class OutputFormat:
|
|
38
|
+
"""An enum used to list the valid output formats for API calls."""
|
|
39
|
+
|
|
40
|
+
JSON = "json"
|
|
41
|
+
CSV = "csv"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ScalarsPlugin(base_plugin.TBPlugin):
|
|
45
|
+
"""Scalars Plugin for TensorBoard."""
|
|
46
|
+
|
|
47
|
+
plugin_name = metadata.PLUGIN_NAME
|
|
48
|
+
|
|
49
|
+
def __init__(self, context):
|
|
50
|
+
"""Instantiates ScalarsPlugin via TensorBoard core.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
context: A base_plugin.TBContext instance.
|
|
54
|
+
"""
|
|
55
|
+
self._downsample_to = (context.sampling_hints or {}).get(
|
|
56
|
+
self.plugin_name, _DEFAULT_DOWNSAMPLING
|
|
57
|
+
)
|
|
58
|
+
self._data_provider = context.data_provider
|
|
59
|
+
self._version_checker = plugin_util._MetadataVersionChecker(
|
|
60
|
+
data_kind="scalar",
|
|
61
|
+
latest_known_version=0,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
def get_plugin_apps(self):
|
|
65
|
+
return {
|
|
66
|
+
"/scalars": self.scalars_route,
|
|
67
|
+
"/scalars_multirun": self.scalars_multirun_route,
|
|
68
|
+
"/tags": self.tags_route,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
def is_active(self):
|
|
72
|
+
return False # `list_plugins` as called by TB core suffices
|
|
73
|
+
|
|
74
|
+
def frontend_metadata(self):
|
|
75
|
+
return base_plugin.FrontendMetadata(element_name="tf-scalar-dashboard")
|
|
76
|
+
|
|
77
|
+
def index_impl(self, ctx, experiment=None):
|
|
78
|
+
"""Return {runName: {tagName: {displayName: ..., description:
|
|
79
|
+
...}}}."""
|
|
80
|
+
mapping = self._data_provider.list_scalars(
|
|
81
|
+
ctx,
|
|
82
|
+
experiment_id=experiment,
|
|
83
|
+
plugin_name=metadata.PLUGIN_NAME,
|
|
84
|
+
)
|
|
85
|
+
result = {run: {} for run in mapping}
|
|
86
|
+
for run, tag_to_content in mapping.items():
|
|
87
|
+
for tag, metadatum in tag_to_content.items():
|
|
88
|
+
md = metadata.parse_plugin_metadata(metadatum.plugin_content)
|
|
89
|
+
if not self._version_checker.ok(md.version, run, tag):
|
|
90
|
+
continue
|
|
91
|
+
description = plugin_util.markdown_to_safe_html(
|
|
92
|
+
metadatum.description
|
|
93
|
+
)
|
|
94
|
+
result[run][tag] = {
|
|
95
|
+
"displayName": metadatum.display_name,
|
|
96
|
+
"description": description,
|
|
97
|
+
}
|
|
98
|
+
return result
|
|
99
|
+
|
|
100
|
+
def scalars_impl(self, ctx, tag, run, experiment, output_format):
|
|
101
|
+
"""Result of the form `(body, mime_type)`."""
|
|
102
|
+
all_scalars = self._data_provider.read_scalars(
|
|
103
|
+
ctx,
|
|
104
|
+
experiment_id=experiment,
|
|
105
|
+
plugin_name=metadata.PLUGIN_NAME,
|
|
106
|
+
downsample=self._downsample_to,
|
|
107
|
+
run_tag_filter=provider.RunTagFilter(runs=[run], tags=[tag]),
|
|
108
|
+
)
|
|
109
|
+
scalars = all_scalars.get(run, {}).get(tag, None)
|
|
110
|
+
if scalars is None:
|
|
111
|
+
raise errors.NotFoundError(
|
|
112
|
+
"No scalar data for run=%r, tag=%r" % (run, tag)
|
|
113
|
+
)
|
|
114
|
+
values = [(x.wall_time, x.step, x.value) for x in scalars]
|
|
115
|
+
if output_format == OutputFormat.CSV:
|
|
116
|
+
string_io = io.StringIO()
|
|
117
|
+
writer = csv.writer(string_io)
|
|
118
|
+
writer.writerow(["Wall time", "Step", "Value"])
|
|
119
|
+
writer.writerows(values)
|
|
120
|
+
return (string_io.getvalue(), "text/csv")
|
|
121
|
+
else:
|
|
122
|
+
return (values, "application/json")
|
|
123
|
+
|
|
124
|
+
def scalars_multirun_impl(self, ctx, tag, runs, experiment):
|
|
125
|
+
"""Result of the form `(body, mime_type)`."""
|
|
126
|
+
all_scalars = self._data_provider.read_scalars(
|
|
127
|
+
ctx,
|
|
128
|
+
experiment_id=experiment,
|
|
129
|
+
plugin_name=metadata.PLUGIN_NAME,
|
|
130
|
+
downsample=self._downsample_to,
|
|
131
|
+
run_tag_filter=provider.RunTagFilter(runs=runs, tags=[tag]),
|
|
132
|
+
)
|
|
133
|
+
body = {
|
|
134
|
+
run: [(x.wall_time, x.step, x.value) for x in run_data[tag]]
|
|
135
|
+
for (run, run_data) in all_scalars.items()
|
|
136
|
+
}
|
|
137
|
+
return (body, "application/json")
|
|
138
|
+
|
|
139
|
+
@wrappers.Request.application
|
|
140
|
+
def tags_route(self, request):
|
|
141
|
+
ctx = plugin_util.context(request.environ)
|
|
142
|
+
experiment = plugin_util.experiment_id(request.environ)
|
|
143
|
+
index = self.index_impl(ctx, experiment=experiment)
|
|
144
|
+
return http_util.Respond(request, index, "application/json")
|
|
145
|
+
|
|
146
|
+
@wrappers.Request.application
|
|
147
|
+
def scalars_route(self, request):
|
|
148
|
+
"""Given a tag and single run, return array of ScalarEvents."""
|
|
149
|
+
tag = request.args.get("tag")
|
|
150
|
+
run = request.args.get("run")
|
|
151
|
+
if tag is None or run is None:
|
|
152
|
+
raise errors.InvalidArgumentError(
|
|
153
|
+
"Both run and tag must be specified: tag=%r, run=%r"
|
|
154
|
+
% (tag, run)
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
ctx = plugin_util.context(request.environ)
|
|
158
|
+
experiment = plugin_util.experiment_id(request.environ)
|
|
159
|
+
output_format = request.args.get("format")
|
|
160
|
+
body, mime_type = self.scalars_impl(
|
|
161
|
+
ctx, tag, run, experiment, output_format
|
|
162
|
+
)
|
|
163
|
+
return http_util.Respond(request, body, mime_type)
|
|
164
|
+
|
|
165
|
+
@wrappers.Request.application
|
|
166
|
+
def scalars_multirun_route(self, request):
|
|
167
|
+
"""Given a tag and list of runs, return dict of ScalarEvent arrays."""
|
|
168
|
+
if request.method != "POST":
|
|
169
|
+
raise werkzeug.exceptions.MethodNotAllowed(["POST"])
|
|
170
|
+
tags = request.form.getlist("tag")
|
|
171
|
+
runs = request.form.getlist("runs")
|
|
172
|
+
if len(tags) != 1:
|
|
173
|
+
raise errors.InvalidArgumentError(
|
|
174
|
+
"tag must be specified exactly once"
|
|
175
|
+
)
|
|
176
|
+
tag = tags[0]
|
|
177
|
+
|
|
178
|
+
ctx = plugin_util.context(request.environ)
|
|
179
|
+
experiment = plugin_util.experiment_id(request.environ)
|
|
180
|
+
body, mime_type = self.scalars_multirun_impl(ctx, tag, runs, experiment)
|
|
181
|
+
return http_util.Respond(request, body, mime_type)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Copyright 2017 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
|
+
"""Scalar summaries and TensorFlow operations to create them.
|
|
16
|
+
|
|
17
|
+
A scalar summary stores a single floating-point value, as a rank-0
|
|
18
|
+
tensor.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import numpy as np
|
|
22
|
+
|
|
23
|
+
from tensorbored.plugins.scalar import metadata
|
|
24
|
+
from tensorbored.plugins.scalar import summary_v2
|
|
25
|
+
|
|
26
|
+
# Export V2 versions.
|
|
27
|
+
scalar = summary_v2.scalar
|
|
28
|
+
scalar_pb = summary_v2.scalar_pb
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def op(name, data, display_name=None, description=None, collections=None):
|
|
32
|
+
"""Create a legacy scalar summary op.
|
|
33
|
+
|
|
34
|
+
Arguments:
|
|
35
|
+
name: A unique name for the generated summary node.
|
|
36
|
+
data: A real numeric rank-0 `Tensor`. Must have `dtype` castable
|
|
37
|
+
to `float32`.
|
|
38
|
+
display_name: Optional name for this summary in TensorBoard, as a
|
|
39
|
+
constant `str`. Defaults to `name`.
|
|
40
|
+
description: Optional long-form description for this summary, as a
|
|
41
|
+
constant `str`. Markdown is supported. Defaults to empty.
|
|
42
|
+
collections: Optional list of graph collections keys. The new
|
|
43
|
+
summary op is added to these collections. Defaults to
|
|
44
|
+
`[Graph Keys.SUMMARIES]`.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
A TensorFlow summary op.
|
|
48
|
+
"""
|
|
49
|
+
# TODO(nickfelt): remove on-demand imports once dep situation is fixed.
|
|
50
|
+
import tensorflow.compat.v1 as tf
|
|
51
|
+
|
|
52
|
+
if display_name is None:
|
|
53
|
+
display_name = name
|
|
54
|
+
summary_metadata = metadata.create_summary_metadata(
|
|
55
|
+
display_name=display_name, description=description
|
|
56
|
+
)
|
|
57
|
+
with tf.name_scope(name):
|
|
58
|
+
with tf.control_dependencies([tf.assert_scalar(data)]):
|
|
59
|
+
return tf.summary.tensor_summary(
|
|
60
|
+
name="scalar_summary",
|
|
61
|
+
tensor=tf.cast(data, tf.float32),
|
|
62
|
+
collections=collections,
|
|
63
|
+
summary_metadata=summary_metadata,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def pb(name, data, display_name=None, description=None):
|
|
68
|
+
"""Create a legacy scalar summary protobuf.
|
|
69
|
+
|
|
70
|
+
Arguments:
|
|
71
|
+
name: A unique name for the generated summary, including any desired
|
|
72
|
+
name scopes.
|
|
73
|
+
data: A rank-0 `np.array` or array-like form (so raw `int`s and
|
|
74
|
+
`float`s are fine, too).
|
|
75
|
+
display_name: Optional name for this summary in TensorBoard, as a
|
|
76
|
+
`str`. Defaults to `name`.
|
|
77
|
+
description: Optional long-form description for this summary, as a
|
|
78
|
+
`str`. Markdown is supported. Defaults to empty.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
A `tf.Summary` protobuf object.
|
|
82
|
+
"""
|
|
83
|
+
# TODO(nickfelt): remove on-demand imports once dep situation is fixed.
|
|
84
|
+
import tensorflow.compat.v1 as tf
|
|
85
|
+
|
|
86
|
+
data = np.array(data)
|
|
87
|
+
if data.shape != ():
|
|
88
|
+
raise ValueError(
|
|
89
|
+
"Expected scalar shape for data, saw shape: %s." % data.shape
|
|
90
|
+
)
|
|
91
|
+
if data.dtype.kind not in ("b", "i", "u", "f"): # bool, int, uint, float
|
|
92
|
+
raise ValueError("Cast %s to float is not supported" % data.dtype.name)
|
|
93
|
+
tensor = tf.make_tensor_proto(data.astype(np.float32))
|
|
94
|
+
|
|
95
|
+
if display_name is None:
|
|
96
|
+
display_name = name
|
|
97
|
+
summary_metadata = metadata.create_summary_metadata(
|
|
98
|
+
display_name=display_name, description=description
|
|
99
|
+
)
|
|
100
|
+
tf_summary_metadata = tf.SummaryMetadata.FromString(
|
|
101
|
+
summary_metadata.SerializeToString()
|
|
102
|
+
)
|
|
103
|
+
summary = tf.Summary()
|
|
104
|
+
summary.value.add(
|
|
105
|
+
tag="%s/scalar_summary" % name,
|
|
106
|
+
metadata=tf_summary_metadata,
|
|
107
|
+
tensor=tensor,
|
|
108
|
+
)
|
|
109
|
+
return summary
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
"""Scalar summaries and TensorFlow operations to create them, V2 versions.
|
|
16
|
+
|
|
17
|
+
A scalar summary stores a single floating-point value, as a rank-0
|
|
18
|
+
tensor.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import numpy as np
|
|
22
|
+
|
|
23
|
+
from tensorbored.compat import tf2 as tf
|
|
24
|
+
from tensorbored.compat.proto import summary_pb2
|
|
25
|
+
from tensorbored.plugins.scalar import metadata
|
|
26
|
+
from tensorbored.util import tensor_util
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def scalar(name, data, step=None, description=None):
|
|
30
|
+
"""Write a scalar summary.
|
|
31
|
+
|
|
32
|
+
See also `tf.summary.image`, `tf.summary.histogram`, `tf.summary.SummaryWriter`.
|
|
33
|
+
|
|
34
|
+
Writes simple numeric values for later analysis in TensorBoard. Writes go to
|
|
35
|
+
the current default summary writer. Each summary point is associated with an
|
|
36
|
+
integral `step` value. This enables the incremental logging of time series
|
|
37
|
+
data. A common usage of this API is to log loss during training to produce
|
|
38
|
+
a loss curve.
|
|
39
|
+
|
|
40
|
+
For example:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
test_summary_writer = tf.summary.create_file_writer('test/logdir')
|
|
44
|
+
with test_summary_writer.as_default():
|
|
45
|
+
tf.summary.scalar('loss', 0.345, step=1)
|
|
46
|
+
tf.summary.scalar('loss', 0.234, step=2)
|
|
47
|
+
tf.summary.scalar('loss', 0.123, step=3)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Multiple independent time series may be logged by giving each series a unique
|
|
51
|
+
`name` value.
|
|
52
|
+
|
|
53
|
+
See [Get started with TensorBoard](https://www.tensorflow.org/tensorboard/get_started)
|
|
54
|
+
for more examples of effective usage of `tf.summary.scalar`.
|
|
55
|
+
|
|
56
|
+
In general, this API expects that data points are logged with a monotonically
|
|
57
|
+
increasing step value. Duplicate points for a single step or points logged out
|
|
58
|
+
of order by step are not guaranteed to display as desired in TensorBoard.
|
|
59
|
+
|
|
60
|
+
Arguments:
|
|
61
|
+
name: A name for this summary. The summary tag used for TensorBoard will
|
|
62
|
+
be this name prefixed by any active name scopes.
|
|
63
|
+
data: A real numeric scalar value, convertible to a `float32` Tensor.
|
|
64
|
+
step: Explicit `int64`-castable monotonic step value for this summary. If
|
|
65
|
+
omitted, this defaults to `tf.summary.experimental.get_step()`, which must
|
|
66
|
+
not be None.
|
|
67
|
+
description: Optional long-form description for this summary, as a
|
|
68
|
+
constant `str`. Markdown is supported. Defaults to empty.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
True on success, or false if no summary was written because no default
|
|
72
|
+
summary writer was available.
|
|
73
|
+
|
|
74
|
+
Raises:
|
|
75
|
+
ValueError: if a default writer exists, but no step was provided and
|
|
76
|
+
`tf.summary.experimental.get_step()` is None.
|
|
77
|
+
"""
|
|
78
|
+
summary_metadata = metadata.create_summary_metadata(
|
|
79
|
+
display_name=None, description=description
|
|
80
|
+
)
|
|
81
|
+
# TODO(https://github.com/tensorflow/tensorboard/issues/2109): remove fallback
|
|
82
|
+
summary_scope = (
|
|
83
|
+
getattr(tf.summary.experimental, "summary_scope", None)
|
|
84
|
+
or tf.summary.summary_scope
|
|
85
|
+
)
|
|
86
|
+
with summary_scope(name, "scalar_summary", values=[data, step]) as (tag, _):
|
|
87
|
+
tf.debugging.assert_scalar(data)
|
|
88
|
+
return tf.summary.write(
|
|
89
|
+
tag=tag,
|
|
90
|
+
tensor=tf.cast(data, tf.float32),
|
|
91
|
+
step=step,
|
|
92
|
+
metadata=summary_metadata,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def scalar_pb(tag, data, description=None):
|
|
97
|
+
"""Create a scalar summary_pb2.Summary protobuf.
|
|
98
|
+
|
|
99
|
+
Arguments:
|
|
100
|
+
tag: String tag for the summary.
|
|
101
|
+
data: A 0-dimensional `np.array` or a compatible python number type.
|
|
102
|
+
description: Optional long-form description for this summary, as a
|
|
103
|
+
`str`. Markdown is supported. Defaults to empty.
|
|
104
|
+
|
|
105
|
+
Raises:
|
|
106
|
+
ValueError: If the type or shape of the data is unsupported.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
A `summary_pb2.Summary` protobuf object.
|
|
110
|
+
"""
|
|
111
|
+
arr = np.array(data)
|
|
112
|
+
if arr.shape != ():
|
|
113
|
+
raise ValueError(
|
|
114
|
+
"Expected scalar shape for tensor, got shape: %s." % arr.shape
|
|
115
|
+
)
|
|
116
|
+
if arr.dtype.kind not in ("b", "i", "u", "f"): # bool, int, uint, float
|
|
117
|
+
raise ValueError("Cast %s to float is not supported" % arr.dtype.name)
|
|
118
|
+
tensor_proto = tensor_util.make_tensor_proto(arr.astype(np.float32))
|
|
119
|
+
summary_metadata = metadata.create_summary_metadata(
|
|
120
|
+
display_name=None, description=description
|
|
121
|
+
)
|
|
122
|
+
summary = summary_pb2.Summary()
|
|
123
|
+
summary.value.add(tag=tag, metadata=summary_metadata, tensor=tensor_proto)
|
|
124
|
+
return summary
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Copyright 2017 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
|
+
"""Internal information about the text plugin."""
|
|
16
|
+
|
|
17
|
+
from tensorbored.compat.proto import summary_pb2
|
|
18
|
+
from tensorbored.plugins.text import plugin_data_pb2
|
|
19
|
+
|
|
20
|
+
PLUGIN_NAME = "text"
|
|
21
|
+
|
|
22
|
+
# The most recent value for the `version` field of the
|
|
23
|
+
# `TextPluginData` proto.
|
|
24
|
+
PROTO_VERSION = 0
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def create_summary_metadata(display_name, description):
|
|
28
|
+
"""Create a `summary_pb2.SummaryMetadata` proto for text plugin data.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
A `summary_pb2.SummaryMetadata` protobuf object.
|
|
32
|
+
"""
|
|
33
|
+
content = plugin_data_pb2.TextPluginData(version=PROTO_VERSION)
|
|
34
|
+
metadata = summary_pb2.SummaryMetadata(
|
|
35
|
+
display_name=display_name,
|
|
36
|
+
summary_description=description,
|
|
37
|
+
plugin_data=summary_pb2.SummaryMetadata.PluginData(
|
|
38
|
+
plugin_name=PLUGIN_NAME, content=content.SerializeToString()
|
|
39
|
+
),
|
|
40
|
+
)
|
|
41
|
+
return metadata
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def parse_plugin_metadata(content):
|
|
45
|
+
"""Parse summary metadata to a Python object.
|
|
46
|
+
|
|
47
|
+
Arguments:
|
|
48
|
+
content: The `content` field of a `SummaryMetadata` proto corresponding to
|
|
49
|
+
the text plugin.
|
|
50
|
+
Returns:
|
|
51
|
+
A `TextPluginData` protobuf object.
|
|
52
|
+
"""
|
|
53
|
+
if not isinstance(content, bytes):
|
|
54
|
+
raise TypeError("Content type must be bytes")
|
|
55
|
+
if content == b"{}":
|
|
56
|
+
# Old-style JSON format. Equivalent to an all-default proto.
|
|
57
|
+
return plugin_data_pb2.TextPluginData()
|
|
58
|
+
result = plugin_data_pb2.TextPluginData.FromString(content)
|
|
59
|
+
if result.version == 0:
|
|
60
|
+
return result
|
|
61
|
+
# No other versions known at this time, so no migrations to do.
|
|
62
|
+
return result
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: tensorbored/plugins/text/plugin_data.proto
|
|
4
|
+
"""Generated protocol buffer code."""
|
|
5
|
+
from google.protobuf import descriptor as _descriptor
|
|
6
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
7
|
+
from google.protobuf import message as _message
|
|
8
|
+
from google.protobuf import reflection as _reflection
|
|
9
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
10
|
+
# @@protoc_insertion_point(imports)
|
|
11
|
+
|
|
12
|
+
_sym_db = _symbol_database.Default()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n*tensorbored/plugins/text/plugin_data.proto\x12\x0btensorbored\"!\n\x0eTextPluginData\x12\x0f\n\x07version\x18\x01 \x01(\x05\x62\x06proto3')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
_TEXTPLUGINDATA = DESCRIPTOR.message_types_by_name['TextPluginData']
|
|
22
|
+
TextPluginData = _reflection.GeneratedProtocolMessageType('TextPluginData', (_message.Message,), {
|
|
23
|
+
'DESCRIPTOR' : _TEXTPLUGINDATA,
|
|
24
|
+
'__module__' : 'tensorbored.plugins.text.plugin_data_pb2'
|
|
25
|
+
# @@protoc_insertion_point(class_scope:tensorbored.TextPluginData)
|
|
26
|
+
})
|
|
27
|
+
_sym_db.RegisterMessage(TextPluginData)
|
|
28
|
+
|
|
29
|
+
if _descriptor._USE_C_DESCRIPTORS == False:
|
|
30
|
+
|
|
31
|
+
DESCRIPTOR._options = None
|
|
32
|
+
_TEXTPLUGINDATA._serialized_start=59
|
|
33
|
+
_TEXTPLUGINDATA._serialized_end=92
|
|
34
|
+
# @@protoc_insertion_point(module_scope)
|