keller-mark / pizzarr

Slice into Zarr arrays in R 🍕
https://keller-mark.github.io/pizzarr/
MIT License
25 stars 2 forks source link

S3/S4-based wrappers around R6 classes for more R-like API #48

Open keller-mark opened 10 months ago

keller-mark commented 10 months ago

From discussions with @pieterjanvc the non-R6 API would be much more natural for the R ecosystem

dblodgett-usgs commented 10 months ago

+1 to this

Consider the RNetCDF API pattern where you pass an open object to a function that works with it.

e.g. open.nc() returns an nc object and you pass that object to functions like att.get() or var.put() etc.

dblodgett-usgs commented 1 month ago

@keller-mark -- here's what I've got cooking.

https://code.usgs.gov/wma/nhgf/geo-data-portal/rnz/-/tree/develop

The README there shows the basics of what it does so far.

I am going to get a copy of that repository public at: https://github.com/DOI-USGS/rnz and will do the rest of the development on a dirty main branch but there's a bit more paperwork to get cleared before it's done.

dblodgett-usgs commented 1 month ago

I implemented:

#' Returns results of listing the store
#' 
#' @param x a pizzar Store object 
#' @export
names.Store <- function(x) {
  x$listdir()
}

And a side affect that is kind of unfortunate is:

> class(store)
[1] "DirectoryStore" "Store"          "R6"  

image

Not sure what the UX of working with these classes really should be, but I'm not sure that R6 and S3 should really coexist based on this?

mdsumner commented 1 month ago

might be some relevance in the new S7 on your questions here (if you haven't seen that): https://blog.r-project.org/2024/05/17/generalizing-support-for-functional-oop-in-r/index.html

dblodgett-usgs commented 1 month ago

I need to sit quietly with some examples of how to implement subsetting and assignment. @keller-mark -- do you feel like the implementations of bracket methods in zarr-array.R are the way they should be or were those just a starting point?