Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZarrMerge writer import for backwards compatibility. #132

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading