Skip to content

Commit

Permalink
Better fix for #172. (#198)
Browse files Browse the repository at this point in the history
* Better fix for #172.

* Update HISTORY.rst
  • Loading branch information
JSKenyon committed Apr 12, 2022
1 parent d6f1d0b commit 8c6af89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ History

X.Y.Z (YYYY-MM-DD)
------------------
* Improve fix for #172 - error out more reliably. (:pr:`198`)
* Fix #172 - error out when missing datavars should be written. (:pr:`197`)
* Fix #195 - allow non-standard columns to be tiled. (:pr:`196`)

Expand Down
12 changes: 10 additions & 2 deletions daskms/experimental/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ def select_vars_and_coords(dataset, columns):
column_set = set(columns)
data_vars = dataset.data_vars
coords = dataset.coords
data_cols = column_set & set(data_vars.keys())
coord_cols = column_set & set(coords.keys())
data_var_names = set(data_vars.keys())
coord_names = set(coords.keys())

if not column_set.issubset((data_var_names | coord_names)):
raise ValueError(f"User requested writes on the following "
f"columns: {column_set}. Some or all of these "
f"are not present on the datasets. Aborting.")

data_cols = column_set & data_var_names
coord_cols = column_set & coord_names

for c in coord_cols:
coord_cols.union(*(d for d in coords[c].dims))
Expand Down
5 changes: 0 additions & 5 deletions daskms/experimental/zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ def xds_to_zarr(xds, store, columns=None):

data_vars, coords = select_vars_and_coords(ds, columns)

if not data_vars:
raise ValueError(f"User requested writes on the following "
f"columns: {columns}. Some or all of these "
f"are not present on the datasets. Aborting.")

group = prepare_zarr_group(di, ds, store)

data_vars = dict(_gen_writes(data_vars, ds.chunks, group))
Expand Down

0 comments on commit 8c6af89

Please sign in to comment.