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
|
@@ -0,0 +1,285 @@
|
|
|
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
|
+
"""A wrapper for TensorFlow SWIG-generated bindings."""
|
|
16
|
+
|
|
17
|
+
import array
|
|
18
|
+
import struct
|
|
19
|
+
|
|
20
|
+
from . import errors
|
|
21
|
+
from .io import gfile
|
|
22
|
+
|
|
23
|
+
TFE_DEVICE_PLACEMENT_WARN = 0
|
|
24
|
+
TFE_DEVICE_PLACEMENT_SILENT_FOR_INT32 = 0
|
|
25
|
+
TFE_DEVICE_PLACEMENT_SILENT = 0
|
|
26
|
+
TFE_DEVICE_PLACEMENT_EXPLICIT = 0
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def __getattr__(attr):
|
|
30
|
+
return 0
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def TF_bfloat16_type():
|
|
34
|
+
return 0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def masked_crc32c(data):
|
|
38
|
+
x = u32(crc32c(data))
|
|
39
|
+
return u32(((x >> 15) | u32(x << 17)) + 0xA282EAD8)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def u32(x):
|
|
43
|
+
return x & 0xFFFFFFFF
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# fmt: off
|
|
47
|
+
CRC_TABLE = (
|
|
48
|
+
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4,
|
|
49
|
+
0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
|
|
50
|
+
0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B,
|
|
51
|
+
0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24,
|
|
52
|
+
0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B,
|
|
53
|
+
0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384,
|
|
54
|
+
0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54,
|
|
55
|
+
0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B,
|
|
56
|
+
0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A,
|
|
57
|
+
0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35,
|
|
58
|
+
0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5,
|
|
59
|
+
0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA,
|
|
60
|
+
0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45,
|
|
61
|
+
0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A,
|
|
62
|
+
0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A,
|
|
63
|
+
0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595,
|
|
64
|
+
0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48,
|
|
65
|
+
0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957,
|
|
66
|
+
0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687,
|
|
67
|
+
0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198,
|
|
68
|
+
0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927,
|
|
69
|
+
0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38,
|
|
70
|
+
0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8,
|
|
71
|
+
0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7,
|
|
72
|
+
0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096,
|
|
73
|
+
0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789,
|
|
74
|
+
0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859,
|
|
75
|
+
0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46,
|
|
76
|
+
0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9,
|
|
77
|
+
0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6,
|
|
78
|
+
0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36,
|
|
79
|
+
0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829,
|
|
80
|
+
0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C,
|
|
81
|
+
0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93,
|
|
82
|
+
0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043,
|
|
83
|
+
0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C,
|
|
84
|
+
0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3,
|
|
85
|
+
0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC,
|
|
86
|
+
0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C,
|
|
87
|
+
0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033,
|
|
88
|
+
0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652,
|
|
89
|
+
0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D,
|
|
90
|
+
0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D,
|
|
91
|
+
0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982,
|
|
92
|
+
0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D,
|
|
93
|
+
0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622,
|
|
94
|
+
0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2,
|
|
95
|
+
0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED,
|
|
96
|
+
0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530,
|
|
97
|
+
0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F,
|
|
98
|
+
0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF,
|
|
99
|
+
0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0,
|
|
100
|
+
0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F,
|
|
101
|
+
0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540,
|
|
102
|
+
0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90,
|
|
103
|
+
0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
|
|
104
|
+
0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE,
|
|
105
|
+
0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1,
|
|
106
|
+
0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321,
|
|
107
|
+
0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E,
|
|
108
|
+
0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81,
|
|
109
|
+
0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E,
|
|
110
|
+
0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E,
|
|
111
|
+
0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351,
|
|
112
|
+
)
|
|
113
|
+
# fmt: on
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
CRC_INIT = 0
|
|
117
|
+
|
|
118
|
+
_MASK = 0xFFFFFFFF
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def crc_update(crc, data):
|
|
122
|
+
"""Update CRC-32C checksum with data.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
crc: 32-bit checksum to update as long.
|
|
126
|
+
data: byte array, string or iterable over bytes.
|
|
127
|
+
Returns:
|
|
128
|
+
32-bit updated CRC-32C as long.
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
if type(data) != array.array or data.itemsize != 1:
|
|
132
|
+
buf = array.array("B", data)
|
|
133
|
+
else:
|
|
134
|
+
buf = data
|
|
135
|
+
|
|
136
|
+
crc ^= _MASK
|
|
137
|
+
for b in buf:
|
|
138
|
+
table_index = (crc ^ b) & 0xFF
|
|
139
|
+
crc = (CRC_TABLE[table_index] ^ (crc >> 8)) & _MASK
|
|
140
|
+
return crc ^ _MASK
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def crc_finalize(crc):
|
|
144
|
+
"""Finalize CRC-32C checksum.
|
|
145
|
+
|
|
146
|
+
This function should be called as last step of crc calculation.
|
|
147
|
+
Args:
|
|
148
|
+
crc: 32-bit checksum as long.
|
|
149
|
+
Returns:
|
|
150
|
+
finalized 32-bit checksum as long
|
|
151
|
+
"""
|
|
152
|
+
return crc & _MASK
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def crc32c(data):
|
|
156
|
+
"""Compute CRC-32C checksum of the data.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
data: byte array, string or iterable over bytes.
|
|
160
|
+
Returns:
|
|
161
|
+
32-bit CRC-32C checksum of data as long.
|
|
162
|
+
"""
|
|
163
|
+
return crc_finalize(crc_update(CRC_INIT, data))
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class PyRecordReader_New:
|
|
167
|
+
def __init__(
|
|
168
|
+
self, filename=None, start_offset=0, compression_type=None, status=None
|
|
169
|
+
):
|
|
170
|
+
if filename is None:
|
|
171
|
+
raise errors.NotFoundError(
|
|
172
|
+
None, None, "No filename provided, cannot read Events"
|
|
173
|
+
)
|
|
174
|
+
if not gfile.exists(filename):
|
|
175
|
+
raise errors.NotFoundError(
|
|
176
|
+
None,
|
|
177
|
+
None,
|
|
178
|
+
"{} does not point to valid Events file".format(filename),
|
|
179
|
+
)
|
|
180
|
+
if start_offset:
|
|
181
|
+
raise errors.UnimplementedError(
|
|
182
|
+
None, None, "start offset not supported by compat reader"
|
|
183
|
+
)
|
|
184
|
+
if compression_type:
|
|
185
|
+
# TODO: Handle gzip and zlib compressed files
|
|
186
|
+
raise errors.UnimplementedError(
|
|
187
|
+
None, None, "compression not supported by compat reader"
|
|
188
|
+
)
|
|
189
|
+
self.filename = filename
|
|
190
|
+
self.start_offset = start_offset
|
|
191
|
+
self.compression_type = compression_type
|
|
192
|
+
self.status = status
|
|
193
|
+
self.curr_event = None
|
|
194
|
+
self.file_handle = gfile.GFile(self.filename, "rb")
|
|
195
|
+
# Maintain a buffer of partially read records, so we can recover from
|
|
196
|
+
# truncated records upon a retry.
|
|
197
|
+
self._buffer = b""
|
|
198
|
+
self._buffer_pos = 0
|
|
199
|
+
|
|
200
|
+
def GetNext(self):
|
|
201
|
+
# Each new read should start at the beginning of any partial record.
|
|
202
|
+
self._buffer_pos = 0
|
|
203
|
+
# Read the header
|
|
204
|
+
self.curr_event = None
|
|
205
|
+
header_str = self._read(8)
|
|
206
|
+
if not header_str:
|
|
207
|
+
# Hit EOF so raise and exit
|
|
208
|
+
raise errors.OutOfRangeError(None, None, "No more events to read")
|
|
209
|
+
if len(header_str) < 8:
|
|
210
|
+
raise self._truncation_error("header")
|
|
211
|
+
header = struct.unpack("<Q", header_str)
|
|
212
|
+
|
|
213
|
+
# Read the crc32, which is 4 bytes, and check it against
|
|
214
|
+
# the crc32 of the header
|
|
215
|
+
crc_header_str = self._read(4)
|
|
216
|
+
if len(crc_header_str) < 4:
|
|
217
|
+
raise self._truncation_error("header crc")
|
|
218
|
+
crc_header = struct.unpack("<I", crc_header_str)
|
|
219
|
+
header_crc_calc = masked_crc32c(header_str)
|
|
220
|
+
if header_crc_calc != crc_header[0]:
|
|
221
|
+
raise errors.DataLossError(
|
|
222
|
+
None, None, "{} failed header crc32 check".format(self.filename)
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
# The length of the header tells us how many bytes the Event
|
|
226
|
+
# string takes
|
|
227
|
+
header_len = int(header[0])
|
|
228
|
+
event_str = self._read(header_len)
|
|
229
|
+
if len(event_str) < header_len:
|
|
230
|
+
raise self._truncation_error("data")
|
|
231
|
+
|
|
232
|
+
event_crc_calc = masked_crc32c(event_str)
|
|
233
|
+
|
|
234
|
+
# The next 4 bytes contain the crc32 of the Event string,
|
|
235
|
+
# which we check for integrity.
|
|
236
|
+
crc_event_str = self._read(4)
|
|
237
|
+
if len(crc_event_str) < 4:
|
|
238
|
+
raise self._truncation_error("data crc")
|
|
239
|
+
crc_event = struct.unpack("<I", crc_event_str)
|
|
240
|
+
if event_crc_calc != crc_event[0]:
|
|
241
|
+
raise errors.DataLossError(
|
|
242
|
+
None,
|
|
243
|
+
None,
|
|
244
|
+
"{} failed event crc32 check".format(self.filename),
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
# Set the current event to be read later by record() call
|
|
248
|
+
self.curr_event = event_str
|
|
249
|
+
# Clear the buffered partial record since we're done reading it.
|
|
250
|
+
self._buffer = b""
|
|
251
|
+
|
|
252
|
+
def _read(self, n):
|
|
253
|
+
"""Read up to n bytes from the underlying file, with buffering.
|
|
254
|
+
|
|
255
|
+
Reads are satisfied from a buffer of previous data read starting at
|
|
256
|
+
`self._buffer_pos` until the buffer is exhausted, and then from the
|
|
257
|
+
actual underlying file. Any new data is added to the buffer, and
|
|
258
|
+
`self._buffer_pos` is advanced to the point in the buffer past all
|
|
259
|
+
data returned as part of this read.
|
|
260
|
+
|
|
261
|
+
Args:
|
|
262
|
+
n: non-negative number of bytes to read
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
bytestring of data read, up to n bytes
|
|
266
|
+
"""
|
|
267
|
+
result = self._buffer[self._buffer_pos : self._buffer_pos + n]
|
|
268
|
+
self._buffer_pos += len(result)
|
|
269
|
+
n -= len(result)
|
|
270
|
+
if n > 0:
|
|
271
|
+
new_data = self.file_handle.read(n)
|
|
272
|
+
result += new_data
|
|
273
|
+
self._buffer += new_data
|
|
274
|
+
self._buffer_pos += len(new_data)
|
|
275
|
+
return result
|
|
276
|
+
|
|
277
|
+
def _truncation_error(self, section):
|
|
278
|
+
return errors.DataLossError(
|
|
279
|
+
None,
|
|
280
|
+
None,
|
|
281
|
+
"{} has truncated record in {}".format(self.filename, section),
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
def record(self):
|
|
285
|
+
return self.curr_event
|