Skip to content

Commit

Permalink
Added FileAcl to tsl::FileSystem.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 590301865
  • Loading branch information
gharibian authored and tensorflow-copybara committed Dec 12, 2023
1 parent 5b91594 commit d6c0917
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tensorflow_serving/servables/tensorflow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ cc_library(
"//tensorflow_serving/resources:resource_util",
"//tensorflow_serving/resources:resource_values",
"//tensorflow_serving/resources:resources_cc_proto",
"//tensorflow_serving/servables/tensorflow:file_acl",
"@org_tensorflow//tensorflow/cc/saved_model:loader",
"@org_tensorflow//tensorflow/core:lib",
],
Expand Down Expand Up @@ -1305,6 +1306,7 @@ cc_library(
"//tensorflow_serving/resources:resource_util",
"//tensorflow_serving/resources:resource_values",
"//tensorflow_serving/resources:resources_cc_proto",
"//tensorflow_serving/servables/tensorflow:file_acl",
"@org_tensorflow//tensorflow/cc/saved_model:loader",
"@org_tensorflow//tensorflow/core:lib",
],
Expand Down Expand Up @@ -1920,3 +1922,11 @@ cc_library(
"//tensorflow_serving/servables/tensorflow/oss:run_options",
]) + if_google(["//tensorflow_serving/servables/tensorflow/google:run_options"]),
)

cc_library(
name = "file_acl",
hdrs = ["file_acl.h"],
deps = ["//tensorflow_serving/util:oss_or_google"] + if_oss([
"//tensorflow_serving/servables/tensorflow/oss:file_acl",
]) + if_google(["//tensorflow_serving/servables/tensorflow/google:file_acl"]),
)
27 changes: 27 additions & 0 deletions tensorflow_serving/servables/tensorflow/file_acl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright 2023 Google Inc. 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 THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_FILE_ACL_H_
#define THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_FILE_ACL_H_

#include "tensorflow_serving/util/oss_or_google.h"

#ifdef TENSORFLOW_SERVING_GOOGLE
#include "tensorflow_serving/servables/tensorflow/google/file_acl.h"
#else
#include "tensorflow_serving/servables/tensorflow/oss/file_acl.h"
#endif

#endif // THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_FILE_ACL_H_
11 changes: 11 additions & 0 deletions tensorflow_serving/servables/tensorflow/oss/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ cc_library(
"//tensorflow_serving/servables/tensorflow:run_options_base",
],
)

cc_library(
name = "file_acl",
srcs = ["file_acl.cc"],
hdrs = ["file_acl.h"],
compatible_with = [],
deps = [
"//tensorflow_serving/core:servable_id",
"@com_google_absl//absl/status",
],
)
33 changes: 33 additions & 0 deletions tensorflow_serving/servables/tensorflow/oss/file_acl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Copyright 2023 Google Inc. 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_serving/servables/tensorflow/oss/file_acl.h"

#include <string_view>

#include "absl/status/status.h"
#include "tensorflow_serving/core/servable_id.h"

namespace tensorflow {
namespace serving {

absl::Status RegisterModelRoot(const ServableId& servable_id,
std::string_view root_path) {
// Unimplemented
return absl::OkStatus();
}

} // namespace serving
} // namespace tensorflow
31 changes: 31 additions & 0 deletions tensorflow_serving/servables/tensorflow/oss/file_acl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Copyright 2023 Google Inc. 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 THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_OSS_FILE_ACL_H_
#define THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_OSS_FILE_ACL_H_

#include "absl/status/status.h"
#include "tensorflow_serving/core/servable_id.h"

namespace tensorflow {
namespace serving {

absl::Status RegisterModelRoot(const ServableId& servable_id,
std::string_view root_path);

} // namespace serving
} // namespace tensorflow

#endif // THIRD_PARTY_TENSORFLOW_SERVING_SERVABLES_TENSORFLOW_OSS_FILE_ACL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ limitations under the License.
#include "tensorflow_serving/resources/resource_values.h"
#include "tensorflow_serving/resources/resources.pb.h"
#include "tensorflow_serving/servables/tensorflow/bundle_factory_util.h"
#include "tensorflow_serving/servables/tensorflow/file_acl.h"
#include "tensorflow_serving/servables/tensorflow/machine_learning_metadata.h"
#include "tensorflow_serving/servables/tensorflow/saved_model_bundle_factory.h"
#include "tensorflow_serving/servables/tensorflow/saved_model_warmup.h"
Expand Down Expand Up @@ -55,6 +56,7 @@ SavedModelBundleSourceAdapter::GetServableCreator(
if (bundle_factory->config().enable_session_metadata()) {
return [bundle_factory, path](const Loader::Metadata& metadata,
std::unique_ptr<SavedModelBundle>* bundle) {
TF_RETURN_IF_ERROR(RegisterModelRoot(metadata.servable_id, path));
TF_RETURN_IF_ERROR(bundle_factory->CreateSavedModelBundleWithMetadata(
metadata, path, bundle));
MaybePublishMLMDStreamz(path, metadata.servable_id.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ limitations under the License.
#include "tensorflow_serving/resources/resource_values.h"
#include "tensorflow_serving/resources/resources.pb.h"
#include "tensorflow_serving/servables/tensorflow/bundle_factory_util.h"
#include "tensorflow_serving/servables/tensorflow/file_acl.h"
#include "tensorflow_serving/servables/tensorflow/machine_learning_metadata.h"
#include "tensorflow_serving/servables/tensorflow/servable.h"
#include "tensorflow_serving/servables/tensorflow/tfrt_saved_model_factory.h"
Expand Down Expand Up @@ -55,6 +56,7 @@ TfrtSavedModelSourceAdapter::GetServableCreator(
const StoragePath& path) const {
return [factory, path](const Loader::Metadata& metadata,
std::unique_ptr<Servable>* servable) {
TF_RETURN_IF_ERROR(RegisterModelRoot(metadata.servable_id, path));
TF_RETURN_IF_ERROR(
factory->CreateTfrtSavedModelWithMetadata(metadata, path, servable));
return OkStatus();
Expand Down

0 comments on commit d6c0917

Please sign in to comment.