Skip to content

Commit

Permalink
Merge branch 'main' into 70_s3_unit_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMichell authored Aug 7, 2024
2 parents 0671b4d + 829f49d commit 3322390
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
30 changes: 17 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,23 @@ list(APPEND mdio_TEST_COPTS
"-Wno-unknown-warning-option")

# Define the internal dependencies that should be linked
set(mdio_INTERNAL_DEPS
tensorstore::driver_array
tensorstore::driver_zarr
tensorstore::driver_json
tensorstore::kvstore_file
tensorstore::kvstore_memory
tensorstore::tensorstore
tensorstore::index_space_dim_expression
tensorstore::index_space_index_transform
tensorstore::util_status_testutil
tensorstore::driver_array
PARENT_SCOPE
)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# This is not the top-level project
set(mdio_INTERNAL_DEPS
tensorstore::driver_array
tensorstore::driver_zarr
tensorstore::driver_json
tensorstore::kvstore_file
tensorstore::kvstore_memory
tensorstore::tensorstore
tensorstore::index_space_dim_expression
tensorstore::index_space_index_transform
tensorstore::util_status_testutil
tensorstore::kvstore_gcs
tensorstore::driver_array
PARENT_SCOPE
)
endif()

# Define internal deps for cloud specific drivers
set(mdio_INTERNAL_GCS_DRIVER_DEPS
Expand Down
6 changes: 6 additions & 0 deletions mdio/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,14 @@ from_zmetadata(const std::string& dataset_path) {
// FIXME - enable async
auto kvs_future = mdio::internal::dataset_kvs_store(dataset_path).result();

if (!kvs_future.ok()) {
return internal::CheckMissingDriverStatus(kvs_future.status());
}
auto kvs_read_result =
tensorstore::kvstore::Read(kvs_future.value(), ".zmetadata").result();
if (!kvs_read_result.ok()) {
return internal::CheckMissingDriverStatus(kvs_read_result.status());
}

::nlohmann::json zmetadata;
try {
Expand Down
37 changes: 36 additions & 1 deletion mdio/variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,41 @@ struct SliceDescriptor {
};

namespace internal {

/**
* @brief Checks a status for a missing driver message and returns an MDIO
* specific error message.
* @param status The status to check
* @return A driver specific message if the status is a missing driver message,
* otherwise the original status.
*/
absl::Status CheckMissingDriverStatus(const absl::Status& status) {
std::string error(status.message());
if (error.find("Error parsing object member \"driver\"") !=
std::string::npos) {
if (error.find("is not registered") != std::string::npos) {
if (error.find("gcs") != std::string::npos) {
return absl::InvalidArgumentError(
"A GCS path was detected but the GCS driver was not "
"registered.\nPlease ensure that your CMake includes the "
"mdio_INTERNAL_GCS_DRIVER_DEPS variable.");
} else if (error.find("s3") != std::string::npos) {
return absl::InvalidArgumentError(
"An S3 path was detected but the S3 driver was not "
"registered.\nPlease ensure that your CMake includes the "
"mdio_INTERNAL_S3_DRIVER_DEPS variable.");
} else {
return absl::InvalidArgumentError(
"An unexpected driver registration error has occured. Please file "
"a bug report with the error message to "
"https://github.com/TGSAI/mdio-cpp/issues\n" +
error);
}
}
}
return status;
}

/**
* @brief Validates and processes a JSON specification for a tensorstore
* variable.
Expand Down Expand Up @@ -358,7 +393,7 @@ Future<Variable<T, R, M>> CreateVariable(const nlohmann::json& json_spec,
tensorstore::ReadyFuture<void> readyFut) {
auto ready_result = readyFut.result();
if (!ready_result.ok()) {
promise.SetResult(ready_result.status());
promise.SetResult(CheckMissingDriverStatus(ready_result.status()));
} else {
promise.SetResult(variable_future.result());
}
Expand Down

0 comments on commit 3322390

Please sign in to comment.