diff --git a/mdio/dataset.h b/mdio/dataset.h index 7b5a9a9..075f3d5 100644 --- a/mdio/dataset.h +++ b/mdio/dataset.h @@ -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().back() == '/') { + base["kvstore"]["path"] = base["kvstore"]["path"].get().substr( + 0, base["kvstore"]["path"].get().size() - 1); + } // Handle cloud stores if (specJson["kvstore"].contains("bucket")) { @@ -1261,8 +1266,6 @@ class Dataset { } auto fieldedVar = mdio::Variable::Open(base, constants::kOpen); - // mdio::Future> fieldedVar = mdio::Variable::Open(base, constants::kOpen); auto pair = tensorstore::PromiseFuturePair>::Make(); fieldedVar.ExecuteWhenReady( diff --git a/mdio/dataset_test.cc b/mdio/dataset_test.cc index a44d9c3..bf17b50 100644 --- a/mdio/dataset_test.cc +++ b/mdio/dataset_test.cc @@ -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 desc1 = {"inline", 0, 5, 1}; mdio::RangeDescriptor desc2 = {"crossline", 0, 5, 1}; mdio::RangeDescriptor desc3 = {"depth", 0, 5, 1}; @@ -688,7 +686,6 @@ TEST(Dataset, selectField) { auto selectedVarFut = slicedDs.SelectField("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(); @@ -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("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();