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

Implement lazy data saving to xarray output. #73

Closed
wants to merge 1 commit into from

Conversation

pp-mo
Copy link
Owner

@pp-mo pp-mo commented Jun 29, 2022

A feature extension to keep data lazy in xarray output


# This identifies a VariableMimic as an array-like object to which LAZY
# data can be written (a dask array).
_ACCEPTS_LAZY_DATA_WRITES = True
Copy link
Owner Author

@pp-mo pp-mo Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: thinking this over, I now think this mechanism is pretty awful.

If we simply accept that we can only replace lazy content wholesale, then we can provide a method specifically for that.
E.G.

    def set_lazy_content(self, array):
        if not all(hasattr(array,x) for x in ('compute', '__setitem__', 'shape')):
            raise ValueError(f'Assigned content, {array} must be a lazy array.')
        self._xr = array

That way,

  1. the existence of set_lazy_content can be used as the capability test used by the assigner ('da.store' replacement)
  2. we don't need the complex _indexes_address_full_shape code.

@pp-mo pp-mo closed this Mar 4, 2024
@pp-mo pp-mo deleted the nc_dataset_save_lazystream branch March 4, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant