Skip to content

Commit

Permalink
Fix missing Variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMichell committed Oct 22, 2024
1 parent f2683f2 commit bf1a7d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
7 changes: 5 additions & 2 deletions mdio/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,11 @@ class Dataset {
}
base["kvstore"]["driver"] = specJson["kvstore"]["driver"];
base["kvstore"]["path"] = specJson["kvstore"]["path"];
// Remove trailing slashes. This causes issue #130
while (base["kvstore"]["path"].get<std::string>().back() == '/') {
base["kvstore"]["path"] = base["kvstore"]["path"].get<std::string>().substr(
0, base["kvstore"]["path"].get<std::string>().size() - 1);
}

// Handle cloud stores
if (specJson["kvstore"].contains("bucket")) {
Expand All @@ -1261,8 +1266,6 @@ class Dataset {
}

auto fieldedVar = mdio::Variable<T, R, M>::Open(base, constants::kOpen);
// mdio::Future<mdio::Variable<T, R, M>> fieldedVar = mdio::Variable<T, R,
// M>::Open(base, constants::kOpen);

auto pair = tensorstore::PromiseFuturePair<mdio::Variable<T, R, M>>::Make();
fieldedVar.ExecuteWhenReady(
Expand Down
19 changes: 16 additions & 3 deletions mdio/dataset_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,6 @@ TEST(Dataset, selectField) {
ASSERT_TRUE(dataset.status().ok()) << dataset.status();
auto ds = dataset.value();

// std::cout << ds << std::endl;

mdio::RangeDescriptor<mdio::Index> desc1 = {"inline", 0, 5, 1};
mdio::RangeDescriptor<mdio::Index> desc2 = {"crossline", 0, 5, 1};
mdio::RangeDescriptor<mdio::Index> desc3 = {"depth", 0, 5, 1};
Expand All @@ -688,7 +686,6 @@ TEST(Dataset, selectField) {
auto selectedVarFut =
slicedDs.SelectField<mdio::dtypes::int32_t>("image_headers", "cdp-x");
ASSERT_TRUE(selectedVarFut.status().ok()) << selectedVarFut.status();
// std::cout << selectedVarFut.value() << std::endl;

auto typedInervalsRes = selectedVarFut.value().get_intervals();
ASSERT_TRUE(typedInervalsRes.status().ok()) << typedInervalsRes.status();
Expand All @@ -709,6 +706,22 @@ TEST(Dataset, selectField) {
<< "Dimension 1 max did not match";
}

TEST(Dataset, selectFieldName) {
auto json_var = GetToyExample();

auto dataset = mdio::Dataset::from_json(json_var, "zarrs/acceptance",
mdio::constants::kCreateClean);

ASSERT_TRUE(dataset.status().ok()) << dataset.status();
auto ds = dataset.value();

auto selectedVarFut =
ds.SelectField<mdio::dtypes::int32_t>("image_headers", "cdp-x");
ASSERT_TRUE(selectedVarFut.status().ok()) << selectedVarFut.status();
EXPECT_EQ(selectedVarFut.value().get_variable_name(), "image_headers")
<< "Expected selected variable to be named image_headers";
}

TEST(Dataset, fromConsolidatedMeta) {
auto json_vars = GetToyExample();

Expand Down

0 comments on commit bf1a7d6

Please sign in to comment.