Add gcs header to expose symbol
diff --git a/tensorflow/c/experimental/filesystem/plugins/gcs/BUILD b/tensorflow/c/experimental/filesystem/plugins/gcs/BUILD
index f61aa83..68d7de4 100644
--- a/tensorflow/c/experimental/filesystem/plugins/gcs/BUILD
+++ b/tensorflow/c/experimental/filesystem/plugins/gcs/BUILD
@@ -19,6 +19,7 @@
cc_library(
name = "gcs_filesystem_impl",
srcs = ["gcs_filesystem.cc"],
+ hdrs = ["gcs_filesystem.h"],
copts = select({
"//conditions:default": [],
"//tensorflow:windows": get_win_copts(),
@@ -55,14 +56,9 @@
"notap",
],
deps = [
- ":gcs_helper",
- "//tensorflow/c:env",
- "//tensorflow/c:tf_status",
+ ":gcs_filesystem_impl",
"//tensorflow/c:tf_status_helper",
- "//tensorflow/c/experimental/filesystem:filesystem_interface",
"//tensorflow/core/platform:stacktrace_handler",
"//tensorflow/core/platform:test",
- "@com_github_googlecloudplatform_google_cloud_cpp//:storage_client",
- "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.cc b/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.cc
index 8c5c035..bd55caf 100644
--- a/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.cc
+++ b/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.cc
@@ -12,26 +12,16 @@
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
+#include "tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.h"
+
#include <stdlib.h>
#include <string.h>
-#include <fstream>
-
-#include "absl/strings/string_view.h"
#include "google/cloud/storage/client.h"
#include "tensorflow/c/env.h"
-#include "tensorflow/c/experimental/filesystem/filesystem_interface.h"
#include "tensorflow/c/experimental/filesystem/plugins/gcs/gcs_helper.h"
#include "tensorflow/c/tf_status.h"
-#ifdef TF_GCS_FILESYSTEM_TEST
-// For testing purpose, we expose some functions.
-#define TF_STATIC
-#else
-// Otherwise, we don't expose any symbol.
-#define TF_STATIC static
-#endif
-
// Implementation of a filesystem for GCS environments.
// This filesystem will support `gs://` URI schemes.
namespace gcs = google::cloud::storage;
@@ -48,8 +38,8 @@
static void* plugin_memory_allocate(size_t size) { return calloc(1, size); }
static void plugin_memory_free(void* ptr) { free(ptr); }
-static void ParseGCSPath(absl::string_view fname, bool object_empty_ok,
- char** bucket, char** object, TF_Status* status) {
+void ParseGCSPath(absl::string_view fname, bool object_empty_ok, char** bucket,
+ char** object, TF_Status* status) {
size_t scheme_end = fname.find("://") + 2;
if (fname.substr(0, scheme_end + 1) != "gs://") {
TF_SetStatus(status, TF_INVALID_ARGUMENT,
@@ -130,7 +120,7 @@
namespace tf_gcs_filesystem {
// TODO(vnvo2409): Add lazy-loading and customizing parameters.
-TF_STATIC void Init(TF_Filesystem* filesystem, TF_Status* status) {
+void Init(TF_Filesystem* filesystem, TF_Status* status) {
google::cloud::StatusOr<gcs::Client> client =
gcs::Client::CreateDefaultClient();
if (!client) {
@@ -143,14 +133,14 @@
TF_SetStatus(status, TF_OK, "");
}
-static void Cleanup(TF_Filesystem* filesystem) {
+void Cleanup(TF_Filesystem* filesystem) {
plugin_memory_free(filesystem->plugin_filesystem);
}
// TODO(vnvo2409): Implement later
-static void NewWritableFile(const TF_Filesystem* filesystem, const char* path,
- TF_WritableFile* file, TF_Status* status) {
+void NewWritableFile(const TF_Filesystem* filesystem, const char* path,
+ TF_WritableFile* file, TF_Status* status) {
char* bucket;
char* object;
ParseGCSPath(path, false, &bucket, &object, status);
@@ -166,8 +156,8 @@
TF_SetStatus(status, TF_OK, "");
}
-static void NewAppendableFile(const TF_Filesystem* filesystem, const char* path,
- TF_WritableFile* file, TF_Status* status) {
+void NewAppendableFile(const TF_Filesystem* filesystem, const char* path,
+ TF_WritableFile* file, TF_Status* status) {
char* bucket;
char* object;
ParseGCSPath(path, false, &bucket, &object, status);
diff --git a/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.h b/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.h
new file mode 100644
index 0000000..cc8168e
--- /dev/null
+++ b/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.h
@@ -0,0 +1,35 @@
+/* Copyright 2020 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.
+ ==============================================================================*/
+#ifndef TENSORFLOW_C_EXPERIMENTAL_FILESYSTEM_PLUGINS_GCS_GCS_FILESYSTEM_H_
+#define TENSORFLOW_C_EXPERIMENTAL_FILESYSTEM_PLUGINS_GCS_GCS_FILESYSTEM_H_
+
+#include "absl/strings/string_view.h"
+#include "google/cloud/storage/client.h"
+#include "tensorflow/c/experimental/filesystem/filesystem_interface.h"
+#include "tensorflow/c/tf_status.h"
+
+void ParseGCSPath(absl::string_view fname, bool object_empty_ok, char** bucket,
+ char** object, TF_Status* status);
+
+namespace tf_gcs_filesystem {
+void Init(TF_Filesystem* filesystem, TF_Status* status);
+void Cleanup(TF_Filesystem* filesystem);
+void NewWritableFile(const TF_Filesystem* filesystem, const char* path,
+ TF_WritableFile* file, TF_Status* status);
+void NewAppendableFile(const TF_Filesystem* filesystem, const char* path,
+ TF_WritableFile* file, TF_Status* status);
+} // namespace tf_gcs_filesystem
+
+#endif // TENSORFLOW_C_EXPERIMENTAL_FILESYSTEM_PLUGINS_GCS_GCS_FILESYSTEM_H_
diff --git a/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem_test.cc b/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem_test.cc
index 4322176..96fef42 100644
--- a/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem_test.cc
+++ b/tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem_test.cc
@@ -12,18 +12,14 @@
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
-#include "tensorflow/c/experimental/filesystem/filesystem_interface.h"
+#include "tensorflow/c/experimental/filesystem/plugins/gcs/gcs_filesystem.h"
+
#include "tensorflow/c/tf_status_helper.h"
#include "tensorflow/core/platform/stacktrace_handler.h"
#include "tensorflow/core/platform/test.h"
#define ASSERT_TF_OK(x) ASSERT_EQ(TF_OK, TF_GetCode(x))
-// Forward declaration
-namespace tf_gcs_filesystem {
-void Init(TF_Filesystem* filesystem, TF_Status* status);
-}
-
namespace tensorflow {
namespace {
@@ -38,7 +34,7 @@
}
void TearDown() override {
TF_DeleteStatus(status_);
- // TODO(vnvo2409): Add filesystem cleanup
+ tf_gcs_filesystem::Cleanup(filesystem_);
delete filesystem_;
}