diff --git a/lamindb/core/storage/_tiledbsoma.py b/lamindb/core/storage/_tiledbsoma.py index c1f6fc921..ce963f79b 100644 --- a/lamindb/core/storage/_tiledbsoma.py +++ b/lamindb/core/storage/_tiledbsoma.py @@ -10,6 +10,7 @@ from lamindb_setup.core._settings_storage import get_storage_region from lamindb_setup.core.upath import LocalPathClasses, create_path from lnschema_core import Artifact, Run +from packaging import version if TYPE_CHECKING: from lamindb_setup.core.types import UPathStr @@ -182,14 +183,28 @@ def save_tiledbsoma_experiment( context=ctx, ) + resize_experiment = False if registration_mapping is not None: - n_observations = len(registration_mapping.obs_axis.data) + if version.parse(soma.__version__) < version.parse("1.15.0rc4"): + n_observations = len(registration_mapping.obs_axis.data) + else: + n_observations = registration_mapping.get_obs_shape() + resize_experiment = True else: # happens only if not appending and only one adata passed assert len(adata_objects) == 1 # noqa: S101 n_observations = adata_objects[0].n_obs logger.important(f"Writing the tiledbsoma store to {storepath}") for adata_obj in adata_objects: + if resize_experiment and soma.Experiment.exists(storepath, context=ctx): + # can only happen if registration_mapping is not None + soma_io.resize_experiment( + storepath, + nobs=n_observations, + nvars=registration_mapping.get_var_shapes(), + context=ctx, + ) + resize_experiment = False soma_io.from_anndata( storepath, adata_obj, diff --git a/noxfile.py b/noxfile.py index c55200115..58a17254f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -89,15 +89,16 @@ def install_ci(session, group): # testing load_to_memory for yaml run(session, "uv pip install --system PyYAML") run(session, "uv pip install --system huggingface_hub") - # pinning 1.15.0rc3 because 1.14.5 is incompatible with anndata>=0.11.0 - # and >1.15.0rc4 has a different append mode API - # wating for a normal release to adapt - run( - session, "uv pip install --system tiledbsoma==1.15.0rc3" - ) # test SOMACurator + # tiledbsoma dependency, specifying it here explicitly + # otherwise there are problems with uv resolver + run(session, "uv pip install --system scanpy") + run(session, "uv pip install --system tiledbsoma") # test SOMACurator elif group == "unit-storage": extras += "zarr,bionty" - run(session, "uv pip install --system tiledbsoma==1.15.0rc3") + # tiledbsoma dependency, specifying it here explicitly + # otherwise there are problems with uv resolver + run(session, "uv pip install --system scanpy") + run(session, "uv pip install --system tiledbsoma") elif group == "tutorial": extras += "jupyter,bionty" run(session, "uv pip install --system huggingface_hub")