diff --git a/HISTORY.md b/HISTORY.md index 0740e4efd9..e304eb36c4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,7 @@ * Fix double-offset bug in chunked sparse CSV row indices by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2279 ## Improvements +* Wrap `data_protocol` API by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2287 * Expose overwrite parameter for saving a profile by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2277 * Add label index support for aggregation by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2272 * Expose the fill value setter at the Python layer by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2274 diff --git a/tiledb/ctx.py b/tiledb/ctx.py index 3a9e94ed9a..5e0c7c55c4 100644 --- a/tiledb/ctx.py +++ b/tiledb/ctx.py @@ -452,6 +452,18 @@ def get_stats(self, print_out: bool = True, json: bool = False): else: return output + def data_protocol(self, uri: str): + """Returns the data protocol version for the given URI. + + :param uri: URI to check for data protocol version + :return: DataProtocol enum value (DATA_PROTOCOL_V2 or DATA_PROTOCOL_V3) + :rtype: tiledb.DataProtocol + + For TileDB Cloud URIs (tiledb://), returns either v2 (legacy) or v3 (TileDB 3.0+). + For non-TileDB URIs (S3, Azure, GCS, etc.), returns v2. + """ + return super().data_protocol(uri) + class CtxMixin: """ diff --git a/tiledb/libtiledb/context.cc b/tiledb/libtiledb/context.cc index 754f8154af..88c2b7e34f 100644 --- a/tiledb/libtiledb/context.cc +++ b/tiledb/libtiledb/context.cc @@ -24,7 +24,12 @@ void init_context(py::module& m) { .def("config", &Context::config) .def("set_tag", &Context::set_tag) .def("get_stats", &Context::stats) - .def("is_supported_fs", &Context::is_supported_fs); + .def("is_supported_fs", &Context::is_supported_fs) +#if TILEDB_VERSION_MAJOR >= 3 || \ + (TILEDB_VERSION_MAJOR == 2 && TILEDB_VERSION_MINOR >= 30) + .def("data_protocol", &Context::data_protocol) +#endif + ; } void init_config(py::module& m) { diff --git a/tiledb/libtiledb/enum.cc b/tiledb/libtiledb/enum.cc index a450ad0573..bed09a6492 100644 --- a/tiledb/libtiledb/enum.cc +++ b/tiledb/libtiledb/enum.cc @@ -182,6 +182,13 @@ void init_enums(py::module& m) { py::enum_(m, "CurrentDomainType") .value("NDRECTANGLE", TILEDB_NDRECTANGLE); #endif + +#if TILEDB_VERSION_MAJOR >= 3 || \ + (TILEDB_VERSION_MAJOR == 2 && TILEDB_VERSION_MINOR >= 30) + py::enum_(m, "DataProtocol") + .value("DATA_PROTOCOL_V2", tiledb::Context::DataProtocol::v2) + .value("DATA_PROTOCOL_V3", tiledb::Context::DataProtocol::v3); +#endif // test helpers to check enum name against typed value m.def("_enum_string", &tiledb::impl::type_to_str); m.def(