Skip to content

Commit

Permalink
ZarrMerge writer import for backwards compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gautam8387 committed Oct 29, 2024
1 parent 31fe772 commit 63f5bcd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
22 changes: 11 additions & 11 deletions scarf/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
__all__ = [
"DatasetMerge",
"AssayMerge",
"ZarrMerge",
# "ZarrMerge",
]


Expand Down Expand Up @@ -640,16 +640,16 @@ def dump(self, nthreads=4):


# Alias for ZarrMerge
class ZarrMerge(AssayMerge):
"""
Alias for AssayMerge for backward compatibility.
"""

def __init__(self, *args, **kwargs):
logger.warning(
"The 'ZarrMerge' class is deprecated and will be removed in a future release. Please use 'AssayMerge' instead."
)
super().__init__(*args, **kwargs)
# class ZarrMerge(AssayMerge):
# """
# Alias for AssayMerge for backward compatibility.
# """

# def __init__(self, *args, **kwargs):
# logger.warning(
# "The 'ZarrMerge' class is deprecated and will be removed in a future release. Please use 'AssayMerge' instead."
# )
# super().__init__(*args, **kwargs)


class DatasetMerge:
Expand Down
27 changes: 25 additions & 2 deletions scarf/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
"""

import os
from typing import Any, Tuple, List, Union, Dict, Optional
from typing import Any, Tuple, List, Union, Dict, Optional, TYPE_CHECKING

if TYPE_CHECKING:
from .merge import AssayMerge


import numpy as np
import pandas as pd
Expand Down Expand Up @@ -52,9 +56,9 @@
"to_h5ad",
"to_mtx",
"CSVtoZarr",
"ZarrMerge"
]


def create_zarr_dataset(
g: zarr.Group,
name: str,
Expand Down Expand Up @@ -242,6 +246,25 @@ def sparse_writer(store: zarr.Array, data_stream, n_cells: int, batch_size: int)
return e


def _import_merge():
from .merge import AssayMerge
return AssayMerge

# Alias for ZarrMerge
class ZarrMerge:
"""
Proxy class for backward compatibility.
Lazily imports AssayMerge to avoid circular imports.
"""
def __new__(cls, *args, **kwargs):
from loguru import logger
logger.warning(
"The 'ZarrMerge' class is deprecated and will be removed in a future release. "
"Please use 'AssayMerge' instead."
)
AssayMerge = _import_merge()
return AssayMerge(*args, **kwargs)

class CrToZarr:
"""A class for converting data in the Cellranger format to a Zarr
hierarchy.
Expand Down

0 comments on commit 63f5bcd

Please sign in to comment.