aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/cloud/ops
diff options
context:
space:
mode:
authorGravatar Brennan Saeta <saeta@google.com>2018-05-30 15:25:46 -0700
committerGravatar Yifei Feng <yifeif@google.com>2018-05-30 15:25:46 -0700
commite469934f1274c7c498e5061995fec425a21c9be8 (patch)
treeab9c0078f1c1fa5027537096898f560cbd9833fe /tensorflow/contrib/cloud/ops
parent176754d6cce54a971c98096f55251870708eea3e (diff)
Add GCS configure ops.
PiperOrigin-RevId: 198624285
Diffstat (limited to 'tensorflow/contrib/cloud/ops')
-rw-r--r--tensorflow/contrib/cloud/ops/gcs_config_ops.cc70
1 files changed, 70 insertions, 0 deletions
diff --git a/tensorflow/contrib/cloud/ops/gcs_config_ops.cc b/tensorflow/contrib/cloud/ops/gcs_config_ops.cc
new file mode 100644
index 0000000000..9cf85f5f18
--- /dev/null
+++ b/tensorflow/contrib/cloud/ops/gcs_config_ops.cc
@@ -0,0 +1,70 @@
+/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==============================================================================*/
+
+#include "tensorflow/core/framework/common_shape_fns.h"
+#include "tensorflow/core/framework/op.h"
+#include "tensorflow/core/framework/shape_inference.h"
+
+namespace tensorflow {
+
+REGISTER_OP("GcsConfigureCredentials")
+ .Input("json: string")
+ .SetShapeFn(shape_inference::NoOutputs)
+ .Doc(R"doc(
+Configures the credentials used by the GCS client of the local TF runtime.
+
+The json input can be of the format:
+
+1. Refresh Token:
+{
+ "client_id": "<redacted>",
+ "client_secret": "<redacted>",
+ "refresh_token: "<redacted>",
+ "type": "authorized_user",
+}
+
+2. Service Account:
+{
+ "type": "service_account",
+ "project_id": "<redacted>",
+ "private_key_id": "<redacted>",
+ "private_key": "------BEGIN PRIVATE KEY-----\n<REDACTED>\n-----END PRIVATE KEY------\n",
+ "client_email": "<REDACTED>@<REDACTED>.iam.gserviceaccount.com",
+ "client_id": "<REDACTED>",
+ # Some additional fields elided
+}
+
+Note the credentials established through this method are shared across all
+sessions run on this runtime.
+
+Note be sure to feed the inputs to this op to ensure the credentials are not
+stored in a constant op within the graph that might accidentally be checkpointed
+or in other ways be persisted or exfiltrated.
+)doc");
+
+REGISTER_OP("GcsConfigureBlockCache")
+ .Input("max_cache_size: uint64")
+ .Input("block_size: uint64")
+ .Input("max_staleness: uint64")
+ .SetShapeFn(shape_inference::NoOutputs)
+ .Doc(R"doc(
+Re-configures the GCS block cache with the new configuration values.
+
+If the values are the same as already configured values, this op is a no-op. If
+they are different, the current contents of the block cache is dropped, and a
+new block cache is created fresh.
+)doc");
+
+} // namespace tensorflow