-
Notifications
You must be signed in to change notification settings - Fork 155
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
(feat): custom reopen
with read_elem_as_dask
for remote h5ad
#1665
base: main
Are you sure you want to change the base?
Conversation
reopen
with read_elem_as_dask
reopen
with read_elem_as_dask
for remote h5ad
I should note that I could not figure out how to extract the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1665 +/- ##
==========================================
- Coverage 86.87% 84.40% -2.47%
==========================================
Files 39 39
Lines 6033 6033
==========================================
- Hits 5241 5092 -149
- Misses 792 941 +149
|
) -> Generator[StorageType, None, None]: | ||
) -> Callable[[], Iterator[StorageType]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous type was correct, the new one isn’t.
The way decorators interact with typing is that you normally type the decorated function (e.g. if it contains yield
, the return type is Generator
). The decorator than transforms the function from whatever it is to whatever the decorator wants.
I.e.
@contextmanager
def foo(*args: Unpack[Args]) -> Generator[Ret, None, None]: ...
is the same as
def _foo(*args: Unpack[Args]) -> Generator[Ret, None, None]: ...
foo: Callable[Args, AbstractContextManager[Ret]] = contextmanager(_foo)
(I’m not 100% sure I got the “unpack” syntax right, but you know what I mean)
@@ -67,13 +67,18 @@ def make_dask_chunk( | |||
*, | |||
wrap: Callable[[ArrayStorageType], ArrayStorageType] | |||
| Callable[[H5Group | ZarrGroup], _CSRDataset | _CSCDataset] = lambda g: g, | |||
reopen: None | Callable[[], Iterator[StorageType]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the idea is “reopen is a callable that can be transformed into a context manager using contextlib.contextmanager
.
Why not just “reopen is a callable that returns an contextlib.AbstractContextManager[StorageType]
?
Do you know what the difference is between what |
@ivirshup My understanding is that |
@ivirshup any thoughts on this for 0.12? |
Benchmark changes
Comparison: https://github.com/scverse/anndata/compare/d7643e966b7cfaf8f5c732f1f020b0674db1def9..abc13bd785ab1049c17443c620fe0fad276fd4f9 More details: https://github.com/scverse/anndata/pull/1665/checks?check_run_id=31678498264 |
Not sure about the typing on
reopen
(withGenerator[...]
as before, it was complaining, but a normalCallable
withreturn
felt wrong); however, the following seems to work:The question is whether or not we'd want to internalize this - my guess is "no." I think we should only promise support for core zarr/hdf5. The flip side then is how do we test this....good questions to grapple with!
dask