Skip to content

Commit

Permalink
rebase onto current main
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Sep 17, 2024
2 parents 7bcd78d + aebcf65 commit 9790ab0
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 61 deletions.
81 changes: 44 additions & 37 deletions apis/python/src/tiledbsoma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,42 +97,6 @@
import os
import sys

from somacore import AxisColumnNames, AxisQuery, ExperimentAxisQuery
from somacore.options import ResultOrder

from ._collection import Collection
from ._constants import SOMA_JOINID
from ._dataframe import DataFrame
from ._dense_nd_array import DenseNDArray
from ._exception import (
AlreadyExistsError,
DoesNotExistError,
NotCreateableError,
SOMAError,
)
from ._experiment import Experiment
from ._factory import open
from ._general_utilities import (
get_implementation,
get_implementation_version,
get_SOMA_version,
get_storage_engine,
show_package_versions,
)
from ._indexer import IntIndexer, tiledbsoma_build_index
from ._measurement import Measurement
from ._sparse_nd_array import SparseNDArray, SparseNDArrayRead
from .options import SOMATileDBContext, TileDBCreateOptions, TileDBWriteOptions
from .pytiledbsoma import (
tiledbsoma_stats_disable,
tiledbsoma_stats_dump,
tiledbsoma_stats_enable,
tiledbsoma_stats_reset,
)
from .stats import (
tiledbsoma_stats_as_py,
tiledbsoma_stats_json,
)

# Load native libraries. On wheel builds, we may have a shared library
# already linked. In this case, we can import directly
Expand Down Expand Up @@ -171,6 +135,49 @@
# Otherwise try loading by name only.
ctypes.CDLL(libtiledbsoma_name)

from somacore import AxisColumnNames, AxisQuery, ExperimentAxisQuery
from somacore.options import ResultOrder

# This is important since we need to do the above dll/dylib/so business
# _before_ imports, but, ruff will tell us that imports need to be
# at the top of the file:
#
# ruff: noqa

from ._collection import Collection
from ._constants import SOMA_JOINID
from ._dataframe import DataFrame
from ._dense_nd_array import DenseNDArray
from ._exception import (
AlreadyExistsError,
DoesNotExistError,
NotCreateableError,
SOMAError,
)
from ._experiment import Experiment
from ._factory import open
from ._general_utilities import (
get_implementation,
get_implementation_version,
get_SOMA_version,
get_storage_engine,
show_package_versions,
)
from ._indexer import IntIndexer, tiledbsoma_build_index
from ._measurement import Measurement
from ._sparse_nd_array import SparseNDArray, SparseNDArrayRead
from .options import SOMATileDBContext, TileDBCreateOptions, TileDBWriteOptions
from .pytiledbsoma import (
tiledbsoma_stats_disable,
tiledbsoma_stats_dump,
tiledbsoma_stats_enable,
tiledbsoma_stats_reset,
)
from .stats import (
tiledbsoma_stats_as_py,
tiledbsoma_stats_json,
)

__version__ = get_implementation_version()

__all__ = [
Expand Down Expand Up @@ -205,6 +212,6 @@
"tiledbsoma_stats_dump",
"tiledbsoma_stats_enable",
"tiledbsoma_stats_reset",
"tiledbsoma_stats_json",
"tiledbsoma_stats_as_py",
"tiledbsoma_stats_json",
]
4 changes: 2 additions & 2 deletions apis/python/src/tiledbsoma/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from somacore import options
from typing_extensions import Self

from tiledbsoma._flags import _new_shape_feature_flag_enabled
from tiledbsoma._flags import NEW_SHAPE_FEATURE_FLAG_ENABLED

from . import _arrow_types, _util
from . import pytiledbsoma as clib
Expand Down Expand Up @@ -293,7 +293,7 @@ def create(
# [4] core current domain hi

index_column_schema.append(pa_field)
if _new_shape_feature_flag_enabled():
if NEW_SHAPE_FEATURE_FLAG_ENABLED:

index_column_data[pa_field.name] = [
*slot_core_max_domain,
Expand Down
15 changes: 5 additions & 10 deletions apis/python/src/tiledbsoma/_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@

import os

# Temporary for https://github.com/single-cell-data/TileDB-SOMA/issues/2407
_new_shape_feature_flag = os.getenv("SOMA_PY_NEW_SHAPE") is not None
# This is temporary for
# https://github.com/single-cell-data/TileDB-SOMA/issues/2407. It will be
# removed once https://github.com/single-cell-data/TileDB-SOMA/issues/2407 is
# complete.


def _new_shape_feature_flag_enabled() -> bool:
"""
This is temporary only and will be removed once
https://github.com/single-cell-data/TileDB-SOMA/issues/2407
is complete.
"""
return _new_shape_feature_flag
NEW_SHAPE_FEATURE_FLAG_ENABLED = os.getenv("SOMA_PY_NEW_SHAPE") is not None
4 changes: 2 additions & 2 deletions apis/python/src/tiledbsoma/_sparse_nd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from somacore.options import PlatformConfig
from typing_extensions import Self

from tiledbsoma._flags import _new_shape_feature_flag_enabled
from tiledbsoma._flags import NEW_SHAPE_FEATURE_FLAG_ENABLED

from . import _util

Expand Down Expand Up @@ -163,7 +163,7 @@ def create(
# [3] core current domain lo
# [4] core current domain hi

if _new_shape_feature_flag_enabled():
if NEW_SHAPE_FEATURE_FLAG_ENABLED:
dim_capacity, dim_extent = cls._dim_capacity_and_extent(
dim_name,
# The user specifies current domain -- this is the max domain
Expand Down
2 changes: 1 addition & 1 deletion apis/python/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_dataframe(tmp_path, arrow_schema):
# More to come on https://github.com/single-cell-data/TileDB-SOMA/issues/2407
assert (
sdf.tiledbsoma_has_upgraded_domain
== soma._flags._new_shape_feature_flag_enabled()
== soma._flags.NEW_SHAPE_FEATURE_FLAG_ENABLED
)

with pytest.raises(AttributeError):
Expand Down
12 changes: 6 additions & 6 deletions apis/python/tests/test_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_sparse_nd_array_basics(
# More to come on https://github.com/single-cell-data/TileDB-SOMA/issues/2407
assert (
snda.tiledbsoma_has_upgraded_shape
== tiledbsoma._flags._new_shape_feature_flag_enabled()
== tiledbsoma._flags.NEW_SHAPE_FEATURE_FLAG_ENABLED
)

# Before current-domain support: shape is maxshape.
Expand All @@ -58,7 +58,7 @@ def test_sparse_nd_array_basics(
# involving R compatibility, and leaving room for a single tile
# capacity, etc ... we could check for some magic value but it suffices
# to check that it's over 2 billion.)
if tiledbsoma._flags._new_shape_feature_flag_enabled():
if tiledbsoma._flags.NEW_SHAPE_FEATURE_FLAG_ENABLED:
for e in snda.maxshape:
assert e > 2_000_000_000
else:
Expand Down Expand Up @@ -89,7 +89,7 @@ def test_sparse_nd_array_basics(
with tiledbsoma.SparseNDArray.open(uri) as snda:
assert snda.shape == arg_shape
# This will change with current-domain support
if tiledbsoma._flags._new_shape_feature_flag_enabled():
if tiledbsoma._flags.NEW_SHAPE_FEATURE_FLAG_ENABLED:
for e in snda.maxshape:
assert e > 2_000_000_000
else:
Expand All @@ -113,7 +113,7 @@ def test_sparse_nd_array_basics(
with tiledbsoma.SparseNDArray.open(uri) as snda:
assert snda.shape == arg_shape

if tiledbsoma._flags._new_shape_feature_flag_enabled():
if tiledbsoma._flags.NEW_SHAPE_FEATURE_FLAG_ENABLED:

# Test resize down
new_shape = tuple([arg_shape[i] - 50 for i in range(ndim)])
Expand Down Expand Up @@ -267,11 +267,11 @@ def test_dataframe_basics(tmp_path, soma_joinid_domain, index_column_names):
has_sjid_dim = "soma_joinid" in index_column_names
if has_sjid_dim:
assert sdf._maybe_soma_joinid_shape == 1 + soma_joinid_domain[1]
if not tiledbsoma._flags._new_shape_feature_flag_enabled():
if not tiledbsoma._flags.NEW_SHAPE_FEATURE_FLAG_ENABLED:
assert sdf._maybe_soma_joinid_maxshape == 1 + soma_joinid_domain[1]
else:
assert sdf._maybe_soma_joinid_shape is None
if not tiledbsoma._flags._new_shape_feature_flag_enabled():
if not tiledbsoma._flags.NEW_SHAPE_FEATURE_FLAG_ENABLED:
assert sdf._maybe_soma_joinid_maxshape is None

assert len(sdf.non_empty_domain()) == len(index_column_names)
2 changes: 1 addition & 1 deletion apis/python/tests/test_sparse_nd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ def test_tile_extents(tmp_path):
).close()

with tiledb.open(uri) as A:
if soma._flags._new_shape_feature_flag_enabled():
if soma._flags.NEW_SHAPE_FEATURE_FLAG_ENABLED:
assert A.schema.domain.dim(0).tile == 2048
assert A.schema.domain.dim(1).tile == 2048
else:
Expand Down
1 change: 0 additions & 1 deletion apis/r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Imports:
stats,
bit64,
tiledb (>= 0.30.0),
tiledb (<= 0.30.99),
arrow (>= 14.0.0),
utils,
fs,
Expand Down
2 changes: 1 addition & 1 deletion apis/r/R/Init.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if (rpkg_lib_version != soma_lib_version) {
msg <- sprintf("TileDB Core version %s used by TileDB-R package, but TileDB-SOMA uses %s",
sQuote(rpkg_lib_version), sQuote(soma_lib_version))
stop(msg, call. = FALSE)
packageStartupMessage(msg)
}

# This is temporary for https://github.com/single-cell-data/TileDB-SOMA/issues/2407
Expand Down

0 comments on commit 9790ab0

Please sign in to comment.