Skip to content

Commit

Permalink
Merge pull request #79 from TGSAI/77_driver_messages
Browse files Browse the repository at this point in the history
77 driver messages
  • Loading branch information
blasscoc authored Aug 7, 2024
2 parents 16f7cb9 + fdfdbda commit f0a9b3c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
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 f0a9b3c

Please sign in to comment.