Skip to content

Enable python 3.12 #1959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-12, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
fail-fast: false
env:
# 11.7 necessary due to: https://github.com/actions/setup-python/issues/682#issuecomment-1604261330
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/daily-test-build-numpy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-12, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
# https://github.com/scipy/oldest-supported-numpy/blob/main/setup.cfg
- python-version: "3.12"
numpy-version: "1.26.4"
- python-version: "3.11"
numpy-version: "1.23.2"
- python-version: "3.10"
Expand Down
3 changes: 1 addition & 2 deletions misc/azure-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ stages:
condition: always()
variables:
cibw_test_requires: "pytest"
USE_CIBW_VERSION: 2.12.3
USE_CIBW_VERSION: 2.17.0
strategy:
matrix:
linux_py:
Expand All @@ -79,7 +79,6 @@ stages:
TILEDB_INSTALL: "$(Pipeline.Workspace)/.libtiledb_dist/$(LIBTILEDB_SHA)-macos-x86_64"
CIBW_ARCHS_MACOS: "x86_64"
CIBW_SKIP: "cp36-* cp37-* pp*"
CIBW_TEST_SKIP: "cp37-*"
CIBW_BUILD_VERBOSITY: 3
macOS_arm64_py:
imageName: "macOS-12"
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ classifiers=[
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version", "dependencies"]

Expand Down
77 changes: 40 additions & 37 deletions tiledb/libtiledb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1514,21 +1514,21 @@ cdef class Array(object):
... A[:] = {"a1": a1_data, "l1": l1_data, "l2": l2_data, "l3": l3_data}
...
... with tiledb.open(tmp, "r") as A:
... A.label_index(["l1"])[3:4]
... A.label_index(["l1", "l3"])[2, 0.5:1.0]
... A.label_index(["l2"])[:, -1:0]
... A.label_index(["l3"])[:, 0.5:1.0]
OrderedDict([('l1', array([4, 3])), ('a1', array([[1, 2, 3],
[4, 5, 6]]))])
OrderedDict([('l3', array([0.5, 1. ])), ('l1', array([2])), ('a1', array([[8, 9]]))])
OrderedDict([('l2', array([-1, 0])), ('a1', array([[ 1, 2],
[ 4, 5],
[ 7, 8],
[10, 11]]))])
OrderedDict([('l3', array([0.5, 1. ])), ('a1', array([[ 2, 3],
[ 5, 6],
[ 8, 9],
[11, 12]]))])
... A.label_index(["l1"])[3:4] # doctest: +ELLIPSIS
... A.label_index(["l1", "l3"])[2, 0.5:1.0] # doctest: +ELLIPSIS
... A.label_index(["l2"])[:, -1:0] # doctest: +ELLIPSIS
... A.label_index(["l3"])[:, 0.5:1.0] # doctest: +ELLIPSIS
OrderedDict(...'l1'... array([4, 3])..., ...'a1'... array([[1, 2, 3],
[4, 5, 6]])...)
OrderedDict(...'l3'... array([0.5, 1. ])..., ...'l1'... array([2])..., ...'a1'... array([[8, 9]])...)
OrderedDict(...'l2'... array([-1, 0])..., ...'a1'... array([[ 1, 2],
[ 4, 5],
[ 7, 8],
[10, 11]])...)
OrderedDict(...'l3'... array([0.5, 1. ])..., ...'a1'... array([[ 2, 3],
[ 5, 6],
[ 8, 9],
[11, 12]])...)

:param labels: List of labels to use when querying. Can only use at most one
label per dimension.
Expand Down Expand Up @@ -1572,19 +1572,23 @@ cdef class Array(object):
>>>
>>> with tempfile.TemporaryDirectory() as tmp:
... A = tiledb.from_numpy(tmp, np.eye(4) * [1,2,3,4])
... A.multi_index[1]
... A.multi_index[1,1]
... A.multi_index[1] # doctest: +ELLIPSIS
... A.multi_index[1,1] # doctest: +ELLIPSIS
... # return row 0 and 2
... A.multi_index[[0,2]]
... A.multi_index[[0,2]] # doctest: +ELLIPSIS
... # return rows 0 and 2 intersecting column 2
... A.multi_index[[0,2], 2]
... A.multi_index[[0,2], 2] # doctest: +ELLIPSIS
... # return rows 0:2 intersecting columns 0:2
... A.multi_index[slice(0,2), slice(0,2)]
OrderedDict([('', array([[0., 2., 0., 0.]]))])
OrderedDict([('', array([[2.]]))])
OrderedDict([('', array([[1., 0., 0., 0.], [0., 0., 3., 0.]]))])
OrderedDict([('', array([[0.], [3.]]))])
OrderedDict([('', array([[1., 0., 0.], [0., 2., 0.], [0., 0., 3.]]))])
... A.multi_index[slice(0,2), slice(0,2)] # doctest: +ELLIPSIS
OrderedDict(...''... array([[0., 2., 0., 0.]])...)
OrderedDict(...''... array([[2.]])...)
OrderedDict(...''... array([[1., 0., 0., 0.],
[0., 0., 3., 0.]])...)
OrderedDict(...''... array([[0.],
[3.]])...)
OrderedDict(...''... array([[1., 0., 0.],
[0., 2., 0.],
[0., 0., 3.]])...)

"""
# Delayed to avoid circular import
Expand Down Expand Up @@ -2161,8 +2165,8 @@ cdef class DenseArrayImpl(Array):
... A[0:10] = {"a1": np.zeros((10)), "a2": np.ones((10))}
... with tiledb.DenseArray(tmp + "/array", mode='r') as A:
... # Access specific attributes individually.
... A.query(attrs=("a1",))[0:5]
OrderedDict([('a1', array([0, 0, 0, 0, 0]))])
... A.query(attrs=("a1",))[0:5] # doctest: +ELLIPSIS
OrderedDict(...'a1'... array([0, 0, 0, 0, 0])...)

"""
if not self.isopen or self.mode != 'r':
Expand Down Expand Up @@ -2216,8 +2220,8 @@ cdef class DenseArrayImpl(Array):
... A[0:10] = {"a1": np.zeros((10)), "a2": np.ones((10))}
... with tiledb.DenseArray(tmp + "/array", mode='r') as A:
... # A[0:5], attribute a1, row-major without coordinates
... A.subarray((slice(0, 5),), attrs=("a1",), coords=False, order='C')
OrderedDict([('a1', array([0, 0, 0, 0, 0]))])
... A.subarray((slice(0, 5),), attrs=("a1",), coords=False, order='C') # doctest: +ELLIPSIS
OrderedDict(...'a1'... array([0, 0, 0, 0, 0])...)

"""
from .subarray import Subarray
Expand Down Expand Up @@ -3154,11 +3158,10 @@ cdef class SparseArrayImpl(Array):
... "a2": np.array([3, 4])}
... with tiledb.SparseArray(tmp + "/array", mode='r') as A:
... # Return an OrderedDict with values and coordinates
... A[0:3, 0:10]
... A[0:3, 0:10] # doctest: +ELLIPSIS
... # Return just the "x" coordinates values
... A[0:3, 0:10]["x"]
OrderedDict([('a1', array([1, 2])), ('a2', array([3, 4])), ('y', array([0, 2], dtype=uint64)), ('x', array([0, 3], dtype=uint64))])
array([0, 3], dtype=uint64)
... A[0:3, 0:10]["x"] # doctest: +ELLIPSIS
OrderedDict(...'a1'... array([1, 2])..., ...'a2'... array([3, 4])..., ...'y'... array([0, 2], dtype=uint64)..., ...'x'... array([0, 3], dtype=uint64)...)

With a floating-point array domain, index bounds are inclusive, e.g.:

Expand Down Expand Up @@ -3231,8 +3234,8 @@ cdef class SparseArrayImpl(Array):
... A[I, J] = {"a1": np.array([1, 2]),
... "a2": np.array([3, 4])}
... with tiledb.SparseArray(tmp + "/array", mode='r') as A:
... A.query(attrs=("a1",), coords=False, order='G')[0:3, 0:10]
OrderedDict([('a1', array([1, 2]))])
... A.query(attrs=("a1",), coords=False, order='G')[0:3, 0:10] # doctest: +ELLIPSIS
OrderedDict(...'a1'... array([1, 2])...)

"""
if not self.isopen or self.mode not in ('r', 'd'):
Expand Down Expand Up @@ -3341,8 +3344,8 @@ cdef class SparseArrayImpl(Array):
... "a2": np.array([3, 4])}
... with tiledb.SparseArray(tmp + "/array", mode='r') as A:
... # A[0:3, 0:10], attribute a1, row-major without coordinates
... A.subarray((slice(0, 3), slice(0, 10)), attrs=("a1",), coords=False, order='G')
OrderedDict([('a1', array([1, 2]))])
... A.subarray((slice(0, 3), slice(0, 10)), attrs=("a1",), coords=False, order='G') # doctest: +ELLIPSIS
OrderedDict(...'a1'... array([1, 2])...)

"""
from .subarray import Subarray
Expand Down
30 changes: 16 additions & 14 deletions tiledb/query_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
filtering query results on attribute and dimension values.
"""

QueryConditionNodeElem = Union[
ast.Name, ast.Constant, ast.Call, ast.Num, ast.Str, ast.Bytes
]
QueryConditionNodeElem = Union[ast.Name, ast.Constant, ast.Call]


@dataclass
Expand Down Expand Up @@ -280,8 +278,8 @@ def is_variable_node(self, variable: QueryConditionNodeElem) -> bool:

return (
isinstance(variable.args[0], ast.Constant)
or isinstance(variable.args[0], ast.Str)
or isinstance(variable.args[0], ast.Bytes)
or isinstance(variable.args[0], ast.Constant)
or isinstance(variable.args[0], ast.Constant)
Comment on lines +281 to +282
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these redundant?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh wow

)

return isinstance(variable, ast.Name)
Expand Down Expand Up @@ -326,7 +324,9 @@ def get_variable_from_node(self, node: QueryConditionNodeElem) -> Any:
variable = variable_node.id
elif isinstance(variable_node, ast.Constant):
variable = variable_node.value
elif isinstance(variable_node, ast.Str) or isinstance(variable_node, ast.Bytes):
elif isinstance(variable_node, ast.Constant) or isinstance(
variable_node, ast.Constant
):
# deprecated in 3.8
variable = variable_node.s
else:
Expand Down Expand Up @@ -363,13 +363,15 @@ def get_value_from_node(self, node: QueryConditionNodeElem) -> Any:

if isinstance(value_node, ast.Constant):
value = value_node.value
elif isinstance(value_node, ast.NameConstant):
elif isinstance(value_node, ast.Constant):
# deprecated in 3.8
value = value_node.value
elif isinstance(value_node, ast.Num):
elif isinstance(value_node, ast.Constant):
# deprecated in 3.8
value = value_node.n
elif isinstance(value_node, ast.Str) or isinstance(value_node, ast.Bytes):
elif isinstance(value_node, ast.Constant) or isinstance(
value_node, ast.Constant
):
# deprecated in 3.8
value = value_node.s
else:
Expand Down Expand Up @@ -491,7 +493,7 @@ def visit_UnaryOp(self, node: ast.UnaryOp, sign: int = 1):
else:
if isinstance(node.operand, ast.Constant):
node.operand.value *= sign
elif isinstance(node.operand, ast.Num):
elif isinstance(node.operand, ast.Constant):
node.operand.n *= sign
else:
raise TileDBError(
Expand All @@ -500,18 +502,18 @@ def visit_UnaryOp(self, node: ast.UnaryOp, sign: int = 1):

return node.operand

def visit_Num(self, node: ast.Num) -> ast.Num:
def visit_Num(self, node: ast.Constant) -> ast.Constant:
# deprecated in 3.8
return node

def visit_Str(self, node: ast.Str) -> ast.Str:
def visit_Str(self, node: ast.Constant) -> ast.Constant:
# deprecated in 3.8
return node

def visit_Bytes(self, node: ast.Bytes) -> ast.Bytes:
def visit_Bytes(self, node: ast.Constant) -> ast.Constant:
# deprecated in 3.8
return node

def visit_NameConstant(self, node: ast.NameConstant) -> ast.NameConstant:
def visit_NameConstant(self, node: ast.Constant) -> ast.Constant:
# deprecated in 3.8
return node
23 changes: 19 additions & 4 deletions tiledb/tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def test_compat_tiledb_py_0_5_anon_attr_dense(self):

path = self.path("tiledb_py_0_6_anon_attr")
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(array_tgz))) as tf:
tf.extractall(path)
try:
tf.extractall(path, filter="fully_trusted")
except TypeError:
tf.extractall(path)

with tiledb.open(path) as A:
self.assertEqual(A.schema.attr(0).name, "")
Expand Down Expand Up @@ -85,7 +88,11 @@ def test_compat_py_0_5_anon_attr_sparse(self):

path = self.path("test_tiledb_py_0_5_anon_attr_sparse")
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(test_array))) as tf:
tf.extractall(path)
try:
tf.extractall(path, filter="fully_trusted")
except TypeError:
tf.extractall(path)

with tiledb.open(path) as A:
assert_array_equal(A[:][""], np.array([1.0, 2.0, 5.0]))

Expand All @@ -108,7 +115,11 @@ def test_tiledb_py_0_6_anon_attr(self):

path = self.path("0_6_anon_sparse")
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(tgz_sparse))) as tf:
tf.extractall(path)
try:
tf.extractall(path, filter="fully_trusted")
except TypeError:
tf.extractall(path)

with tiledb.open(path) as A:
if A.schema.sparse:
assert_array_equal(A[:][""], np.array([1.0, 2.0, 5.0]))
Expand Down Expand Up @@ -158,7 +169,11 @@ def test_tiledb_py_0_6_anon_attr(self):

path = self.path("0_6_anon_dense")
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(tgz_dense))) as tf:
tf.extractall(path)
try:
tf.extractall(path, filter="fully_trusted")
except TypeError:
tf.extractall(path)

with tiledb.open(path) as A:
self.assertEqual(A.schema.attr(0).name, "")
self.assertEqual(A.schema.attr(0)._internal_name, "__attr")
Expand Down
6 changes: 4 additions & 2 deletions tiledb/tests/test_fork_ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_no_warning_fork_without_ctx():
@pytest.mark.skipif(
sys.platform == "win32", reason="fork() is not available on Windows"
)
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_warning_fork_with_ctx():
"""Get a warning if we fork after creating a tiledb context."""
_ = tiledb.Ctx()
Expand All @@ -50,6 +51,7 @@ def test_warning_fork_with_ctx():
@pytest.mark.skipif(
sys.platform == "win32", reason="fork() is not available on Windows"
)
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_warning_fork_with_default_ctx():
"""Get a warning if we fork after creating a default context."""
_ = tiledb.default_ctx()
Expand All @@ -60,8 +62,6 @@ def test_warning_fork_with_default_ctx():
else:
os.wait()

pass


@pytest.mark.skipif(
sys.platform == "win32", reason="fork() is not available on Windows"
Expand All @@ -79,6 +79,7 @@ def test_no_warning_multiprocessing_without_ctx():
@pytest.mark.skipif(
sys.platform == "win32", reason="fork() is not available on Windows"
)
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_warning_multiprocessing_with_ctx():
"""Get a warning if we fork after creating a tiledb context."""
_ = tiledb.Ctx()
Expand All @@ -92,6 +93,7 @@ def test_warning_multiprocessing_with_ctx():
@pytest.mark.skipif(
sys.platform == "win32", reason="fork() is not available on Windows"
)
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_warning_multiprocessing_with_default_ctx():
"""Get a warning if we fork after creating a default context."""
_ = tiledb.default_ctx()
Expand Down
5 changes: 4 additions & 1 deletion tiledb/tests/test_libtiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ def test_upgrade_version(self):
path = self.path("test_upgrade_version")

with tarfile.open(fileobj=io.BytesIO(base64.b64decode(tgz_sparse))) as tf:
tf.extractall(path)
try:
tf.extractall(path, filter="fully_trusted")
except TypeError:
tf.extractall(path)

with tiledb.open(path) as A:
assert A.schema.version == 5
Expand Down
Loading