Skip to content

Commit

Permalink
Modify check for ctx between versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsitsi committed Feb 19, 2025
1 parent 9c8cdcf commit d88cb02
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
matrix:
python-version: ["3.9"]
ml-deps:
- "torch==2.1.0+cpu torchvision==0.16.0+cpu torchdata==0.7.0 tensorflow-cpu==2.15.0 'numpy>=1.25'"
- "torch==2.2.0+cpu torchvision==0.17.0+cpu torchdata==0.8.0 tensorflow-cpu==2.15.0 'numpy>=1.25'"
- "torch==2.3.1+cpu torchvision==0.18.1+cpu torchdata==0.8.0 'tensorflow-cpu<2.16.0' 'numpy<2'"
- "torch==2.1.0+cpu torchvision==0.16.0+cpu torchdata==0.7.0 tensorflow-cpu==2.15.0 "
- "torch==2.2.0+cpu torchvision==0.17.0+cpu torchdata==0.8.0 tensorflow-cpu==2.15.0 "
- "torch==2.3.1+cpu torchvision==0.18.1+cpu torchdata==0.8.0 'tensorflow-cpu<2.16.0'"
env:
run_coverage: ${{ github.ref == 'refs/heads/master' }}

Expand Down
11 changes: 10 additions & 1 deletion tiledb/ml/readers/_tensor_schema/base_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ def key_range(self) -> WeightedRange[Any, int]:
def max_partition_weight(self) -> int:
try:
# getattr for compatibility with TileDB-Py <0.33
ctx = getattr(self._array, "ctx", self._array._ctx_())
if hasattr(self._array, "ctx"): # Check if 'ctx' exists (TileDB-Py >= 0.33)
ctx = self._array.ctx
elif hasattr(
self._array, "_ctx_"
): # Check if '_ctx_' exists (TileDB-Py < 0.33)
ctx = self._array._ctx_() # Note the parentheses - it was a method
else:
raise AttributeError(
"TileDB context not found. Incompatible TileDB-Py version?"
)
memory_budget = int(ctx.config()["py.init_buffer_bytes"])
except KeyError:
memory_budget = 10 * 1024**2
Expand Down
11 changes: 10 additions & 1 deletion tiledb/ml/readers/_tensor_schema/dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ def iter_tensors(
@property
def max_partition_weight(self) -> int:
# getattr for compatibility with TileDB-Py <0.33
ctx = getattr(self._array, "ctx", self._array._ctx_())
if hasattr(self._array, "ctx"): # Check if 'ctx' exists (TileDB-Py >= 0.33)
ctx = self._array.ctx
elif hasattr(
self._array, "_ctx_"
): # Check if '_ctx_' exists (TileDB-Py < 0.33)
ctx = self._array._ctx_() # Note the parentheses - it was a method
else:
raise AttributeError(
"TileDB context not found. Incompatible TileDB-Py version?"
)
memory_budget = int(ctx.config()["sm.mem.total_budget"])

# The memory budget should be large enough to read the cells of the largest field
Expand Down

0 comments on commit d88cb02

Please sign in to comment.