diff --git a/.gitignore b/.gitignore index 9daa9a8fc3..04b7efebbb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,9 +7,6 @@ __pycache__/ *.so *.dylib -# Cython extensions -*.cpp - # Distribution / packaging .Python env/ diff --git a/pyproject.toml b/pyproject.toml index 0e822ea338..9d2d7d124f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,6 @@ requires = [ "scikit-build-core", "pybind11", - "Cython>=3", "numpy>=2.0.1" ] build-backend = "scikit_build_core.build" diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index 3f9dc05ae6..6103a3630a 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -1,33 +1,3 @@ -# Cython - -add_custom_command( - OUTPUT libtiledb.cc - COMMAND Python::Interpreter -m cython - "${CMAKE_CURRENT_SOURCE_DIR}/libtiledb.pyx" --output-file libtiledb.cc - DEPENDS libtiledb.pyx - VERBATIM -) - -python_add_library( - libtiledb - MODULE - libtiledb.cc - WITH_SOABI -) - -target_link_libraries( - libtiledb - PUBLIC - Python::NumPy - TileDB::tiledb_shared -) - -target_compile_features( - libtiledb - PUBLIC - cxx_std_20 -) - # Pybind11 pybind11_add_module( @@ -64,7 +34,7 @@ if (TILEDB_SERIALIZATION) ) endif() -install(TARGETS main libtiledb DESTINATION tiledb) +install(TARGETS main DESTINATION tiledb) if(TILEDB_DOWNLOADED) message(STATUS "Adding \"libtiledb\" into install group") @@ -73,10 +43,8 @@ if(TILEDB_DOWNLOADED) if (APPLE) set_target_properties(main PROPERTIES INSTALL_RPATH "@loader_path") - set_target_properties(libtiledb PROPERTIES INSTALL_RPATH "@loader_path") elseif(UNIX) set_target_properties(main PROPERTIES INSTALL_RPATH "\$ORIGIN") - set_target_properties(libtiledb PROPERTIES INSTALL_RPATH "\$ORIGIN") endif() else() # If using external TileDB core library force it to be linked at runtime using RPATH @@ -84,7 +52,6 @@ else() get_filename_component(TILEDB_LOCATION ${TILEDB_LOCATION} DIRECTORY) message(STATUS "Setting RPATH for targets \"main\" and \"libtiledb\" to ${TILEDB_LOCATION}") set_target_properties(main PROPERTIES INSTALL_RPATH ${TILEDB_LOCATION}) - set_target_properties(libtiledb PROPERTIES INSTALL_RPATH ${TILEDB_LOCATION}) endif() -add_subdirectory(cc) \ No newline at end of file +add_subdirectory(libtiledb) \ No newline at end of file diff --git a/tiledb/__init__.py b/tiledb/__init__.py index 4546c015e3..5c39b061cf 100644 --- a/tiledb/__init__.py +++ b/tiledb/__init__.py @@ -2,15 +2,6 @@ import os import sys -# un-comment this section to fix Cython backtrace line-numbers in -# IPython/Jupyter. see https://bugs.python.org/issue32797#msg323167 -# --- -# try: -# from importlib.machinery import ExtensionFileLoader -# else: -# del ExtensionFileLoader.get_source -# --- - if os.name == "posix": if sys.platform == "darwin": lib_name = "libtiledb.dylib" @@ -19,6 +10,14 @@ else: lib_name = "tiledb" +import numpy as np + +# TODO: get rid of this - It is currently used for unified numpy printing accross numpy versions +np.set_printoptions( + legacy="1.21" if np.lib.NumpyVersion(np.__version__) >= "1.22.0" else False +) +del np + from tiledb.libtiledb import version as libtiledb_version if libtiledb_version()[0] == 2 and libtiledb_version()[1] >= 26: @@ -30,7 +29,6 @@ from .array import Array from .array_schema import ArraySchema from .attribute import Attr -from .cc import TileDBError from .consolidation_plan import ConsolidationPlan from .ctx import Config, Ctx, default_ctx, scope_ctx from .dataframe_ import from_csv, from_pandas, open_dataframe @@ -88,7 +86,7 @@ vacuum, walk, ) -from .libtiledb import Ctx +from .libtiledb import TileDBError from .multirange_indexing import EmptyRange from .object import Object from .parquet_ import from_parquet diff --git a/tiledb/aggregation.py b/tiledb/aggregation.py index d1ba5dd98c..1ec93684a6 100644 --- a/tiledb/aggregation.py +++ b/tiledb/aggregation.py @@ -1,4 +1,4 @@ -import tiledb.cc as lt +import tiledb.libtiledb as lt class Aggregation: diff --git a/tiledb/array.py b/tiledb/array.py index 9fef9c5d99..986c693e09 100644 --- a/tiledb/array.py +++ b/tiledb/array.py @@ -4,7 +4,7 @@ import numpy as np import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Config, Ctx, default_ctx from .datatypes import DataType diff --git a/tiledb/array_schema.py b/tiledb/array_schema.py index 7bdddc909b..16fc9ba56d 100644 --- a/tiledb/array_schema.py +++ b/tiledb/array_schema.py @@ -5,8 +5,7 @@ import numpy as np -import tiledb.cc as lt -from tiledb.libtiledb import version as libtiledb_version +import tiledb.libtiledb as lt from .attribute import Attr from .ctx import Ctx, CtxMixin, default_ctx @@ -14,7 +13,7 @@ from .domain import Domain from .filter import Filter, FilterList -if libtiledb_version()[0] == 2 and libtiledb_version()[1] >= 26: +if lt.version()[0] == 2 and lt.version()[1] >= 25: from .current_domain import CurrentDomain _tiledb_order_to_string = { @@ -388,7 +387,7 @@ def has_dim_label(self, name: str) -> bool: """ return self._has_dim_label(self._ctx, name) - if libtiledb_version()[0] == 2 and libtiledb_version()[1] >= 26: + if lt.version()[0] == 2 and lt.version()[1] >= 25: @property def current_domain(self) -> CurrentDomain: diff --git a/tiledb/attribute.py b/tiledb/attribute.py index 0e723fe0c0..2ba713abaa 100644 --- a/tiledb/attribute.py +++ b/tiledb/attribute.py @@ -4,7 +4,7 @@ import numpy as np -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, CtxMixin from .datatypes import DataType diff --git a/tiledb/common.pxi b/tiledb/common.pxi deleted file mode 100644 index 85137e4325..0000000000 --- a/tiledb/common.pxi +++ /dev/null @@ -1,62 +0,0 @@ -from cpython.bytes cimport ( - PyBytes_AS_STRING, - PyBytes_FromString, - PyBytes_FromStringAndSize, - PyBytes_GET_SIZE, - PyBytes_Size, -) -from cpython.float cimport PyFloat_FromDouble -from cpython.long cimport PyLong_FromLong -from cpython.ref cimport Py_DECREF, Py_INCREF, PyTypeObject -from libc cimport limits -from libc.stddef cimport ptrdiff_t -from libc.stdint cimport ( - int8_t, - int16_t, - int32_t, - int64_t, - uint8_t, - uint16_t, - uint32_t, - uint64_t, - uintptr_t, -) -from libc.stdio cimport FILE, stdout -from libc.stdlib cimport calloc, free, malloc -from libc.string cimport memcpy -from libcpp.vector cimport vector - - -cdef extern from "Python.h": - object PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size) - object PyUnicode_FromString(const char *u) - -# Numpy imports -""" -cdef extern from "numpyFlags.h": - # Include 'numpyFlags.h' into the generated C code to disable warning. - # This must be included before numpy is cimported - pass -""" - -import numpy as np - -cimport numpy as np - - -cdef extern from "numpy/arrayobject.h": - # Steals a reference to dtype, need to incref the dtype - object PyArray_NewFromDescr(PyTypeObject* subtype, - np.dtype descr, - int nd, - np.npy_intp* dims, - np.npy_intp* strides, - void* data, - int flags, - object obj) - # Steals a reference to dtype, need to incref the dtype - object PyArray_Scalar(void* ptr, np.dtype descr, object itemsize) - void PyArray_ENABLEFLAGS(np.ndarray arr, int flags) - void* PyDataMem_NEW(size_t nbytes) - void* PyDataMem_RENEW(void* data, size_t nbytes) - void PyDataMem_FREE(void* data) diff --git a/tiledb/consolidation_plan.py b/tiledb/consolidation_plan.py index 35f6733b11..cf9551aec6 100644 --- a/tiledb/consolidation_plan.py +++ b/tiledb/consolidation_plan.py @@ -1,6 +1,6 @@ import pprint -import tiledb.cc as lt +import tiledb.libtiledb as lt from .array import Array from .ctx import Ctx, CtxMixin, default_ctx diff --git a/tiledb/ctx.py b/tiledb/ctx.py index cc1a6314d6..c998921630 100644 --- a/tiledb/ctx.py +++ b/tiledb/ctx.py @@ -5,7 +5,7 @@ from typing import Union import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt _ctx_var = ContextVar("ctx") diff --git a/tiledb/current_domain.py b/tiledb/current_domain.py index b842ad73b7..527c429a0e 100644 --- a/tiledb/current_domain.py +++ b/tiledb/current_domain.py @@ -1,4 +1,4 @@ -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, CtxMixin from .domain import Domain diff --git a/tiledb/data_order.py b/tiledb/data_order.py index 9ff84a7486..154a7d2b89 100644 --- a/tiledb/data_order.py +++ b/tiledb/data_order.py @@ -1,6 +1,6 @@ from enum import Enum -import tiledb.cc as lt +import tiledb.libtiledb as lt class DataOrder(Enum): diff --git a/tiledb/datatypes.py b/tiledb/datatypes.py index de47506d3f..1cd29069e6 100644 --- a/tiledb/datatypes.py +++ b/tiledb/datatypes.py @@ -6,7 +6,7 @@ import numpy as np -import tiledb.cc as lt +import tiledb.libtiledb as lt @dataclass(frozen=True) diff --git a/tiledb/dense_array.py b/tiledb/dense_array.py index b1e12b1a95..1722480943 100644 --- a/tiledb/dense_array.py +++ b/tiledb/dense_array.py @@ -3,7 +3,7 @@ import numpy as np import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt from .array import ( Array, diff --git a/tiledb/dimension.py b/tiledb/dimension.py index 1e5eb35279..4f46032bf2 100644 --- a/tiledb/dimension.py +++ b/tiledb/dimension.py @@ -3,7 +3,7 @@ import numpy as np -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, CtxMixin from .datatypes import DataType diff --git a/tiledb/dimension_label.py b/tiledb/dimension_label.py index 3e762db9f9..3ca9dbe683 100644 --- a/tiledb/dimension_label.py +++ b/tiledb/dimension_label.py @@ -2,7 +2,7 @@ import numpy as np -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import CtxMixin from .data_order import DataOrder diff --git a/tiledb/dimension_label_schema.py b/tiledb/dimension_label_schema.py index f107dcb109..34b69a1119 100644 --- a/tiledb/dimension_label_schema.py +++ b/tiledb/dimension_label_schema.py @@ -2,7 +2,7 @@ import numpy as np -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, default_ctx from .data_order import DataOrder diff --git a/tiledb/domain.py b/tiledb/domain.py index fdb10e45e3..99b3ac9609 100644 --- a/tiledb/domain.py +++ b/tiledb/domain.py @@ -3,7 +3,7 @@ import numpy as np -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, CtxMixin from .datatypes import DataType diff --git a/tiledb/domain_indexer.py b/tiledb/domain_indexer.py index d6c178de65..8042a8be08 100644 --- a/tiledb/domain_indexer.py +++ b/tiledb/domain_indexer.py @@ -3,7 +3,7 @@ import numpy as np import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt def _index_as_tuple(idx): diff --git a/tiledb/enumeration.py b/tiledb/enumeration.py index 2bd7e930a5..46995355e5 100644 --- a/tiledb/enumeration.py +++ b/tiledb/enumeration.py @@ -6,7 +6,7 @@ import numpy as np from numpy.typing import NDArray -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, CtxMixin from .datatypes import DataType diff --git a/tiledb/filestore.py b/tiledb/filestore.py index ffe0de7660..b8f1c9cb49 100644 --- a/tiledb/filestore.py +++ b/tiledb/filestore.py @@ -1,7 +1,7 @@ import warnings from typing import ByteString, Optional -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, default_ctx diff --git a/tiledb/filter.py b/tiledb/filter.py index 6d60c763ad..6952dab08f 100644 --- a/tiledb/filter.py +++ b/tiledb/filter.py @@ -3,7 +3,7 @@ import numpy as np -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, CtxMixin from .datatypes import DataType diff --git a/tiledb/fragment.py b/tiledb/fragment.py index 04be4021ad..bd438e3889 100644 --- a/tiledb/fragment.py +++ b/tiledb/fragment.py @@ -5,8 +5,6 @@ import tiledb from tiledb.libtiledb import version as libtiledb_version -from .main import PyFragmentInfo - """ Classes and functions relating to TileDB fragments. """ @@ -105,6 +103,8 @@ def __init__(self, array_uri, include_mbrs=False, ctx=None): self.array_uri = array_uri + from .main import PyFragmentInfo + fi = PyFragmentInfo(self.array_uri, schema, include_mbrs, ctx) self.__nums = fi.get_num_fragments() @@ -188,6 +188,9 @@ def __init__(self, fragments): self._fragments = fragments self._index = 0 + def __iter__(self): + return self + def __next__(self): if self._index < len(self._fragments): fi = FragmentInfo(self._fragments, self._index) diff --git a/tiledb/group.py b/tiledb/group.py index 4a325523f3..0e7d858482 100644 --- a/tiledb/group.py +++ b/tiledb/group.py @@ -1,6 +1,6 @@ from typing import Optional, Union -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Config, Ctx, CtxMixin, default_ctx from .metadata import Metadata diff --git a/tiledb/highlevel.py b/tiledb/highlevel.py index 324049e13a..e9727a010b 100644 --- a/tiledb/highlevel.py +++ b/tiledb/highlevel.py @@ -5,7 +5,7 @@ import numpy as np import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt from .dataframe_ import create_dim diff --git a/tiledb/libtiledb.pxd b/tiledb/libtiledb.pxd deleted file mode 100644 index 2b49ef672b..0000000000 --- a/tiledb/libtiledb.pxd +++ /dev/null @@ -1,1129 +0,0 @@ -#!python -#cython: language_level=3 - -from libc.stdint cimport uint32_t, uint64_t -from libc.stdio cimport FILE -from .domain_indexer import DomainIndexer -include "common.pxi" - -cdef extern from "Python.h": - char* PyUnicode_AsUTF8(object unicode) - -cdef extern from "tiledb/tiledb.h": - # Constants - enum: TILEDB_OK - enum: TILEDB_ERR - enum: TILEDB_OOM - - enum: TILEDB_VAR_NUM - unsigned int tiledb_var_num() - - enum: TILEDB_MAX_PATH - unsigned int tiledb_max_path() - - enum: TILEDB_OFFSET_SIZE - unsigned int tiledb_offset_size() - - # Version - void tiledb_version(int* major, int* minor, int* rev) - - # Enums - ctypedef enum tiledb_object_t: - TILEDB_INVALID - TILEDB_GROUP - TILEDB_ARRAY - - ctypedef enum tiledb_query_type_t: - TILEDB_MODIFY_EXCLUSIVE - TILEDB_DELETE - TILEDB_READ - TILEDB_WRITE - - ctypedef enum tiledb_query_status_t: - TILEDB_FAILED - TILEDB_COMPLETED - TILEDB_INPROGRESS - TILEDB_INCOMPLETE - - ctypedef enum tiledb_datatype_t: - TILEDB_INT32 - TILEDB_INT64 - TILEDB_FLOAT32 - TILEDB_FLOAT64 - TILEDB_BLOB - TILEDB_GEOM_WKB - TILEDB_GEOM_WKT - TILEDB_CHAR - TILEDB_INT8 - TILEDB_UINT8 - TILEDB_INT16 - TILEDB_UINT16 - TILEDB_UINT32 - TILEDB_UINT64 - TILEDB_STRING_ASCII - TILEDB_STRING_UTF8 - TILEDB_STRING_UTF16 - TILEDB_STRING_UTF32 - TILEDB_STRING_UCS2 - TILEDB_STRING_UCS4 - TILEDB_DATETIME_YEAR - TILEDB_DATETIME_MONTH - TILEDB_DATETIME_WEEK - TILEDB_DATETIME_DAY - TILEDB_DATETIME_HR - TILEDB_DATETIME_MIN - TILEDB_DATETIME_SEC - TILEDB_DATETIME_MS - TILEDB_DATETIME_US - TILEDB_DATETIME_NS - TILEDB_DATETIME_PS - TILEDB_DATETIME_FS - TILEDB_DATETIME_AS - TILEDB_BOOL - - ctypedef enum tiledb_array_type_t: - TILEDB_DENSE - TILEDB_SPARSE - - ctypedef enum tiledb_layout_t: - TILEDB_ROW_MAJOR - TILEDB_COL_MAJOR - TILEDB_GLOBAL_ORDER - TILEDB_UNORDERED - TILEDB_HILBERT - - ctypedef enum tiledb_data_order_t: - TILEDB_UNORDERED_DATA - TILEDB_INCREASING_DATA - TILEDB_DECREASING_DATA - - ctypedef enum tiledb_encryption_type_t: - TILEDB_NO_ENCRYPTION - TILEDB_AES_256_GCM - - ctypedef enum tiledb_filesystem_t: - TILEDB_HDFS - TILEDB_S3 - TILEDB_AZURE - TILEDB_GCS - - ctypedef enum tiledb_vfs_mode_t: - TILEDB_VFS_READ - TILEDB_VFS_WRITE - TILEDB_VFS_APPEND - - # Types - ctypedef struct tiledb_ctx_t: - pass - ctypedef struct tiledb_config_t: - pass - ctypedef struct tiledb_config_iter_t: - pass - ctypedef struct tiledb_enumeration_t: - pass - ctypedef struct tiledb_error_t: - pass - ctypedef struct tiledb_array_t: - pass - ctypedef struct tiledb_attribute_t: - pass - ctypedef struct tiledb_array_schema_t: - pass - ctypedef struct tiledb_dimension_t: - pass - ctypedef struct tiledb_domain_t: - pass - ctypedef struct tiledb_query_t: - pass - ctypedef struct tiledb_subarray_t: - pass - ctypedef struct tiledb_filter_list_t: - pass - ctypedef struct tiledb_vfs_t: - pass - ctypedef struct tiledb_vfs_fh_t: - pass - - # Config - int tiledb_config_alloc( - tiledb_config_t** config, - tiledb_error_t** error) - - void tiledb_config_free( - tiledb_config_t** config) - - int tiledb_config_set( - tiledb_config_t* config, - const char* param, - const char* value, - tiledb_error_t** error) - - int tiledb_config_get( - tiledb_config_t* config, - const char* param, - const char** value, - tiledb_error_t** error) - - int tiledb_config_load_from_file( - tiledb_config_t* config, - const char* filename, - tiledb_error_t** error) nogil - - int tiledb_config_unset( - tiledb_config_t* config, - const char* param, - tiledb_error_t** error) - - int tiledb_config_save_to_file( - tiledb_config_t* config, - const char* filename, - tiledb_error_t** error) nogil - - # Config Iterator - int tiledb_config_iter_alloc( - tiledb_config_t* config, - const char* prefix, - tiledb_config_iter_t** config_iter, - tiledb_error_t** error) - - void tiledb_config_iter_free( - tiledb_config_iter_t** config_iter) - - int tiledb_config_iter_here( - tiledb_config_iter_t* config_iter, - const char** param, - const char** value, - tiledb_error_t** error) - - int tiledb_config_iter_next( - tiledb_config_iter_t* config_iter, - tiledb_error_t** error) - - int tiledb_config_iter_done( - tiledb_config_iter_t* config_iter, - int* done, - tiledb_error_t** error) - - # Context - int tiledb_ctx_alloc( - tiledb_config_t* config, - tiledb_ctx_t** ctx) - - void tiledb_ctx_free( - tiledb_ctx_t** ctx) - - int tiledb_ctx_get_config( - tiledb_ctx_t* ctx, - tiledb_config_t** config) - - int tiledb_ctx_get_last_error( - tiledb_ctx_t* ctx, - tiledb_error_t** error) - - int tiledb_ctx_get_stats( - tiledb_ctx_t* ctx, - char** stats_json); - - int tiledb_ctx_is_supported_fs( - tiledb_ctx_t* ctx, - tiledb_filesystem_t fs, - int* is_supported) - - int tiledb_ctx_set_tag( - tiledb_ctx_t* ctx, - const char* key, - const char* value) - - # Error - int tiledb_error_message( - tiledb_error_t* err, - char** msg) - - void tiledb_error_free( - tiledb_error_t** err) - - # Attribute - int tiledb_attribute_alloc( - tiledb_ctx_t* ctx, - const char* name, - tiledb_datatype_t atype, - tiledb_attribute_t** attr) - - void tiledb_attribute_free( - tiledb_attribute_t** attr) - - int tiledb_attribute_set_filter_list( - tiledb_ctx_t* ctx_ptr, - const tiledb_attribute_t* attr, - tiledb_filter_list_t* filter_list) - - int tiledb_attribute_set_fill_value( - tiledb_ctx_t *ctx, - tiledb_attribute_t *attr, - const void *value, uint64_t size) - - int tiledb_attribute_set_cell_val_num( - tiledb_ctx_t* ctx, - tiledb_attribute_t* attr, - unsigned int cell_val_num) - - int tiledb_attribute_get_name( - tiledb_ctx_t* ctx, - const tiledb_attribute_t* attr, - const char** name) - - int tiledb_attribute_get_type( - tiledb_ctx_t* ctx, - const tiledb_attribute_t* attr, - tiledb_datatype_t* type) - - int tiledb_attribute_get_filter_list( - tiledb_ctx_t* ctx, - const tiledb_attribute_t* attr, - tiledb_filter_list_t** filter_list) - - int tiledb_attribute_get_fill_value( - tiledb_ctx_t *ctx, - tiledb_attribute_t *attr, - const void **value, - uint64_t *size) - - int tiledb_attribute_get_cell_val_num( - tiledb_ctx_t* ctx, - const tiledb_attribute_t* attr, - unsigned int* cell_val_num) - - int tiledb_attribute_set_nullable( - tiledb_ctx_t* ctx, - const tiledb_attribute_t* attr, - uint8_t nullable) - - int tiledb_attribute_get_nullable( - tiledb_ctx_t* ctx, - const tiledb_attribute_t* attr, - uint8_t* nullable) - - int tiledb_attribute_dump( - tiledb_ctx_t* ctx, - const tiledb_attribute_t* attr, - FILE* out) - - # Datatype - uint64_t tiledb_datatype_size( - tiledb_datatype_t type); - - # Domain - int tiledb_domain_alloc( - tiledb_ctx_t* ctx, - tiledb_domain_t** domain) - - void tiledb_domain_free( - tiledb_domain_t** domain) - - int tiledb_domain_get_type( - tiledb_ctx_t* ctx, - const tiledb_domain_t* domain, - tiledb_datatype_t* dtype) - - int tiledb_domain_get_ndim( - tiledb_ctx_t* ctx, - const tiledb_domain_t* domain, - unsigned int* ndim) - - int tiledb_domain_add_dimension( - tiledb_ctx_t* ctx, - tiledb_domain_t* domain, - tiledb_dimension_t* dim) - - int tiledb_domain_get_dimension_from_index( - tiledb_ctx_t* ctx, - const tiledb_domain_t* domain, - unsigned int index, - tiledb_dimension_t** dim) - - int tiledb_domain_get_dimension_from_name( - tiledb_ctx_t* ctx, - const tiledb_domain_t* domain, - const char* name, - tiledb_dimension_t** dim) - - int tiledb_domain_has_dimension( - tiledb_ctx_t * ctx, - const tiledb_domain_t* domain, - const char* name, - int32_t* has_dim) - - int tiledb_domain_dump( - tiledb_ctx_t* ctx, - const tiledb_domain_t* domain, - FILE* out) - - # Dimension - int tiledb_dimension_alloc( - tiledb_ctx_t* ctx, - const char* name, - tiledb_datatype_t type, - const void* dim_domain, - const void* tile_extent, - tiledb_dimension_t** dim) - - void tiledb_dimension_free( - tiledb_dimension_t** dim) - - int tiledb_dimension_get_name( - tiledb_ctx_t* ctx, - const tiledb_dimension_t* dim, - const char** name) - - int tiledb_dimension_get_cell_val_num( - tiledb_ctx_t* ctx, - const tiledb_dimension_t* dim, - uint32_t* cell_val_num) - - int tiledb_dimension_get_type( - tiledb_ctx_t* ctx, - const tiledb_dimension_t* dim, - tiledb_datatype_t* type) - - int tiledb_dimension_get_domain( - tiledb_ctx_t* ctx, - const tiledb_dimension_t* dim, - const void** domain) - - int tiledb_dimension_get_tile_extent( - tiledb_ctx_t* ctx, - const tiledb_dimension_t* dim, - const void** tile_extent) - - int tiledb_dimension_get_filter_list( - tiledb_ctx_t *ctx, - tiledb_dimension_t *dim, - tiledb_filter_list_t **filter_list) - - int tiledb_dimension_set_filter_list( - tiledb_ctx_t *ctx, - tiledb_dimension_t *dim, - tiledb_filter_list_t *filter_list) - - # Array schema - int tiledb_array_schema_alloc( - tiledb_ctx_t* ctx, - tiledb_array_type_t array_type, - tiledb_array_schema_t** array_schema) - - void tiledb_array_schema_free( - tiledb_array_schema_t** array_schema) - - int tiledb_array_schema_add_attribute( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - tiledb_attribute_t* attr) - - int tiledb_array_schema_has_attribute( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - const char* name, - int32_t* has_attr) - - int tiledb_array_schema_set_domain( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - tiledb_domain_t* domain); - - int tiledb_array_schema_set_capacity( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - uint64_t capacity); - - int tiledb_array_schema_set_cell_order( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - tiledb_layout_t cell_order); - - int tiledb_array_schema_set_tile_order( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - tiledb_layout_t tile_order) - - int tiledb_array_schema_set_offsets_filter_list( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schmea, - tiledb_filter_list_t* filter_list) - - int tiledb_array_schema_set_coords_filter_list( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - tiledb_filter_list_t* filter_list) - - int tiledb_array_schema_set_validity_filter_list( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - tiledb_filter_list_t* filter_list) - - int tiledb_array_schema_check( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema) - - int tiledb_array_schema_load( - tiledb_ctx_t* ctx, - const char* array_uri, - tiledb_array_schema_t** array_schema) nogil - - int tiledb_array_schema_get_array_type( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - tiledb_array_type_t* array_type) - - int tiledb_array_schema_get_capacity( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - uint64_t* capacity) - - int tiledb_array_schema_get_cell_order( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - tiledb_layout_t* cell_order) - - int tiledb_array_schema_get_coords_filter_list( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - tiledb_filter_list_t** filter_list) - - int tiledb_array_schema_get_offsets_filter_list( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - tiledb_filter_list_t** filter_list) - - int tiledb_array_schema_get_validity_filter_list( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - tiledb_filter_list_t** filter_list) - - int tiledb_array_schema_get_domain( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - tiledb_domain_t** domain) - - int tiledb_array_schema_get_tile_order( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - tiledb_layout_t* tile_order) - - int tiledb_array_schema_get_attribute_num( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - unsigned int* num_attributes) - - int tiledb_array_schema_get_attribute_from_index( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - unsigned int index, - tiledb_attribute_t** attr) - - int tiledb_array_schema_get_attribute_from_name( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - const char* name, - tiledb_attribute_t** attr) - - int tiledb_array_schema_get_array_name( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - const char** array_name) - - int tiledb_array_schema_get_allows_dups( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - int* allows_dups); - - int tiledb_array_schema_set_allows_dups( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - int allows_dups) - - int tiledb_array_schema_dump( - tiledb_ctx_t* ctx, - const tiledb_array_schema_t* array_schema, - FILE* out) - - int tiledb_array_schema_get_version( - tiledb_ctx_t* ctx, - tiledb_array_schema_t* array_schema, - uint32_t* version) - - int tiledb_array_get_open_timestamp_start( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint64_t* timestamp_start) - - int tiledb_array_get_open_timestamp_end( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint64_t* timestamp_end) - - int tiledb_array_set_config( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - tiledb_config_t* config) - - int tiledb_array_set_open_timestamp_start( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint64_t timestamp_start) - - int tiledb_array_set_open_timestamp_end( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint64_t timestamp_end) - - int tiledb_array_put_metadata( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - const char* key, - tiledb_datatype_t value_type, - uint32_t value_num, - const void* value) nogil - - int tiledb_array_delete_metadata( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - const char* key) nogil - - int tiledb_array_has_metadata_key( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - const char* key, - tiledb_datatype_t* value_type, - int32_t* has_key) nogil - - int tiledb_array_get_metadata( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - const char* key, - tiledb_datatype_t* value_type, - uint32_t* value_num, - const void** value) nogil - - int tiledb_array_get_metadata_num( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint64_t* num) nogil - - int tiledb_array_get_metadata_from_index( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint64_t index, - const char** key, - uint32_t* key_len, - tiledb_datatype_t* value_type, - uint32_t* value_num, - const void** value) nogil - - int tiledb_array_consolidate_metadata( - tiledb_ctx_t* ctx, - const char* array_uri, - tiledb_config_t* config) nogil - - int tiledb_array_delete( - tiledb_ctx_t* ctx, - const char* uri) nogil - - # Query - int tiledb_query_alloc( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - tiledb_query_type_t query_type, - tiledb_query_t** query) - - int tiledb_query_set_subarray_t( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - const tiledb_subarray_t*) - - int32_t tiledb_query_set_data_buffer( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - const char* name, - void* buffer, - uint64_t* buffer_size) - - int tiledb_query_set_validity_buffer( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - const char* name, - uint8_t* buffer, - uint64_t* buffer_size) - - int32_t tiledb_query_set_offsets_buffer( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - const char* name, - uint64_t* buffer, - uint64_t* buffer_size) - - int tiledb_query_set_layout( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - tiledb_layout_t layout) - - void tiledb_query_free( - tiledb_query_t** query) - - int tiledb_query_finalize( - tiledb_ctx_t* ctx, - tiledb_query_t* query) nogil - - int tiledb_query_submit( - tiledb_ctx_t* ctx, - tiledb_query_t* query) nogil - - int tiledb_query_submit_async( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - void* (*callback)(void*) noexcept, - void* callback_data) - - int tiledb_query_get_status( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - tiledb_query_status_t* status) - - int tiledb_query_get_subarray_t( - tiledb_ctx_t* ctx, - const tiledb_query_t* query, - tiledb_subarray_t** subarray) - - int tiledb_query_get_type( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - tiledb_query_type_t* query_type) - - int tiledb_query_has_results( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - int* has_results) - - int tiledb_query_get_fragment_num( - tiledb_ctx_t* ctx, - const tiledb_query_t* query, - uint32_t* num) - - int tiledb_query_get_fragment_uri( - tiledb_ctx_t* ctx, - const tiledb_query_t* query, - uint64_t idx, - const char** uri) - - int tiledb_query_get_fragment_timestamp_range( - tiledb_ctx_t* ctx, - const tiledb_query_t* query, - uint64_t idx, - uint64_t* t1, - uint64_t* t2) - - int tiledb_query_get_est_result_size( - tiledb_ctx_t* ctx, - const tiledb_query_t* query, - const char* attr_name, - uint64_t* size) - - int tiledb_query_get_est_result_size_var( - tiledb_ctx_t* ctx, - const tiledb_query_t* query, - const char* attr_name, - uint64_t* size_off, - uint64_t* size_val) - - int tiledb_query_get_stats( - tiledb_ctx_t* ctx, - tiledb_query_t* query, - char** stats_json) - - # Subarray - int tiledb_subarray_alloc( - tiledb_ctx_t* ctx, - const tiledb_array_t* array, - tiledb_subarray_t** subarray) - - void tiledb_subarray_free(tiledb_subarray_t** subarray) - - int tiledb_subarray_add_range( - tiledb_ctx_t* ctx, - tiledb_subarray_t* subarray, - uint32_t dim_idx, - const void* start, - const void* end, - const void* stride) - - int tiledb_subarray_add_range_var( - tiledb_ctx_t* ctx, - tiledb_subarray_t* subarray, - uint32_t dim_idx, - const void* start, - uint64_t start_size, - const void* end, - uint64_t end_size) - - int tiledb_subarray_set_subarray( - tiledb_ctx_t* ctx, - tiledb_subarray_t* subarray, - const void* subarray_v) - - # Array - int tiledb_array_alloc( - tiledb_ctx_t* ctx, - const char* uri, - tiledb_array_t** array) - - int tiledb_array_open( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - tiledb_query_type_t query_type) nogil - - int tiledb_array_reopen( - tiledb_ctx_t* ctx, - tiledb_array_t* array) nogil - - int tiledb_array_reopen_at( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint64_t timestamp) nogil - - int tiledb_array_close( - tiledb_ctx_t* ctx, - tiledb_array_t* array) nogil - - void tiledb_array_free( - tiledb_array_t** array) - - int tiledb_array_create( - tiledb_ctx_t* ctx, - const char* uri, - const tiledb_array_schema_t* array_schema) nogil - - int tiledb_array_is_open( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - int* is_open) - - int tiledb_array_consolidate( - tiledb_ctx_t* ctx, - const char* array_path, - tiledb_config_t* config) nogil - - int tiledb_array_delete_fragments_v2( - tiledb_ctx_t* ctx, - const char* uri, - uint64_t timestamp_start, - uint64_t timestamp_end) - - int tiledb_array_get_schema( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - tiledb_array_schema_t** array_schema) nogil - - int tiledb_array_get_timestamp( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint64_t* timestamp) nogil - - int tiledb_array_get_query_type( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - tiledb_query_type_t* query_type) - - int tiledb_array_get_non_empty_domain( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - void* domain, - int* isempty) nogil - - int32_t tiledb_array_get_non_empty_domain_from_index( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint32_t idx, - void* domain, - int32_t* is_empty); - - int32_t tiledb_array_get_non_empty_domain_from_name( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - const char* name, - void* domain, - int32_t* is_empty); - - int32_t tiledb_array_get_non_empty_domain_var_size_from_index( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint32_t idx, - uint64_t* start_size, - uint64_t* end_size, - int32_t* is_empty) - - int32_t tiledb_array_get_non_empty_domain_var_size_from_name( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - const char* name, - uint64_t* start_size, - uint64_t* end_size, - int32_t* is_empty) - - int32_t tiledb_array_get_non_empty_domain_var_from_index( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - uint32_t idx, - void* start, - void* end, - int32_t* is_empty); - - int32_t tiledb_array_get_non_empty_domain_var_from_name( - tiledb_ctx_t* ctx, - tiledb_array_t* array, - const char* name, - void* start, - void* end, - int32_t* is_empty) - - int32_t tiledb_array_get_enumeration( - tiledb_ctx_t* ctx, - const tiledb_array_t* array, - const char* name, - tiledb_enumeration_t** enumeration) - - int tiledb_array_vacuum( - tiledb_ctx_t* ctx, - const char* array_uri, - tiledb_config_t* config) nogil - - # Resource management - int tiledb_object_type( - tiledb_ctx_t* ctx, - const char* path, - tiledb_object_t* otype) nogil - - int tiledb_object_remove( - tiledb_ctx_t* ctx, - const char* path) nogil - - int tiledb_object_move( - tiledb_ctx_t* ctx, - const char* old_path, - const char* new_path) nogil - - int tiledb_object_ls( - tiledb_ctx_t* ctx, - const char* path, - int (*callback)(const char*, tiledb_object_t, void*) noexcept, - void* data) - - # VFS - int tiledb_vfs_alloc( - tiledb_ctx_t* ctx, - tiledb_config_t* config, - tiledb_vfs_t** vfs) - - void tiledb_vfs_free( - tiledb_vfs_t** vfs) - - int tiledb_vfs_create_bucket( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri) nogil - - int tiledb_vfs_remove_bucket( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri) nogil - - int tiledb_vfs_empty_bucket( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri) nogil - - int tiledb_vfs_is_empty_bucket( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri, - int* is_empty) nogil - - int tiledb_vfs_is_bucket( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri, - int* is_bucket) nogil - - int tiledb_vfs_create_dir( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri) nogil - - int tiledb_vfs_is_dir( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri, - int* is_dir) nogil - - int tiledb_vfs_remove_dir( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri) nogil - - int tiledb_vfs_is_file( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri, - int* is_file) nogil - - int tiledb_vfs_remove_file( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri) nogil - - int tiledb_vfs_file_size( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri, - uint64_t* size) nogil - - int tiledb_vfs_dir_size( - tiledb_ctx_t * ctx, - tiledb_vfs_t * vfs, - const char * uri, - uint64_t * size) nogil - - int tiledb_vfs_ls( - tiledb_ctx_t * ctx, - tiledb_vfs_t * vfs, - const char * path, - void * data) nogil - - int tiledb_vfs_move_file( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* old_uri, - const char* new_uri) nogil - - int tiledb_vfs_move_dir( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* old_uri, - const char* new_uri) nogil - - int tiledb_vfs_copy_file( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* old_uri, - const char* new_uri) nogil - - int tiledb_vfs_copy_dir( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* old_uri, - const char* new_uri) nogil - - int tiledb_vfs_open( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri, - tiledb_vfs_mode_t mode, - tiledb_vfs_fh_t** fh) nogil - - int tiledb_vfs_close( - tiledb_ctx_t* ctx, - tiledb_vfs_fh_t* fh) nogil - - int tiledb_vfs_read( - tiledb_ctx_t* ctx, - tiledb_vfs_fh_t* fh, - uint64_t offset, - void* buffer, - uint64_t nbytes) nogil - - int tiledb_vfs_write( - tiledb_ctx_t* ctx, - tiledb_vfs_fh_t* fh, - const void* buffer, - uint64_t nbytes) nogil - - int tiledb_vfs_sync( - tiledb_ctx_t* ctx, - tiledb_vfs_fh_t* fh) nogil - - void tiledb_vfs_fh_free( - tiledb_vfs_fh_t** fh) nogil - - int tiledb_vfs_fh_is_closed( - tiledb_ctx_t* ctx, - tiledb_vfs_fh_t* fh, - int* is_closed) nogil - - int tiledb_vfs_touch( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - const char* uri) nogil - - int tiledb_vfs_get_config( - tiledb_ctx_t* ctx, - tiledb_vfs_t* vfs, - tiledb_config_t** config) - - # URI - int tiledb_uri_to_path( - tiledb_ctx_t* ctx, - const char* uri, - char* path_out, - unsigned* path_length) nogil - - int tiledb_datatype_to_str( - tiledb_datatype_t datatype, - const char** datatype_str - ) - -cdef extern from "tiledb/tiledb_experimental.h": - # Filestore - int tiledb_filestore_schema_create( - tiledb_ctx_t* ctx, - const char* uri, - tiledb_array_schema_t** array_schema) nogil - - int tiledb_array_upgrade_version( - tiledb_ctx_t* ctx, - const char* array_uri, - tiledb_config_t* config) nogil - - int tiledb_array_consolidate_fragments( - tiledb_ctx_t* ctx, - const char* array_uri, - const char** fragment_uris, - const uint64_t num_fragments, - tiledb_config_t* config - ) - -# Free helper functions -cdef _raise_tiledb_error(tiledb_error_t* err_ptr) -cdef _raise_ctx_err(tiledb_ctx_t* ctx_ptr, int rc) - -############################################################################### -# # -# TileDB-Py API declaration # -# # -############################################################################### - -cdef class Query(object): - cdef object array - cdef object attrs - cdef object cond - cdef object dims - cdef object order - cdef object coords - cdef object index_col - cdef object use_arrow - cdef object return_arrow - cdef object return_incomplete - cdef object domain_index - cdef object multi_index - cdef object df - -cdef class ReadQuery(object): - cdef object _buffers - cdef object _offsets diff --git a/tiledb/libtiledb.pyx b/tiledb/libtiledb.pyx deleted file mode 100644 index 687a5dc668..0000000000 --- a/tiledb/libtiledb.pyx +++ /dev/null @@ -1,76 +0,0 @@ -#!python -#cython: embedsignature=True -#cython: auto_pickle=False - -from cpython.pycapsule cimport PyCapsule_GetPointer -from cpython.version cimport PY_MAJOR_VERSION - -include "common.pxi" - -from .cc import TileDBError -from .ctx import Config, Ctx, default_ctx -from .array import Array - -############################################################################### -# Numpy initialization code (critical) # -############################################################################### - -# https://docs.scipy.org/doc/numpy/reference/c-api.array.html#c.import_array -np.import_array() - -############################################################################### -# Utility/setup # -############################################################################### - -# Use unified numpy printing -np.set_printoptions(legacy="1.21" if np.lib.NumpyVersion(np.__version__) >= "1.22.0" else False) - - -cdef tiledb_ctx_t* safe_ctx_ptr(object ctx): - if ctx is None: - raise TileDBError("internal error: invalid Ctx object") - return PyCapsule_GetPointer(ctx.__capsule__(), "ctx") - -def version(): - """Return the version of the linked ``libtiledb`` shared library - - :rtype: tuple - :return: Semver version (major, minor, rev) - - """ - cdef: - int major = 0 - int minor = 0 - int rev = 0 - tiledb_version(&major, &minor, &rev) - return major, minor, rev - -cdef _raise_tiledb_error(tiledb_error_t* err_ptr): - cdef const char* err_msg_ptr = NULL - ret = tiledb_error_message(err_ptr, &err_msg_ptr) - if ret != TILEDB_OK: - tiledb_error_free(&err_ptr) - if ret == TILEDB_OOM: - raise MemoryError() - raise TileDBError("error retrieving error message") - cdef unicode message_string - try: - message_string = err_msg_ptr.decode('UTF-8', 'strict') - finally: - tiledb_error_free(&err_ptr) - raise TileDBError(message_string) - - -cdef _raise_ctx_err(tiledb_ctx_t* ctx_ptr, int rc): - if rc == TILEDB_OK: - return - if rc == TILEDB_OOM: - raise MemoryError() - cdef tiledb_error_t* err_ptr = NULL - cdef int ret = tiledb_ctx_get_last_error(ctx_ptr, &err_ptr) - if ret != TILEDB_OK: - tiledb_error_free(&err_ptr) - if ret == TILEDB_OOM: - raise MemoryError() - raise TileDBError("error retrieving error object from ctx") - _raise_tiledb_error(err_ptr) diff --git a/tiledb/cc/CMakeLists.txt b/tiledb/libtiledb/CMakeLists.txt similarity index 70% rename from tiledb/cc/CMakeLists.txt rename to tiledb/libtiledb/CMakeLists.txt index 4b5fdba4d7..8fd2072bc2 100644 --- a/tiledb/cc/CMakeLists.txt +++ b/tiledb/libtiledb/CMakeLists.txt @@ -1,5 +1,5 @@ pybind11_add_module( - cc + libtiledb array.cc attribute.cc common.cc @@ -24,20 +24,20 @@ pybind11_add_module( ) target_link_libraries( - cc + libtiledb PUBLIC TileDB::tiledb_shared ) target_compile_features( - cc + libtiledb PUBLIC cxx_std_20 ) if (TILEDB_REMOVE_DEPRECATIONS) target_compile_definitions( - cc + libtiledb PRIVATE TILEDB_REMOVE_DEPRECATIONS ) @@ -45,24 +45,24 @@ endif() if (TILEDB_SERIALIZATION) target_compile_definitions( - cc + libtiledb PRIVATE TILEDB_SERIALIZATION ) endif() -install(TARGETS cc DESTINATION tiledb) +install(TARGETS libtiledb DESTINATION tiledb) if(TILEDB_DOWNLOADED) if (APPLE) - set_target_properties(cc PROPERTIES INSTALL_RPATH "@loader_path") + set_target_properties(libtiledb PROPERTIES INSTALL_RPATH "@loader_path") elseif(UNIX) - set_target_properties(cc PROPERTIES INSTALL_RPATH "\$ORIGIN") + set_target_properties(libtiledb PROPERTIES INSTALL_RPATH "\$ORIGIN") endif() else() # If using external TileDB core library force it to be linked at runtime using RPATH get_property(TILEDB_LOCATION TARGET TileDB::tiledb_shared PROPERTY LOCATION) get_filename_component(TILEDB_LOCATION ${TILEDB_LOCATION} DIRECTORY) - message(STATUS "Setting RPATH for target \"cc\" to ${TILEDB_LOCATION}") - set_target_properties(cc PROPERTIES INSTALL_RPATH ${TILEDB_LOCATION}) + message(STATUS "Setting RPATH for target \"libtiledb\" to ${TILEDB_LOCATION}") + set_target_properties(libtiledb PROPERTIES INSTALL_RPATH ${TILEDB_LOCATION}) endif() diff --git a/tiledb/cc/array.cc b/tiledb/libtiledb/array.cc similarity index 99% rename from tiledb/cc/array.cc rename to tiledb/libtiledb/array.cc index f3e3512512..392d1950b1 100644 --- a/tiledb/cc/array.cc +++ b/tiledb/libtiledb/array.cc @@ -50,7 +50,6 @@ void init_array(py::module &m) { end.value())); }), py::keep_alive<1, 2>()) - // Temporary initializer while Array is converted from Cython to PyBind. .def(py::init([](const Context &ctx, py::object array) { tiledb_array_t *c_array = (py::capsule)array.attr("__capsule__")(); return std::make_unique(ctx, c_array, false); diff --git a/tiledb/cc/attribute.cc b/tiledb/libtiledb/attribute.cc similarity index 100% rename from tiledb/cc/attribute.cc rename to tiledb/libtiledb/attribute.cc diff --git a/tiledb/cc/common.cc b/tiledb/libtiledb/common.cc similarity index 100% rename from tiledb/cc/common.cc rename to tiledb/libtiledb/common.cc diff --git a/tiledb/cc/common.h b/tiledb/libtiledb/common.h similarity index 100% rename from tiledb/cc/common.h rename to tiledb/libtiledb/common.h diff --git a/tiledb/cc/consolidation_plan.cc b/tiledb/libtiledb/consolidation_plan.cc similarity index 100% rename from tiledb/cc/consolidation_plan.cc rename to tiledb/libtiledb/consolidation_plan.cc diff --git a/tiledb/cc/context.cc b/tiledb/libtiledb/context.cc similarity index 100% rename from tiledb/cc/context.cc rename to tiledb/libtiledb/context.cc diff --git a/tiledb/cc/current_domain.cc b/tiledb/libtiledb/current_domain.cc similarity index 100% rename from tiledb/cc/current_domain.cc rename to tiledb/libtiledb/current_domain.cc diff --git a/tiledb/cc/dimension_label.cc b/tiledb/libtiledb/dimension_label.cc similarity index 100% rename from tiledb/cc/dimension_label.cc rename to tiledb/libtiledb/dimension_label.cc diff --git a/tiledb/cc/domain.cc b/tiledb/libtiledb/domain.cc similarity index 100% rename from tiledb/cc/domain.cc rename to tiledb/libtiledb/domain.cc diff --git a/tiledb/cc/enum.cc b/tiledb/libtiledb/enum.cc similarity index 100% rename from tiledb/cc/enum.cc rename to tiledb/libtiledb/enum.cc diff --git a/tiledb/cc/enumeration.cc b/tiledb/libtiledb/enumeration.cc similarity index 100% rename from tiledb/cc/enumeration.cc rename to tiledb/libtiledb/enumeration.cc diff --git a/tiledb/cc/filestore.cc b/tiledb/libtiledb/filestore.cc similarity index 98% rename from tiledb/cc/filestore.cc rename to tiledb/libtiledb/filestore.cc index 72fd5bee61..c4c3768ea3 100644 --- a/tiledb/cc/filestore.cc +++ b/tiledb/libtiledb/filestore.cc @@ -18,7 +18,7 @@ class Filestore { public: // TODO this works, but isn't actually in use at the moment. // we are still using tiledb.libtiledb.ArraySchema. when we switch to using - // tiledb.cc.ArraySchema, use this function instead. + // tiledb.libtiledb.ArraySchema, use this function instead. static ArraySchema schema_create(const Context &ctx, const char *uri) { tiledb_array_schema_t *schema; tiledb_filestore_schema_create(ctx.ptr().get(), uri, &schema); diff --git a/tiledb/cc/filter.cc b/tiledb/libtiledb/filter.cc similarity index 100% rename from tiledb/cc/filter.cc rename to tiledb/libtiledb/filter.cc diff --git a/tiledb/cc/group.cc b/tiledb/libtiledb/group.cc similarity index 100% rename from tiledb/cc/group.cc rename to tiledb/libtiledb/group.cc diff --git a/tiledb/cc/metadata.h b/tiledb/libtiledb/metadata.h similarity index 100% rename from tiledb/cc/metadata.h rename to tiledb/libtiledb/metadata.h diff --git a/tiledb/cc/object.cc b/tiledb/libtiledb/object.cc similarity index 100% rename from tiledb/cc/object.cc rename to tiledb/libtiledb/object.cc diff --git a/tiledb/cc/query.cc b/tiledb/libtiledb/query.cc similarity index 100% rename from tiledb/cc/query.cc rename to tiledb/libtiledb/query.cc diff --git a/tiledb/cc/schema.cc b/tiledb/libtiledb/schema.cc similarity index 100% rename from tiledb/cc/schema.cc rename to tiledb/libtiledb/schema.cc diff --git a/tiledb/cc/subarray.cc b/tiledb/libtiledb/subarray.cc similarity index 100% rename from tiledb/cc/subarray.cc rename to tiledb/libtiledb/subarray.cc diff --git a/tiledb/cc/tiledbcpp.cc b/tiledb/libtiledb/tiledbcpp.cc similarity index 91% rename from tiledb/cc/tiledbcpp.cc rename to tiledb/libtiledb/tiledbcpp.cc index cce6e433f6..e97a428a4c 100644 --- a/tiledb/cc/tiledbcpp.cc +++ b/tiledb/libtiledb/tiledbcpp.cc @@ -34,7 +34,7 @@ void init_schema(py::module &); void init_subarray(py::module &); void init_vfs(py::module &m); -PYBIND11_MODULE(cc, m) { +PYBIND11_MODULE(libtiledb, m) { init_array(m); init_attribute(m); @@ -56,6 +56,14 @@ PYBIND11_MODULE(cc, m) { init_subarray(m); init_vfs(m); + m.def("version", []() { + int major = 0; + int minor = 0; + int rev = 0; + tiledb_version(&major, &minor, &rev); + return std::make_tuple(major, minor, rev); + }); + py::register_exception(m, "TileDBError"); /* diff --git a/tiledb/cc/vfs.cc b/tiledb/libtiledb/vfs.cc similarity index 100% rename from tiledb/cc/vfs.cc rename to tiledb/libtiledb/vfs.cc diff --git a/tiledb/metadata.py b/tiledb/metadata.py index 469560b0d9..30dc96641d 100644 --- a/tiledb/metadata.py +++ b/tiledb/metadata.py @@ -3,7 +3,7 @@ import numpy as np import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Config, Ctx, default_ctx from .datatypes import DataType diff --git a/tiledb/multirange_indexing.py b/tiledb/multirange_indexing.py index 4400d55d0a..2db599c6d5 100644 --- a/tiledb/multirange_indexing.py +++ b/tiledb/multirange_indexing.py @@ -27,8 +27,8 @@ from .aggregation import Aggregation as AggregationProxy from .array import Array from .array_schema import ArraySchema -from .cc import TileDBError from .dataframe_ import check_dataframe_deps +from .libtiledb import TileDBError from .main import PyAgg, PyQuery, increment_stat, use_stats from .metadata import Metadata from .query import Query diff --git a/tiledb/ndrectangle.py b/tiledb/ndrectangle.py index e071e403bf..8bc87187e2 100644 --- a/tiledb/ndrectangle.py +++ b/tiledb/ndrectangle.py @@ -1,6 +1,6 @@ from typing import Tuple, Union -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Ctx, CtxMixin from .domain import Domain diff --git a/tiledb/numpyFlags.h b/tiledb/numpyFlags.h deleted file mode 100644 index be21064176..0000000000 --- a/tiledb/numpyFlags.h +++ /dev/null @@ -1,2 +0,0 @@ -// Turn off cython generated deprecation warnings -#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION \ No newline at end of file diff --git a/tiledb/object.py b/tiledb/object.py index 2c8c300e4f..602c27066a 100644 --- a/tiledb/object.py +++ b/tiledb/object.py @@ -1,7 +1,7 @@ from typing import Optional import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt class Object(lt.Object): diff --git a/tiledb/query.py b/tiledb/query.py index a44d0a0c40..9775b62f91 100644 --- a/tiledb/query.py +++ b/tiledb/query.py @@ -2,8 +2,7 @@ from json import loads as json_loads from typing import Optional, Sequence, Union -import tiledb.cc as lt -from tiledb import TileDBError +import tiledb.libtiledb as lt from .array import Array from .ctx import Ctx, CtxMixin, default_ctx @@ -63,7 +62,7 @@ def __init__( raise ValueError("Cannot pass both dims and has_coords=True to Query") if return_incomplete and not array.schema.sparse: - raise TileDBError( + raise lt.TileDBError( "Incomplete queries are only supported for sparse arrays at this time" ) @@ -82,7 +81,9 @@ def __init__( domain = array.schema.domain for dname in dims: if not domain.has_dim(dname): - raise TileDBError(f"Selected dimension does not exist: '{dname}'") + raise lt.TileDBError( + f"Selected dimension does not exist: '{dname}'" + ) self._dims = dims else: self._dims = None @@ -90,7 +91,7 @@ def __init__( if attrs is not None: for name in attrs: if not array.schema.has_attr(name): - raise TileDBError(f"Selected attribute does not exist: '{name}'") + raise lt.TileDBError(f"Selected attribute does not exist: '{name}'") self._attrs = attrs self._cond = cond @@ -109,7 +110,9 @@ def __init__( if use_arrow is None: use_arrow = True if not use_arrow: - raise TileDBError("Cannot initialize return_arrow with use_arrow=False") + raise lt.TileDBError( + "Cannot initialize return_arrow with use_arrow=False" + ) self._use_arrow = use_arrow self._return_incomplete = return_incomplete @@ -124,7 +127,7 @@ def subarray(self) -> Subarray: def __getitem__(self, selection): if self._return_arrow: - raise TileDBError("`return_arrow=True` requires .df indexer`") + raise lt.TileDBError("`return_arrow=True` requires .df indexer`") return self._array.subarray( selection, diff --git a/tiledb/query_condition.py b/tiledb/query_condition.py index 9acf9660e0..0902906ca2 100644 --- a/tiledb/query_condition.py +++ b/tiledb/query_condition.py @@ -7,8 +7,8 @@ import tiledb.main as qc from .array import Array -from .cc import TileDBError from .ctx import Ctx, default_ctx +from .libtiledb import TileDBError """ A high level wrapper around the Pybind11 query_condition.cc implementation for diff --git a/tiledb/sparse_array.py b/tiledb/sparse_array.py index 978f6affa1..255dc2e72f 100644 --- a/tiledb/sparse_array.py +++ b/tiledb/sparse_array.py @@ -3,7 +3,7 @@ import numpy as np import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt from .array import ( Array, diff --git a/tiledb/subarray.py b/tiledb/subarray.py index 1bde836022..d211ccc421 100644 --- a/tiledb/subarray.py +++ b/tiledb/subarray.py @@ -3,7 +3,7 @@ import numpy as np -import tiledb.cc as lt +import tiledb.libtiledb as lt from .array import Array from .ctx import Ctx, CtxMixin, default_ctx diff --git a/tiledb/tests/cc/test_cc.py b/tiledb/tests/cc/test_cc.py index d18f170fe9..9c5c58b6f2 100644 --- a/tiledb/tests/cc/test_cc.py +++ b/tiledb/tests/cc/test_cc.py @@ -5,7 +5,7 @@ import pytest import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt from tiledb.datatypes import DataType from tiledb.main import PyFragmentInfo @@ -264,7 +264,7 @@ def test_schema(): with pytest.raises(lt.TileDBError): schema._tile_order = lt.LayoutType.HILBERT - if tiledb.libtiledb.version() >= (2, 24, 0): + if lt.version() >= (2, 24, 0): with pytest.raises(lt.TileDBError): schema._tile_order = lt.LayoutType.UNORDERED schema._tile_order = lt.LayoutType.ROW_MAJOR diff --git a/tiledb/tests/cc/test_filestore.py b/tiledb/tests/cc/test_filestore.py index 8bf691a4b6..b0df37b5eb 100644 --- a/tiledb/tests/cc/test_filestore.py +++ b/tiledb/tests/cc/test_filestore.py @@ -3,7 +3,7 @@ import pytest import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt @pytest.fixture diff --git a/tiledb/tests/cc/test_group.py b/tiledb/tests/cc/test_group.py index b9513990db..b0f8016e77 100644 --- a/tiledb/tests/cc/test_group.py +++ b/tiledb/tests/cc/test_group.py @@ -4,7 +4,7 @@ import numpy as np from numpy.testing import assert_array_equal -import tiledb.cc as lt +import tiledb.libtiledb as lt def test_group_metadata(tmp_path): diff --git a/tiledb/tests/cc/test_vfs.py b/tiledb/tests/cc/test_vfs.py index 3bfb767583..b45adf47f3 100644 --- a/tiledb/tests/cc/test_vfs.py +++ b/tiledb/tests/cc/test_vfs.py @@ -1,6 +1,6 @@ import os -import tiledb.cc as lt +import tiledb.libtiledb as lt def test_dir(tmp_path): diff --git a/tiledb/tests/test_context_and_config.py b/tiledb/tests/test_context_and_config.py index 13ce7b72fa..157516c5c3 100644 --- a/tiledb/tests/test_context_and_config.py +++ b/tiledb/tests/test_context_and_config.py @@ -37,7 +37,7 @@ class ContextTest(DiskTestCase): def test_default_ctx(self): ctx = tiledb.default_ctx() self.assertIsInstance(ctx, tiledb.Ctx) - assert isinstance(ctx.config(), tiledb.libtiledb.Config) + assert isinstance(ctx.config(), tiledb.Config) def test_default_ctx_errors(self): config = tiledb.Config() @@ -186,7 +186,7 @@ def test_ctx_config_from_file(self): def test_ctx_config_dict(self): ctx = tiledb.Ctx(config={"sm.memory_budget": "100"}) config = ctx.config() - assert issubclass(type(config), tiledb.libtiledb.Config) + assert issubclass(type(config), tiledb.Config) self.assertEqual(config["sm.memory_budget"], "100") def test_config_repr_sensitive_params_hidden(self): diff --git a/tiledb/tests/test_current_domain.py b/tiledb/tests/test_current_domain.py index 402d407b0e..55dff8a56b 100644 --- a/tiledb/tests/test_current_domain.py +++ b/tiledb/tests/test_current_domain.py @@ -5,9 +5,9 @@ import pytest import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt -if not (tiledb.libtiledb.version()[0] == 2 and tiledb.libtiledb.version()[1] >= 26): +if not (lt.version()[0] == 2 and lt.version()[1] >= 25): pytest.skip( "CurrentDomain is only available in TileDB 2.26 and later", allow_module_level=True, diff --git a/tiledb/tests/test_enumeration.py b/tiledb/tests/test_enumeration.py index f6af612b2c..00ed043fd0 100644 --- a/tiledb/tests/test_enumeration.py +++ b/tiledb/tests/test_enumeration.py @@ -28,7 +28,7 @@ def test_enumeration_basic(self, name, ordered, data): assert enmr.ordered == ordered assert_array_equal(enmr.values(), data) if name in ("str", "utf8", "ascii"): - assert enmr.cell_val_num == tiledb.cc.TILEDB_VAR_NUM() + assert enmr.cell_val_num == tiledb.libtiledb.TILEDB_VAR_NUM() assert enmr.dtype.kind == data.dtype.kind else: assert enmr.cell_val_num == 1 diff --git a/tiledb/tests/test_examples.py b/tiledb/tests/test_examples.py index 6dcd20a612..4941347385 100644 --- a/tiledb/tests/test_examples.py +++ b/tiledb/tests/test_examples.py @@ -57,14 +57,8 @@ def test_examples(self, path): sys.platform == "win32", reason="Some doctests are missing a clean-up step on windows", ) - @pytest.mark.parametrize( - "path", - [ - os.path.join(PROJECT_DIR, "tiledb", "libtiledb.pyx"), - os.path.join(PROJECT_DIR, "tiledb", "fragment.py"), - ], - ) - def test_docs(self, path, capsys): + def test_docs(self, capsys): + path = os.path.join(self.PROJECT_DIR, "tiledb", "fragment.py") failures, _ = doctest.testfile( path, module_relative=False, diff --git a/tiledb/tests/test_filters.py b/tiledb/tests/test_filters.py index fedf706918..224ac93dce 100644 --- a/tiledb/tests/test_filters.py +++ b/tiledb/tests/test_filters.py @@ -188,7 +188,7 @@ def test_float_scaling_filter(self, factor, offset, bytewidth): [ (np.uint64, None, None), (np.float64, np.uint64, np.uint64), - (np.float64, tiledb.cc.DataType.UINT64, np.uint64), + (np.float64, tiledb.libtiledb.DataType.UINT64, np.uint64), ], ) def test_delta_filter(self, attr_dtype, reinterp_dtype, expected_reinterp_dtype): @@ -225,7 +225,7 @@ def test_delta_filter(self, attr_dtype, reinterp_dtype, expected_reinterp_dtype) [ (np.uint64, None, None), (np.float64, np.uint64, np.uint64), - (np.float64, tiledb.cc.DataType.UINT64, np.uint64), + (np.float64, tiledb.libtiledb.DataType.UINT64, np.uint64), ], ) def test_double_delta_filter( diff --git a/tiledb/tests/test_fixes.py b/tiledb/tests/test_fixes.py index a4ab4f65f0..e766669c39 100644 --- a/tiledb/tests/test_fixes.py +++ b/tiledb/tests/test_fixes.py @@ -350,7 +350,7 @@ def test_sc56611(self): # test from_numpy with sparse argument set to True uri = self.path("test_sc56611") data = np.random.rand(10, 10) - with pytest.raises(tiledb.cc.TileDBError) as exc_info: + with pytest.raises(tiledb.libtiledb.TileDBError) as exc_info: tiledb.from_numpy(uri, data, sparse=True) assert str(exc_info.value) == "from_numpy only supports dense arrays" diff --git a/tiledb/vfs.py b/tiledb/vfs.py index f63bf9de6f..7614a1d85f 100644 --- a/tiledb/vfs.py +++ b/tiledb/vfs.py @@ -6,7 +6,7 @@ import numpy as np import tiledb -import tiledb.cc as lt +import tiledb.libtiledb as lt from .ctx import Config, Ctx, default_ctx