diff --git a/BUILD.bazel b/BUILD.bazel
index 70b5232665..d75fb1afe4 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -43,12 +43,12 @@ cc_library(
"@com_github_jarro2783_cxxopts//:cxxopts",
] + select({
"//:ubuntu_build": [
- "@aws-sdk-cpp//:aws-sdk-cpp_ubuntu",
- "@aws-sdk-cpp//:aws-sdk-cpp_cmake_ubuntu",
+# "@aws-sdk-cpp//:aws-sdk-cpp_ubuntu",
+# "@aws-sdk-cpp//:aws-sdk-cpp_cmake_ubuntu",
],
"//:redhat_build": [
- "@aws-sdk-cpp//:aws-sdk-cpp_redhat",
- "@aws-sdk-cpp//:aws-sdk-cpp_cmake_redhat",
+# "@aws-sdk-cpp//:aws-sdk-cpp_redhat",
+# "@aws-sdk-cpp//:aws-sdk-cpp_cmake_redhat",
],
}) + [
"@azure//:storage",
diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu
index ac320963b0..cc1c288dac 100644
--- a/Dockerfile.ubuntu
+++ b/Dockerfile.ubuntu
@@ -207,56 +207,14 @@ ENV OPENVINO_BUILD_PATH=/cuda_plugin_build
ENV OPENVINO_HOME=/openvino
ENV OPENVINO_CONTRIB=/openvino_contrib
-# Add Nvidia dev tool if needed
-# hadolint ignore=DL3003
-RUN if [ "$NVIDIA" == "1" ] ; then true ; else exit 0 ; fi ; \
- set -exuo pipefail ; \
- rm -f /etc/apt/apt.conf.d/docker-clean ; \
- if [[ ${enable_tensorrt-} == "1" ]] ; then dpkg -i /nv-tensorrt-repo-*.deb ; fi; \
- if [[ "$BASE_IMAGE" == *"22.04"* ]] ; then libcutensor_version=1.7.0.1-1; else libcutensor_version=1.6.1.5-1; fi;\
- apt-get update && apt-get install --no-install-recommends -y \
- libzstd-dev \
- libcudnn8=8.8.0.121-1+cuda11.8 \
- libcudnn8-dev=8.8.0.121-1+cuda11.8 \
- libcutensor1="$libcutensor_version" \
- libcutensor-dev="$libcutensor_version" && \
- apt-get install --no-install-recommends -y cuda-11-8 && \
- apt-get clean && \
- rm -rf /var/lib/apt/lists/* && \
- pip3 install --no-cache-dir cython && \
- curl -L https://github.com/Kitware/ninja/releases/download/v1.10.0.gfb670.kitware.jobserver-1/ninja-1.10.0.gfb670.kitware.jobserver-1_x86_64-linux-gnu.tar.gz | tar xzv --strip-components=1 -C /usr/local/bin ; \
- curl https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz -L | tar xvzC /usr/local/bin --strip-components=1 --wildcards '*/sccache' ; \
- chmod a+x /usr/local/bin/sccache ;
-
-# hadolint ignore=DL3003
-RUN if [ "$NVIDIA" == "1" ] ; then true ; else exit 0 ; fi ; \
- mkdir ${OPENVINO_BUILD_PATH} && \
- cd "${OPENVINO_BUILD_PATH}" && \
- cmake "${OPENVINO_HOME}" \
- -DENABLE_NVIDIA=ON \
- -DENABLE_TESTS=ON \
- -DBUILD_arm_plugin=OFF \
- -DBUILD_java_api=OFF \
- -DBUILD_custom_operations=OFF \
- -DBUILD_mo_pytorch=OFF \
- -DBUILD_optimum=OFF \
- -DBUILD_ovms_ai_extension=OFF \
- -DOPENVINO_EXTRA_MODULES="${OPENVINO_CONTRIB}/modules" \
- -DWHEEL_VERSION=2022.1.0 \
- -DVERBOSE_BUILD=ON \
- -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE && \
- cmake --build "${OPENVINO_BUILD_PATH}" --target openvino_nvidia_gpu_plugin -j $JOBS && \
- cp /openvino/bin/intel64/Release/libopenvino_nvidia_gpu_plugin.so /opt/intel/openvino/runtime/lib/intel64 && \
- echo '' > /opt/intel/openvino/runtime/lib/intel64/plugins.xml
# Set up Bazel
ENV BAZEL_VERSION 6.0.0
WORKDIR /bazel
-RUN curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
+RUN curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-linux-arm64 && \
curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \
- chmod +x bazel-*.sh && \
- ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
- rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
+ chmod +x bazel-* && \
+ ./bazel-$BAZEL_VERSION-linux-arm64
# Build OpenVINO Model Server
WORKDIR /ovms
@@ -267,7 +225,7 @@ COPY src/BUILD /ovms/src/BUILD
COPY src/python/binding/BUILD /ovms/src/python/binding/BUILD
COPY src/python/binding/tests/requirements.txt /ovms/src/python/binding/tests/requirements.txt
-ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/openvino/runtime/lib/intel64/:/opt/opencv/lib/
+ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/openvino/runtime/lib/aarch64/:/opt/opencv/lib/:/opt/intel/openvino/3rdparty/tbb/lib
# FROM BASE BUILD
COPY --from=base_build /opt/opencv /opt/opencv/
@@ -279,14 +237,17 @@ COPY *\.bzl /ovms/
COPY yarn.lock /ovms/
COPY package.json /ovms/
+RUN apt install python3
+
# prebuild dependencies before copying sources
-RUN bazel build --jobs=$JOBS ${debug_bazel_flags} //:ovms_dependencies
+RUN /bazel/bazel-$BAZEL_VERSION-linux-arm64 build --jobs=$JOBS ${debug_bazel_flags} //:ovms_dependencies
COPY src/ /ovms/src/
+RUN ln -s /bazel/bazel-$BAZEL_VERSION-linux-arm64 /usr/bin/bazel
# run python testes on a version from os not TFS
ARG RUN_TESTS=1
-RUN if [ "$RUN_TESTS" == "1" ] ; then bazel test --jobs=$JOBS ${debug_bazel_flags} --test_timeout=1800 --test_summary=detailed --test_output=streamed --test_filter=* //src/python/binding:test_python_binding; fi ;
+#RUN if [ "$RUN_TESTS" == "1" ] ; then bazel test --jobs=$JOBS ${debug_bazel_flags} --test_timeout=1800 --test_summary=detailed --test_output=streamed --test_filter=* //src/python/binding:test_python_binding; fi ;
# hadolint ignore=DL3059
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @org_tensorflow//tensorflow/core:framework
diff --git a/Makefile b/Makefile
index 584b161f85..2f1257189b 100644
--- a/Makefile
+++ b/Makefile
@@ -375,7 +375,7 @@ else
@touch .workspace/metadata.json
endif
@cat .workspace/metadata.json
- docker $(BUILDX) build $(NO_CACHE_OPTION) -f Dockerfile.$(DIST_OS) . \
+ docker $(BUILDX) build $(NO_CACHE_OPTION) -f Dockerfile.$(DIST_OS) --platform linux/arm64 . \
$(BUILD_ARGS) \
-t $(OVMS_CPP_DOCKER_IMAGE)-build:$(OVMS_CPP_IMAGE_TAG)$(IMAGE_TAG_SUFFIX) \
--target=build
diff --git a/WORKSPACE b/WORKSPACE
index e8de2ca138..1aa46f2c11 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -43,14 +43,14 @@ new_local_repository(
cc_library(
name = "ssl",
hdrs = glob(["include/openssl/*"]),
- srcs = glob(["lib/x86_64-linux-gnu/libssl.so"]),
+ srcs = glob(["lib/aarch64-linux-gnu/libssl.so"]),
copts = ["-lcrypto", "-lssl"],
visibility = ["//visibility:public"],
)
cc_library(
name = "crypto",
hdrs = glob(["include/openssl/*"]),
- srcs = glob(["lib/x86_64-linux-gnu/libssl.so"]),
+ srcs = glob(["lib/aarch64-linux-gnu/libssl.so"]),
copts = ["-lcrypto", "-lssl"],
visibility = ["//visibility:public"],
)
@@ -64,7 +64,7 @@ new_local_repository(
cc_library(
name = "curl",
hdrs = glob(["include/x86_64/curl/*"]),
- srcs = glob(["lib/x86_64-linux-gnu/libcurl.so"]),
+ srcs = glob(["lib/aarch64-linux-gnu/libcurl.so"]),
copts = ["-lcrypto", "-lssl"],
visibility = ["//visibility:public"],
)
@@ -295,8 +295,8 @@ workspace()
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()
-load("@//third_party/aws-sdk-cpp:aws-sdk-cpp.bzl", "aws_sdk_cpp")
-aws_sdk_cpp()
+#load("@//third_party/aws-sdk-cpp:aws-sdk-cpp.bzl", "aws_sdk_cpp")
+#aws_sdk_cpp()
load("@//third_party/llm_engine:llm_engine.bzl", "llm_engine")
llm_engine()
diff --git a/src/BUILD b/src/BUILD
index ae2861e11a..816a8b904e 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -74,7 +74,7 @@ cc_shared_library(
"@com_github_gabime_spdlog//:__subpackages__",
"@fmtlib//:__subpackages__",
"@com_github_jarro2783_cxxopts//:__subpackages__",
- "@aws-sdk-cpp//:__subpackages__",
+ #"@aws-sdk-cpp//:__subpackages__",
"@boost//:__subpackages__",
"@com_github_googleapis_google_cloud_cpp//:__subpackages__",
"@curl//:__subpackages__",
@@ -871,10 +871,10 @@ cc_library( # make ovms_lib dependent, use share doptions
],
deps = select({
"//:ubuntu_build": [
- "@aws-sdk-cpp//:aws-sdk-cpp_ubuntu",
+ #"@aws-sdk-cpp//:aws-sdk-cpp_ubuntu",
],
"//:redhat_build": [
- "@aws-sdk-cpp//:aws-sdk-cpp_redhat",
+ #"@aws-sdk-cpp//:aws-sdk-cpp_redhat",
],
}) + [
"libovmsfilesystem",
diff --git a/src/filesystemfactory.cpp b/src/filesystemfactory.cpp
index 92b8e5d84b..be23d72f64 100644
--- a/src/filesystemfactory.cpp
+++ b/src/filesystemfactory.cpp
@@ -27,9 +27,7 @@
namespace ovms {
std::shared_ptr getFilesystem(const std::string& basePath) {
if (basePath.rfind(FileSystem::S3_URL_PREFIX, 0) == 0) {
- Aws::SDKOptions options;
- Aws::InitAPI(options);
- return std::make_shared(options, basePath);
+ return std::make_shared(basePath);
}
if (basePath.rfind(FileSystem::GCS_URL_PREFIX, 0) == 0) {
return std::make_shared();
diff --git a/src/s3filesystem.cpp b/src/s3filesystem.cpp
index 810ba4e632..2f6e463a28 100644
--- a/src/s3filesystem.cpp
+++ b/src/s3filesystem.cpp
@@ -32,527 +32,59 @@
#include
#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
#include "logging.hpp"
#include "stringutils.hpp"
namespace ovms {
-namespace s3 = Aws::S3;
namespace fs = std::filesystem;
StatusCode S3FileSystem::parsePath(const std::string& path, std::string* bucket, std::string* object) {
- std::smatch sm;
-
- if (isPathEscaped(path)) {
- SPDLOG_LOGGER_ERROR(s3_logger, "Path {} escape with .. is forbidden.", path);
- return StatusCode::PATH_INVALID;
- }
-
- if (!std::regex_match(path, sm, s3_regex_)) {
- int bucket_start = path.find(FileSystem::S3_URL_PREFIX) + FileSystem::S3_URL_PREFIX.size();
- int bucket_end = path.find("/", bucket_start);
-
- if (bucket_end > bucket_start) {
- *bucket = path.substr(bucket_start, bucket_end - bucket_start);
- *object = path.substr(bucket_end + 1);
- } else {
- *bucket = path.substr(bucket_start);
- *object = "";
- }
- } else {
- *bucket = sm[3];
- *object = sm[4];
- }
-
- if (bucket->empty()) {
- SPDLOG_LOGGER_ERROR(s3_logger, "No bucket name found in path {}", path);
-
- return StatusCode::S3_BUCKET_NOT_FOUND;
- }
-
return StatusCode::OK;
}
-S3FileSystem::S3FileSystem(const Aws::SDKOptions& options, const std::string& s3_path) :
- options_(options),
+S3FileSystem::S3FileSystem(const std::string& s3_path) :
s3_regex_(FileSystem::S3_URL_PREFIX + "([0-9a-zA-Z-.]+):([0-9]+)/([0-9a-z.-]+)(((/"
"[0-9a-zA-Z.-_]+)*)?)"),
proxy_regex_("^(https?)://(([^:]{1,128}):([^@]{1,256})@)?([^:/]{1,255})(:([0-9]{1,5}))?/?") {
- Aws::Client::ClientConfiguration config;
- Aws::Auth::AWSCredentials credentials;
-
- const char* profile_name = std::getenv("AWS_PROFILE");
- const char* secret_key = std::getenv("AWS_SECRET_ACCESS_KEY");
- const char* key_id = std::getenv("AWS_ACCESS_KEY_ID");
- const char* region = std::getenv("AWS_REGION");
- const char* session_token = std::getenv("AWS_SESSION_TOKEN");
- const char* s3_endpoint = std::getenv("S3_ENDPOINT");
- const char* http_proxy = std::getenv("http_proxy") != nullptr ? std::getenv("http_proxy") : std::getenv("HTTP_PROXY");
- const char* https_proxy = std::getenv("https_proxy") != nullptr ? std::getenv("https_proxy") : std::getenv("HTTPS_PROXY");
- const std::string default_proxy = https_proxy != nullptr ? std::string(https_proxy) : http_proxy != nullptr ? std::string(http_proxy) : "";
-
- if ((secret_key != NULL) && (key_id != NULL)) {
- credentials.SetAWSAccessKeyId(key_id);
- credentials.SetAWSSecretKey(secret_key);
- config = Aws::Client::ClientConfiguration();
- if (region != NULL) {
- config.region = region;
- }
- if (session_token != NULL) {
- credentials.SetSessionToken(session_token);
- }
- } else if (profile_name) {
- config = Aws::Client::ClientConfiguration(profile_name);
- } else {
- config = Aws::Client::ClientConfiguration("default");
- }
-
- std::string host_name, host_port, bucket, object;
- std::smatch sm;
- if (std::regex_match(s3_path, sm, s3_regex_)) {
- host_name = sm[1];
- host_port = sm[2];
- bucket = sm[3];
- object = sm[4];
-
- config.endpointOverride = Aws::String(host_name + ":" + host_port);
- config.scheme = Aws::Http::Scheme::HTTP;
- }
- if (s3_endpoint != NULL) {
- std::string endpoint(s3_endpoint);
- if (endpoint.rfind("http://") != std::string::npos) {
- endpoint = endpoint.substr(7);
- }
- config.endpointOverride = Aws::String(endpoint.c_str());
- config.scheme = Aws::Http::Scheme::HTTP;
- }
-
- if (!default_proxy.empty()) {
- if (std::regex_match(default_proxy, sm, proxy_regex_)) {
- config.proxyHost = sm[5].str();
- config.proxyPort = std::stoi(sm[7].str());
- config.proxyScheme = sm[1].str().size() == 4 ? Aws::Http::Scheme::HTTP : Aws::Http::Scheme::HTTPS;
- if (!sm[3].str().empty()) {
- config.proxyUserName = sm[3].str();
- }
- if (!sm[4].str().empty()) {
- config.proxyPassword = sm[4].str();
- }
- } else {
- SPDLOG_LOGGER_ERROR(s3_logger, "Couldn't parse proxy: {}", default_proxy);
- }
- }
-
- if (profile_name) {
- client_ = s3::S3Client(
- config,
- Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
- false);
- } else if ((secret_key != NULL) && (key_id != NULL)) {
- client_ = s3::S3Client(
- credentials,
- config,
- Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
- false);
- } else {
- std::shared_ptr provider = std::make_shared();
- client_ = s3::S3Client(
- provider,
- config,
- Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
- true);
- }
}
S3FileSystem::~S3FileSystem() {
- Aws::ShutdownAPI(options_);
}
StatusCode S3FileSystem::fileExists(const std::string& path, bool* exists) {
- *exists = false;
- std::string bucket, object;
-
- auto status = parsePath(path, &bucket, &object);
- if (status != StatusCode::OK) {
- return status;
- }
-
- s3::Model::HeadObjectRequest head_request;
- head_request.SetBucket(bucket.c_str());
- head_request.SetKey(object.c_str());
-
- auto head_object_outcome = client_.HeadObject(head_request);
- if (head_object_outcome.IsSuccess()) {
- *exists = true;
- return StatusCode::OK;
- }
-
- bool is_dir;
- status = isDirectory(path, &is_dir);
- if (status != StatusCode::OK) {
- return status;
- }
- *exists = is_dir;
-
return StatusCode::OK;
}
StatusCode S3FileSystem::isDirectory(const std::string& path, bool* is_dir) {
- *is_dir = false;
- std::string bucket, object_path;
- auto status = parsePath(path, &bucket, &object_path);
- if (status != StatusCode::OK) {
- return status;
- }
-
- // Check if the bucket exists
- s3::Model::HeadBucketRequest head_request;
- head_request.WithBucket(bucket.c_str());
-
- auto head_bucket_outcome = client_.HeadBucket(head_request);
- if (!head_bucket_outcome.IsSuccess()) {
- SPDLOG_LOGGER_ERROR(s3_logger, "Invalid or missing S3 credentials, or bucket does not exist - {}. {}", bucket, head_bucket_outcome.GetError().GetMessage());
- return StatusCode::S3_METADATA_FAIL;
- }
-
- // Root case - bucket exists and object path is empty
- if (object_path.empty()) {
- *is_dir = true;
- return StatusCode::OK;
- }
-
- // List the objects in the bucket
- s3::Model::ListObjectsRequest list_objects_request;
- list_objects_request.SetBucket(bucket.c_str());
- list_objects_request.SetPrefix(appendSlash(object_path).c_str());
- auto list_objects_outcome = client_.ListObjects(list_objects_request);
-
- if (list_objects_outcome.IsSuccess()) {
- *is_dir = !list_objects_outcome.GetResult().GetContents().empty();
- } else {
- SPDLOG_LOGGER_ERROR(s3_logger, "Failed to list objects with prefix {}", path);
- return StatusCode::S3_FAILED_LIST_OBJECTS;
- }
-
return StatusCode::OK;
}
StatusCode S3FileSystem::getDirectoryContents(const std::string& path, std::set* contents) {
- // Parse bucket and dir_path
- std::string bucket, dir_path, full_dir;
- auto status = parsePath(path, &bucket, &dir_path);
- if (status != StatusCode::OK) {
- return status;
- }
- std::string true_path = FileSystem::S3_URL_PREFIX + bucket + '/' + dir_path;
-
- // Capture the full path to facilitate content listing
- full_dir = appendSlash(dir_path);
-
- // Issue request for objects with prefix
- s3::Model::ListObjectsRequest objects_request;
- objects_request.SetBucket(bucket.c_str());
- objects_request.SetPrefix(full_dir.c_str());
- auto list_objects_outcome = client_.ListObjects(objects_request);
-
- if (list_objects_outcome.IsSuccess()) {
- Aws::Vector object_list = list_objects_outcome.GetResult().GetContents();
- for (auto const& s3_object : object_list) {
- // In the case of empty directories, the directory itself will appear here
- if (s3_object.GetKey().c_str() == full_dir) {
- continue;
- }
-
- // We have to make sure that subdirectory contents do not appear here
- std::string name(s3_object.GetKey().c_str());
- int item_start = name.find(full_dir) + full_dir.size();
- int item_end = name.find("/", item_start);
-
- // Let set take care of subdirectory contents
- std::string item = name.substr(item_start, item_end - item_start);
- contents->insert(item);
- }
- } else {
- SPDLOG_LOGGER_ERROR(s3_logger, "Could not list contents of directory {}", true_path);
- return StatusCode::S3_INVALID_ACCESS;
- }
-
return StatusCode::OK;
}
StatusCode S3FileSystem::getDirectorySubdirs(const std::string& path, std::set* subdirs) {
- // Parse bucket and dir_path
- std::string bucket, dir_path;
- auto status = parsePath(path, &bucket, &dir_path);
- if (status != StatusCode::OK) {
- return status;
- }
- std::string true_path = FileSystem::S3_URL_PREFIX + bucket + '/' + dir_path;
- status = getDirectoryContents(true_path, subdirs);
- if (status != StatusCode::OK) {
- return status;
- }
-
- // Erase non-directory entries...
- for (auto iter = subdirs->begin(); iter != subdirs->end();) {
- bool is_dir;
- status = isDirectory(FileSystem::joinPath({true_path, *iter}), &is_dir);
- if (status != StatusCode::OK) {
- return status;
- }
- if (!is_dir) {
- iter = subdirs->erase(iter);
- } else {
- ++iter;
- }
- }
-
return StatusCode::OK;
}
StatusCode S3FileSystem::getDirectoryFiles(const std::string& path, std::set* files) {
- // Parse bucket and dir_path
- std::string bucket, dir_path;
- auto status = parsePath(path, &bucket, &dir_path);
- if (status != StatusCode::OK) {
- return status;
- }
-
- std::string true_path = FileSystem::S3_URL_PREFIX + bucket + '/' + dir_path;
- status = getDirectoryContents(true_path, files);
- if (status != StatusCode::OK) {
- return status;
- }
-
- // Erase directory entries...
- for (auto iter = files->begin(); iter != files->end();) {
- bool is_dir;
- status = isDirectory(FileSystem::joinPath({true_path, *iter}), &is_dir);
- if (status != StatusCode::OK) {
- return status;
- }
- if (is_dir) {
- iter = files->erase(iter);
- } else {
- ++iter;
- }
- }
-
return StatusCode::OK;
}
StatusCode S3FileSystem::readTextFile(const std::string& path, std::string* contents) {
- bool exists;
- auto status = fileExists(path, &exists);
- if (status != StatusCode::OK) {
- return status;
- }
-
- if (!exists) {
- SPDLOG_LOGGER_ERROR(s3_logger, "File does not exist at {}", path);
- return StatusCode::S3_FILE_NOT_FOUND;
- }
-
- std::string bucket, object;
- status = parsePath(path, &bucket, &object);
- if (status != StatusCode::OK) {
- return status;
- }
-
- // Send a request for the objects metadata
- s3::Model::GetObjectRequest object_request;
- object_request.SetBucket(bucket.c_str());
- object_request.SetKey(object.c_str());
-
- auto get_object_outcome = client_.GetObject(object_request);
- if (get_object_outcome.IsSuccess()) {
- auto& object_result = get_object_outcome.GetResultWithOwnership().GetBody();
-
- std::string data = "";
- char c = 0;
- while (object_result.get(c)) {
- data += c;
- }
-
- *contents = data;
- } else {
- SPDLOG_LOGGER_ERROR(s3_logger, "Failed to get object at {}", path);
- return StatusCode::S3_FILE_INVALID;
- }
-
return StatusCode::OK;
}
StatusCode S3FileSystem::downloadFileFolder(const std::string& path, const std::string& local_path) {
- bool exists;
- auto status = fileExists(path, &exists);
- if (status != StatusCode::OK) {
- return status;
- }
- if (!exists) {
- SPDLOG_LOGGER_ERROR(s3_logger, "File/folder does not exist at {}", path);
- return StatusCode::S3_FILE_NOT_FOUND;
- }
-
- std::string effective_path, host_name, host_port, bucket, object;
-
- std::smatch sm;
- if (std::regex_match(path, sm, s3_regex_)) {
- host_name = sm[1];
- host_port = sm[2];
- bucket = sm[3];
- object = sm[4];
- effective_path = FileSystem::S3_URL_PREFIX + bucket + object;
- } else {
- effective_path = path;
- }
-
- bool is_dir = false;
- std::set contents, files;
- status = isDirectory(effective_path, &is_dir);
- if (status != StatusCode::OK) {
- return status;
- }
- if (is_dir) {
- status = getDirectoryContents(effective_path, &contents);
- if (status != StatusCode::OK) {
- return status;
- }
-
- for (auto iter = contents.begin(); iter != contents.end(); ++iter) {
- bool is_subdir;
- std::string s3_fpath = FileSystem::joinPath({effective_path, *iter});
- std::string local_fpath = FileSystem::joinPath({local_path, *iter});
- status = isDirectory(s3_fpath, &is_subdir);
- if (status != StatusCode::OK) {
- return status;
- }
- if (is_subdir) {
- // Create local mirror of sub-directories
- int status = mkdir(const_cast(local_fpath.c_str()), S_IRUSR | S_IWUSR | S_IXUSR);
- if (status == -1) {
- SPDLOG_LOGGER_ERROR(s3_logger, "Failed to create local folder: {} {} ", local_fpath, strerror(errno));
- return StatusCode::PATH_INVALID;
- }
-
- // Add with s3 path
- std::set subdir_files;
- auto s = getDirectoryFiles(s3_fpath, &subdir_files);
- if (s != StatusCode::OK) {
- return s;
- }
- for (auto itr = subdir_files.begin(); itr != subdir_files.end(); ++itr) {
- files.insert(FileSystem::joinPath({s3_fpath, *itr}));
- }
- } else {
- files.insert(s3_fpath);
- }
- }
-
- for (auto iter = files.begin(); iter != files.end(); ++iter) {
- if (std::any_of(acceptedFiles.begin(), acceptedFiles.end(), [&iter](const std::string& x) {
- return iter->size() > 0 && endsWith(*iter, x);
- })) {
- std::string bucket, object;
- status = parsePath(*iter, &bucket, &object);
- if (status != StatusCode::OK) {
- return status;
- }
-
- // Send a request for the objects metadata
- s3::Model::GetObjectRequest object_request;
- object_request.SetBucket(bucket.c_str());
- object_request.SetKey(object.c_str());
-
- auto get_object_outcome = client_.GetObject(object_request);
- if (get_object_outcome.IsSuccess()) {
- auto& retrieved_file =
- get_object_outcome.GetResultWithOwnership().GetBody();
- std::string s3_removed_path = (*iter).substr(effective_path.size());
- std::string local_file_path = FileSystem::joinPath({local_path, s3_removed_path});
- std::ofstream output_file(local_file_path.c_str(), std::ios::binary);
- output_file << retrieved_file.rdbuf();
- output_file.close();
- } else {
- SPDLOG_LOGGER_ERROR(s3_logger, "Failed to get object at {}", *iter);
- return StatusCode::S3_FAILED_GET_OBJECT;
- }
- }
- }
- } else {
- std::string bucket, object;
- auto s = parsePath(effective_path, &bucket, &object);
- if (s != StatusCode::OK) {
- return s;
- }
-
- // Send a request for the objects metadata
- s3::Model::GetObjectRequest object_request;
- object_request.SetBucket(bucket.c_str());
- object_request.SetKey(object.c_str());
-
- auto get_object_outcome = client_.GetObject(object_request);
- if (get_object_outcome.IsSuccess()) {
- auto& retrieved_file = get_object_outcome.GetResultWithOwnership().GetBody();
- std::ofstream output_file(local_path.c_str(), std::ios::binary);
- output_file << retrieved_file.rdbuf();
- output_file.close();
- } else {
- SPDLOG_LOGGER_ERROR(s3_logger, "Failed to get object at {}", effective_path);
- return StatusCode::S3_FAILED_GET_OBJECT;
- }
- }
-
return StatusCode::OK;
}
-StatusCode S3FileSystem::downloadModelVersions(const std::string& path,
- std::string* local_path,
- const std::vector& versions) {
- auto sc = createTempPath(local_path);
- if (sc != StatusCode::OK) {
- SPDLOG_LOGGER_ERROR(s3_logger, "Failed to create a temporary path {}", sc);
- return sc;
- }
-
- StatusCode result = StatusCode::OK;
- for (auto& ver : versions) {
- std::string versionpath = path;
- if (!endsWith(versionpath, "/")) {
- versionpath.append("/");
- }
- versionpath.append(std::to_string(ver));
- std::string lpath = *local_path;
- if (!endsWith(lpath, "/")) {
- lpath.append("/");
- }
- lpath.append(std::to_string(ver));
- fs::create_directory(lpath);
- auto status = downloadFileFolder(versionpath, lpath);
- if (status != StatusCode::OK) {
- result = status;
- SPDLOG_LOGGER_ERROR(s3_logger, "Failed to download model version {}", versionpath);
- }
- }
-
- return result;
+StatusCode S3FileSystem::downloadModelVersions(const std::string& path, std::string* b, const std::vector& a){
+ return StatusCode::OK;
}
StatusCode S3FileSystem::deleteFileFolder(const std::string& path) {
- SPDLOG_LOGGER_DEBUG(s3_logger, "Deleting local file folder {}", path);
- if (::remove(path.c_str()) == 0) {
- return StatusCode::OK;
- } else {
- SPDLOG_LOGGER_ERROR(s3_logger, "Unable to remove local path: {}", path);
- return StatusCode::FILE_INVALID;
- }
+ return StatusCode::OK;
}
} // namespace ovms
diff --git a/src/s3filesystem.hpp b/src/s3filesystem.hpp
index 650d06b906..a85d6291d5 100644
--- a/src/s3filesystem.hpp
+++ b/src/s3filesystem.hpp
@@ -19,9 +19,6 @@
#include
#include
-#include
-#include
-
#include "filesystem.hpp"
#include "status.hpp"
@@ -35,7 +32,7 @@ class S3FileSystem : public FileSystem {
* @param options
* @param s3_path
*/
- S3FileSystem(const Aws::SDKOptions& options, const std::string& s3_path);
+ S3FileSystem(const std::string& s3_path);
/**
* @brief Destroy the S3FileSystem object
@@ -139,13 +136,11 @@ class S3FileSystem : public FileSystem {
* @brief
*
*/
- Aws::SDKOptions options_;
/**
* @brief
*
*/
- Aws::S3::S3Client client_;
std::regex s3_regex_;
std::regex proxy_regex_;
};
diff --git a/third_party/openvino/BUILD b/third_party/openvino/BUILD
index 58f0c60d14..14b940f358 100644
--- a/third_party/openvino/BUILD
+++ b/third_party/openvino/BUILD
@@ -51,7 +51,7 @@ cc_library(
cc_library(
name = "openvino",
srcs = glob([
- "lib/intel64/libopenvino.so"
+ "lib/aarch64/libopenvino.so"
]),
strip_include_prefix = "include/ie",
visibility = ["//visibility:public"],