Repository: single-cell-data/TileDB-SOMA (language: python)

Issue:
Move `experimental` module to `io.spatial`
Move the `experimental` modules with ingest/outgest for spatial omics to `io.spatial`.




Discussion / hints:

Fix patch:
diff --git a/apis/python/notebooks/tutorial_spatial.ipynb b/apis/python/notebooks/tutorial_spatial.ipynb
index dd72c2d81f..392b1a0212 100644
--- a/apis/python/notebooks/tutorial_spatial.ipynb
+++ b/apis/python/notebooks/tutorial_spatial.ipynb
@@ -36,7 +36,7 @@
     "\n",
     "import tiledbsoma\n",
     "from tiledbsoma import Experiment\n",
-    "from tiledbsoma.experimental import from_visium\n",
+    "from tiledbsoma.io.spatial import from_visium\n",
     "\n",
     "err = partial(print, file=stderr)\n"
    ]
@@ -183,7 +183,7 @@
      "output_type": "stream",
      "text": [
       "Ingesting data/CytAssist_FFPE_Protein_Expression_Human_Glioblastoma/10x to data/CytAssist_FFPE_Protein_Expression_Human_Glioblastoma/soma\n",
-      "/tmp/ipykernel_35332/2080821725.py:3: UserWarning: Support for spatial types is experimental. Changes to both the API and data storage may not be backwards compatible.\n",
+      "/tmp/ipykernel_151554/2080821725.py:3: UserWarning: Support for spatial types is experimental. Changes to both the API and data storage may not be backwards compatible.\n",
       "  from_visium(\n"
      ]
     }
@@ -548,7 +548,7 @@
     {
      "data": {
       "text/plain": [
-       "<matplotlib.image.AxesImage at 0xff65c6cb9b50>"
+       "<matplotlib.image.AxesImage at 0xff91a6664110>"
       ]
      },
      "execution_count": 19,
@@ -1181,7 +1181,7 @@
     {
      "data": {
       "text/plain": [
-       "SpatialRead(data=<tiledbsoma._read_iters.TableReadIter object at 0xff65e817c8d0>, data_coordinate_space=CoordinateSpace(axes=(Axis(name='x', unit='pixels'), Axis(name='y', unit='pixels'))), output_coordinate_space=CoordinateSpace(axes=(Axis(name='x', unit='pixels'), Axis(name='y', unit='pixels'))), coordinate_transform=<IdentityTransform\n",
+       "SpatialRead(data=<tiledbsoma._read_iters.TableReadIter object at 0xff91a1754850>, data_coordinate_space=CoordinateSpace(axes=(Axis(name='x', unit='pixels'), Axis(name='y', unit='pixels'))), output_coordinate_space=CoordinateSpace(axes=(Axis(name='x', unit='pixels'), Axis(name='y', unit='pixels'))), coordinate_transform=<IdentityTransform\n",
        "  input axes: ('x', 'y')\n",
        "  output axes: ('x', 'y')>)"
       ]
diff --git a/apis/python/src/tiledbsoma/experimental/__init__.py b/apis/python/src/tiledbsoma/io/spatial/__init__.py
similarity index 100%
rename from apis/python/src/tiledbsoma/experimental/__init__.py
rename to apis/python/src/tiledbsoma/io/spatial/__init__.py
diff --git a/apis/python/src/tiledbsoma/experimental/_util.py b/apis/python/src/tiledbsoma/io/spatial/_util.py
similarity index 98%
rename from apis/python/src/tiledbsoma/experimental/_util.py
rename to apis/python/src/tiledbsoma/io/spatial/_util.py
index 13e03c43c6..0b4cfcfb39 100644
--- a/apis/python/src/tiledbsoma/experimental/_util.py
+++ b/apis/python/src/tiledbsoma/io/spatial/_util.py
@@ -7,7 +7,7 @@
 
 import h5py
 
-from .._exception import SOMAError
+from ..._exception import SOMAError
 
 
 def _str_to_int(value: str) -> int:
diff --git a/apis/python/src/tiledbsoma/experimental/_xarray_backend.py b/apis/python/src/tiledbsoma/io/spatial/_xarray_backend.py
similarity index 98%
rename from apis/python/src/tiledbsoma/experimental/_xarray_backend.py
rename to apis/python/src/tiledbsoma/io/spatial/_xarray_backend.py
index 34214f0a91..c27e813980 100644
--- a/apis/python/src/tiledbsoma/experimental/_xarray_backend.py
+++ b/apis/python/src/tiledbsoma/io/spatial/_xarray_backend.py
@@ -23,8 +23,8 @@
     warnings.warn("Experimental spatial exporter requires the xarray package.")
     raise err
 
-from .. import DenseNDArray
-from ..options._soma_tiledb_context import SOMATileDBContext
+from ... import DenseNDArray
+from ...options._soma_tiledb_context import SOMATileDBContext
 from ._util import _str_to_int
 
 
diff --git a/apis/python/src/tiledbsoma/experimental/ingest.py b/apis/python/src/tiledbsoma/io/spatial/ingest.py
similarity index 98%
rename from apis/python/src/tiledbsoma/experimental/ingest.py
rename to apis/python/src/tiledbsoma/io/spatial/ingest.py
index 8209c97236..5d43f4f539 100644
--- a/apis/python/src/tiledbsoma/experimental/ingest.py
+++ b/apis/python/src/tiledbsoma/io/spatial/ingest.py
@@ -39,7 +39,7 @@
 
 from somacore import Axis, CoordinateSpace, IdentityTransform, ScaleTransform
 
-from .. import (
+from ... import (
     Collection,
     DataFrame,
     DenseNDArray,
@@ -51,17 +51,21 @@
     _util,
     logging,
 )
-from .._arrow_types import df_to_arrow
-from .._constants import SPATIAL_DISCLAIMER
-from .._exception import (
+from ..._arrow_types import df_to_arrow
+from ..._constants import SPATIAL_DISCLAIMER
+from ..._exception import (
     AlreadyExistsError,
     NotCreateableError,
     SOMAError,
 )
-from .._soma_object import AnySOMAObject
-from .._types import IngestMode
-from ..io import from_anndata
-from ..io.ingest import (
+from ..._soma_object import AnySOMAObject
+from ..._types import IngestMode
+from ...options._tiledb_create_write_options import (
+    TileDBCreateOptions,
+    TileDBWriteOptions,
+)
+from .. import from_anndata
+from ..ingest import (
     IngestCtx,
     IngestionParams,
     _create_or_open_collection,
@@ -69,18 +73,14 @@
     _write_arrow_table,
     add_metadata,
 )
-from ..options._tiledb_create_write_options import (
-    TileDBCreateOptions,
-    TileDBWriteOptions,
-)
 from ._util import _read_visium_software_version
 
 if TYPE_CHECKING:
     from somacore.options import PlatformConfig
 
-    from ..io._common import AdditionalMetadata
-    from ..io._registration import ExperimentAmbientLabelMapping
-    from ..options import SOMATileDBContext
+    from ...options import SOMATileDBContext
+    from .._common import AdditionalMetadata
+    from .._registration import ExperimentAmbientLabelMapping
 
 
 def path_validator(instance, attribute, value: Path) -> None:  # type: ignore[no-untyped-def]
diff --git a/apis/python/src/tiledbsoma/experimental/outgest.py b/apis/python/src/tiledbsoma/io/spatial/outgest.py
similarity index 99%
rename from apis/python/src/tiledbsoma/experimental/outgest.py
rename to apis/python/src/tiledbsoma/io/spatial/outgest.py
index 5886c8dfed..cc3fb6e423 100644
--- a/apis/python/src/tiledbsoma/experimental/outgest.py
+++ b/apis/python/src/tiledbsoma/io/spatial/outgest.py
@@ -19,8 +19,8 @@
     warnings.warn("Experimental spatial outgestor requires the geopandas package.")
     raise err
 
-from .. import MultiscaleImage, PointCloudDataFrame
-from .._constants import SOMA_JOINID
+from ... import MultiscaleImage, PointCloudDataFrame
+from ..._constants import SOMA_JOINID
 from ._xarray_backend import dense_nd_array_to_data_array, images_to_datatree
 
 if TYPE_CHECKING:


Test patch:
diff --git a/apis/python/tests/test_basic_xarray_io.py b/apis/python/tests/test_basic_xarray_io.py
index ed1cfea5e6..c04b04d51b 100644
--- a/apis/python/tests/test_basic_xarray_io.py
+++ b/apis/python/tests/test_basic_xarray_io.py
@@ -6,7 +6,7 @@
 
 import tiledbsoma as soma
 
-soma_xarray = pytest.importorskip("tiledbsoma.experimental._xarray_backend")
+soma_xarray = pytest.importorskip("tiledbsoma.io.spatial._xarray_backend")
 xr = pytest.importorskip("xarray")
 
 
diff --git a/apis/python/tests/test_export_multiscale_image.py b/apis/python/tests/test_export_multiscale_image.py
index 0c56452d86..bc6609164c 100644
--- a/apis/python/tests/test_export_multiscale_image.py
+++ b/apis/python/tests/test_export_multiscale_image.py
@@ -7,7 +7,7 @@
 
 import tiledbsoma as soma
 
-soma_outgest = pytest.importorskip("tiledbsoma.experimental.outgest")
+soma_outgest = pytest.importorskip("tiledbsoma.io.spatial.outgest")
 sd = pytest.importorskip("spatialdata")
 
 
diff --git a/apis/python/tests/test_export_point_cloud_dataframe.py b/apis/python/tests/test_export_point_cloud_dataframe.py
index 337f6b6779..58823ffee8 100644
--- a/apis/python/tests/test_export_point_cloud_dataframe.py
+++ b/apis/python/tests/test_export_point_cloud_dataframe.py
@@ -10,7 +10,7 @@
 import tiledbsoma as soma
 
 gpd = pytest.importorskip("geopandas")
-soma_outgest = pytest.importorskip("tiledbsoma.experimental.outgest")
+soma_outgest = pytest.importorskip("tiledbsoma.io.spatial.outgest")
 spatialdata = pytest.importorskip("spatialdata")