It would be neat to add a method vds.nrefs() to the accessor, which returns the total number of virtual references in the dataset. It's useful to know how many millions of references you're about to try and write to icechunk (or kerchunk json...)
class VirtualDatasetAccessor
def nrefs(self: xr.Dataset) -> int:
"""Count the number of virtual references in the dataset"""
from virtualizarr.manifests import ManifestArray
# this just ignores non-virtual variables
return sum(
len(var.data.manifest) for var in vds.variables.values() if isinstance(var.data, ManifestArray)
)