Rollback of PR #52316
PR #52316: Add support of filesystem_set_configuration to tensorflow core

Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/52316

This is a follow up to PR in https://github.com/tensorflow/io/pull/1443 to add set_configuration support to tensorflow core repo.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Copybara import of the project:

--
a11f08106c6aecb8969a033712cd7e8b30312994 by Yong Tang <yong.tang.github@outlook.com>:

Add support of filesystem_set_configuration to tensorflow core

This is a follow up to PR in https://github.com/tensorflow/io/pull/1443
to add set_configuration support to tensorflow core repo.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

--
eb8559d94500e2f5184b83ac0dceef915a2fb00d by Yong Tang <yong.tang.github@outlook.com>:

Expose tf.experimental.filesystem_set_configuration API

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

--
16ad176163bdd9290a0761d1264c1f5630e26b6c by Yong Tang <yong.tang.github@outlook.com>:

Add placeholder SetOption for gcs file system

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
PiperOrigin-RevId: 406210322
Change-Id: Ia1fd891a522c6f6a81bfab5c86c00e9940b1084a
diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD
index d226a0f..5c1fb12 100644
--- a/tensorflow/core/BUILD
+++ b/tensorflow/core/BUILD
@@ -631,7 +631,6 @@
         "//tensorflow/core/kernels:composite_tensor_ops",
         "//tensorflow/core/kernels:fact_op",
         "//tensorflow/core/kernels:fake_quant_ops",
-        "//tensorflow/core/kernels:filesystem_ops",
         "//tensorflow/core/kernels:function_ops",
         "//tensorflow/core/kernels:functional_ops",
         "//tensorflow/core/kernels:grappler",
@@ -965,7 +964,6 @@
         "decode_proto_ops_op_lib",
         "encode_proto_ops_op_lib",
         "experimental_dataset_ops_op_lib",
-        "filesystem_ops_op_lib",
         "function_ops_op_lib",
         "functional_grad",
         "functional_ops_op_lib",
diff --git a/tensorflow/core/api_def/base_api/api_def_FileSystemSetConfiguration.pbtxt b/tensorflow/core/api_def/base_api/api_def_FileSystemSetConfiguration.pbtxt
deleted file mode 100644
index 3070370..0000000
--- a/tensorflow/core/api_def/base_api/api_def_FileSystemSetConfiguration.pbtxt
+++ /dev/null
@@ -1,23 +0,0 @@
-op {
-  graph_op_name: "FileSystemSetConfiguration"
-  visibility: HIDDEN
-  in_arg {
-    name: "scheme"
-    description: <<END
-File system scheme.
-END
-  }
-  in_arg {
-    name: "key"
-    description: <<END
-The name of the configuration option.
-END
-  }
-  in_arg {
-    name: "value"
-    description: <<END
-The value of the configuration option.
-END
-  }
-  summary: "Set configuration of the file system."
-}
diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD
index 85026ba..269ffaf 100644
--- a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
@@ -7818,12 +7818,3 @@
         "//tensorflow/core:testlib",
     ],
 )
-
-tf_kernel_library(
-    name = "filesystem_ops",
-    srcs = ["filesystem_ops.cc"],
-    deps = [
-        "//tensorflow/core:framework",
-        "//tensorflow/core:lib",
-    ],
-)
diff --git a/tensorflow/core/kernels/filesystem_ops.cc b/tensorflow/core/kernels/filesystem_ops.cc
deleted file mode 100644
index 7248049..0000000
--- a/tensorflow/core/kernels/filesystem_ops.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Copyright 2021 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/op_kernel.h"
-#include "tensorflow/core/platform/logging.h"
-
-namespace tensorflow {
-
-class FileSystemSetConfigurationOp : public OpKernel {
- public:
-  explicit FileSystemSetConfigurationOp(OpKernelConstruction* context)
-      : OpKernel(context) {
-    env_ = context->env();
-  }
-
-  void Compute(OpKernelContext* context) override {
-    const Tensor* scheme_tensor;
-    OP_REQUIRES_OK(context, context->input("scheme", &scheme_tensor));
-    OP_REQUIRES(context, TensorShapeUtils::IsScalar(scheme_tensor->shape()),
-                errors::InvalidArgument("scheme must be scalar, got shape ",
-                                        scheme_tensor->shape().DebugString()));
-    const string scheme = scheme_tensor->scalar<tstring>()();
-
-    const Tensor* key_tensor;
-    OP_REQUIRES_OK(context, context->input("key", &key_tensor));
-    OP_REQUIRES(context, TensorShapeUtils::IsScalar(key_tensor->shape()),
-                errors::InvalidArgument("key must be scalar, got shape ",
-                                        key_tensor->shape().DebugString()));
-    const string key = key_tensor->scalar<tstring>()();
-
-    const Tensor* value_tensor;
-    OP_REQUIRES_OK(context, context->input("value", &value_tensor));
-    OP_REQUIRES(context, TensorShapeUtils::IsScalar(value_tensor->shape()),
-                errors::InvalidArgument("value must be scalar, got shape ",
-                                        scheme_tensor->shape().DebugString()));
-    const string value = value_tensor->scalar<tstring>()();
-    OP_REQUIRES_OK(context, env_->SetOption(scheme, key, value));
-  }
-
- private:
-  Env* env_;
-};
-REGISTER_KERNEL_BUILDER(Name("FileSystemSetConfiguration").Device(DEVICE_CPU),
-                        FileSystemSetConfigurationOp);
-
-}  // namespace tensorflow
diff --git a/tensorflow/core/ops/BUILD b/tensorflow/core/ops/BUILD
index 95ed731..533d60c 100644
--- a/tensorflow/core/ops/BUILD
+++ b/tensorflow/core/ops/BUILD
@@ -61,7 +61,6 @@
         "decode_proto_ops",
         "encode_proto_ops",
         "experimental_dataset_ops",
-        "filesystem_ops",
         "function_ops",
         "functional_ops",
         "image_ops",
@@ -269,7 +268,6 @@
         ":encode_proto_ops_op_lib",
         ":experimental_dataset_ops_op_lib",
         ":composite_tensor_ops_op_lib",
-        ":filesystem_ops_op_lib",
         ":function_ops_op_lib",
         ":functional_ops_op_lib",
         ":image_ops_op_lib",
diff --git a/tensorflow/core/ops/filesystem_ops.cc b/tensorflow/core/ops/filesystem_ops.cc
deleted file mode 100644
index 00e6d86..0000000
--- a/tensorflow/core/ops/filesystem_ops.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2021 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 {
-
-// Filesystem Ops ----------------------------------------------------------
-
-REGISTER_OP("FileSystemSetConfiguration")
-    .Input("scheme: string")
-    .Input("key: string")
-    .Input("value: string")
-    .SetIsStateful()
-    .SetShapeFn(shape_inference::ScalarShape);
-
-}  // namespace tensorflow
diff --git a/tensorflow/core/platform/env.cc b/tensorflow/core/platform/env.cc
index babf489..ed709fe 100644
--- a/tensorflow/core/platform/env.cc
+++ b/tensorflow/core/platform/env.cc
@@ -141,16 +141,6 @@
 }
 
 Status Env::SetOption(const std::string& scheme, const std::string& key,
-                      const std::string& value) {
-  FileSystem* file_system = file_system_registry_->Lookup(scheme);
-  if (!file_system) {
-    return errors::Unimplemented("File system scheme '", scheme,
-                                 "' not found to set configuration");
-  }
-  return file_system->SetOption(key, value);
-}
-
-Status Env::SetOption(const std::string& scheme, const std::string& key,
                       const std::vector<string>& values) {
   FileSystem* file_system = file_system_registry_->Lookup(scheme);
   if (!file_system) {
diff --git a/tensorflow/core/platform/env.h b/tensorflow/core/platform/env.h
index 1f20aa2..72e63ab 100644
--- a/tensorflow/core/platform/env.h
+++ b/tensorflow/core/platform/env.h
@@ -94,9 +94,6 @@
                                     std::unique_ptr<FileSystem> filesystem);
 
   Status SetOption(const std::string& scheme, const std::string& key,
-                   const std::string& value);
-
-  Status SetOption(const std::string& scheme, const std::string& key,
                    const std::vector<string>& values);
 
   Status SetOption(const std::string& scheme, const std::string& key,
diff --git a/tensorflow/core/platform/file_system.h b/tensorflow/core/platform/file_system.h
index 23b5536..dd2ab9a 100644
--- a/tensorflow/core/platform/file_system.h
+++ b/tensorflow/core/platform/file_system.h
@@ -516,11 +516,6 @@
   /// \brief Decode transaction to human readable string.
   virtual std::string DecodeTransaction(const TransactionToken* token);
 
-  /// \brief Set File System Configuration Options
-  virtual Status SetOption(const string& key, const string& value) {
-    return errors::Unimplemented("SetOption");
-  }
-
   /// \brief Set File System Configuration Option
   virtual tensorflow::Status SetOption(const std::string& name,
                                        const std::vector<string>& values) {
diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD
index 7e8373e..9176986 100644
--- a/tensorflow/python/BUILD
+++ b/tensorflow/python/BUILD
@@ -146,7 +146,6 @@
         ":control_flow_ops",
         ":cudnn_rnn_ops_gen",
         ":distributed_framework_test_lib",
-        ":filesystem_ops",
         ":functional_ops",
         ":gradient_checker",
         ":gradient_checker_v2",
@@ -635,13 +634,6 @@
 )
 
 tf_gen_op_wrapper_private_py(
-    name = "filesystem_ops_gen",
-    visibility = [
-        "//tensorflow:__subpackages__",
-    ],
-)
-
-tf_gen_op_wrapper_private_py(
     name = "image_ops_gen",
     visibility = ["//learning/brain/python/ops:__pkg__"],
 )
@@ -1606,16 +1598,6 @@
 )
 
 py_library(
-    name = "filesystem_ops",
-    srcs = ["ops/filesystem_ops.py"],
-    srcs_version = "PY3",
-    deps = [
-        ":filesystem_ops_gen",
-        "//tensorflow/python/framework:for_generated_wrappers",
-    ],
-)
-
-py_library(
     name = "histogram_ops",
     srcs = ["ops/histogram_ops.py"],
     srcs_version = "PY3",
diff --git a/tensorflow/python/ops/filesystem_ops.py b/tensorflow/python/ops/filesystem_ops.py
deleted file mode 100644
index 412fff4..0000000
--- a/tensorflow/python/ops/filesystem_ops.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2021 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.
-# ==============================================================================
-"""Filesystem related operations."""
-
-from tensorflow.python.ops import gen_filesystem_ops as _gen_filesystem_ops
-from tensorflow.python.util.tf_export import tf_export
-
-
-# pylint: disable=protected-access
-@tf_export('experimental.filesystem_set_configuration')
-def filesystem_set_configuration(scheme, key, value, name=None):
-  """Set configuration of the file system.
-
-  Args:
-    scheme: File system scheme.
-    key: The name of the configuration option.
-    value: The value of the configuration option.
-    name: A name for the operation (optional).
-
-  Returns:
-    None.
-  """
-
-  return _gen_filesystem_ops.file_system_set_configuration(
-      scheme, key=key, value=value, name=name)
-
-
-# pylint: enable=protected-access