Skip to content

Commit

Permalink
[python] Continue to use tiledb.Ctx's tiledb_config until it is remov…
Browse files Browse the repository at this point in the history
…ed (#2768)
  • Loading branch information
nguyenv committed Jul 2, 2024
1 parent 3eab504 commit ccc4487
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
26 changes: 16 additions & 10 deletions apis/python/src/tiledbsoma/options/_soma_tiledb_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,22 @@ def _internal_tiledb_config(self) -> Dict[str, Union[str, float]]:
Returns a new dict with the contents. Caller must hold ``_lock``.
"""
if self._native_context is None:
# Our TileDB Context has not yet been built.
# We return what will be passed into `tiledb.Ctx()`.
return (
dict(self._initial_config)
if self._initial_config is not None
else _default_config({})
)
# We *do* have a TileDB Context. Return its actual config.
return dict(self._native_context.config())
# We have a clib.SOMAContext. Return its actual config.
if self._native_context is not None:
return dict(self._native_context.config())

# We have TileDB Context. Return its actual config.
# TODO This block will be deleted once tiledb_ctx is removed in 1.14
if self._tiledb_ctx is not None:
return dict(self._tiledb_ctx.config())

# Our context has not yet been built.
# We return what will be passed into the context.
return (
dict(self._initial_config)
if self._initial_config is not None
else _default_config({})
)

def replace(
self,
Expand Down
7 changes: 7 additions & 0 deletions apis/python/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def test_lazy_init():
mock_ctx.assert_called_once()


def test_tiledb_ctx_init():
config = {"hither": "yon"}
with pytest.deprecated_call():
context = stc.SOMATileDBContext(tiledb_ctx=tiledb.Ctx(config))
assert "hither" in context.tiledb_config


def test_lazy_replace_config():
"""Verifies we don't construct a Ctx even if we call ``.replace``."""
with mock.patch.object(tiledb, "Ctx", wraps=tiledb.Ctx) as mock_ctx:
Expand Down

0 comments on commit ccc4487

Please sign in to comment.