From a3bd72f28d42b39150f0da1a1bf1033994265f9f Mon Sep 17 00:00:00 2001 From: Joyce Yan <5653616+joyceyan@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:46:02 -0800 Subject: [PATCH] feat: Do not use backed mode when reading in anndata for CXG conversion (#7377) --- DEV_ENV_WITHOUT_DOCKER.md | 22 +++++++++++++++++++++ backend/layers/processing/h5ad_data_file.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/DEV_ENV_WITHOUT_DOCKER.md b/DEV_ENV_WITHOUT_DOCKER.md index 50f87e4d141dc..83eb05fc3ebbe 100644 --- a/DEV_ENV_WITHOUT_DOCKER.md +++ b/DEV_ENV_WITHOUT_DOCKER.md @@ -51,3 +51,25 @@ Run functional tests for WMG api against the `dev` environment. **NOTE**: `dev` environment is a remote environment. These functional tests run locally against a backend in a remote environment called `dev`. 1. `AWS_PROFILE=single-cell-dev DEPLOYMENT_STAGE=dev pytest -v tests/functional/backend/wmg/test_wmg_api.py` + +### Set up vips + +You may run into issues with finding `_libvips` if you're running a Jupyter notebook locally that calls `pyvips`, such as when running CXG conversion locally. The error may look like this: + +``` +ModuleNotFoundError Traceback (most recent call last) +File ~/miniconda3/envs/py11/lib/python3.11/site-packages/pyvips/__init__.py:19 + 18 try: +---> 19 import _libvips + 21 logger.debug('Loaded binary module _libvips') + +ModuleNotFoundError: No module named '_libvips' +``` + +To resolve this, you'll need to install `vips` with `brew install vips`, because this is a dependency that `pyvips` has. If you're using conda, you'll have to also tell your conda environment where homebrew installed `vips`. You can do this with: + +``` +mkdir -p ~/miniconda3/envs//etc/conda/activate.d +touch ~/miniconda3/envs//etc/conda/activate.d/env_vars.sh +echo 'export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH' >> ~/miniconda3/envs//etc/conda/activate.d/env_vars.sh +``` diff --git a/backend/layers/processing/h5ad_data_file.py b/backend/layers/processing/h5ad_data_file.py index 58e7381526462..5720b31a4a558 100644 --- a/backend/layers/processing/h5ad_data_file.py +++ b/backend/layers/processing/h5ad_data_file.py @@ -183,7 +183,7 @@ def validate_anndata(self): def extract_anndata_elements_from_file(self): logging.info(f"Reading in AnnData dataset: {path.basename(self.input_filename)}") - self.anndata = anndata.read_h5ad(self.input_filename, backed="r") + self.anndata = anndata.read_h5ad(self.input_filename) logging.info("Completed reading in AnnData dataset!") self.obs = self.transform_dataframe_index_into_column(self.anndata.obs, "obs", self.obs_index_column_name)