Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/zarr/testing/stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,13 @@ def delete_array_using_del(self, data: DataObject) -> None:
self.all_arrays.remove(array_path)

@precondition(lambda self: self.store.supports_deletes)
@precondition(lambda self: len(self.all_groups) >= 2) # fixme don't delete root
@precondition(lambda self: bool(self.all_groups - {"", "/"}))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is "" in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty sure the root group gets put there as "", or at least i think i remember that happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking again i might have been confused by this:

if self.all_groups:
parent = data.draw(st.sampled_from(sorted(self.all_groups)), label="Group parent")
else:
parent = ""

beceuase we strip the / at the start of paths i was worried that root might end up there as an empty string.

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC it should be "/", so I prefer not filtering for ""

Copy link
Contributor

Choose a reason for hiding this comment

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

the name of the root group is the empty string "". You probably get the same thing with "/", but that's technically the root group + a separator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so maybe we only filter for ""?

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds right but please confirm what's inserted in the bundle; we should only filter for one.

@rule(data=st.data())
def delete_group_using_del(self, data: DataObject) -> None:
# ensure that we don't include the root group in the list of member names that we try
# to delete
member_names = tuple(filter(lambda v: "/" in v, sorted(self.all_groups)))
group_path = data.draw(st.sampled_from(member_names), label="Group deletion target")
group_path = data.draw(
st.sampled_from(sorted(self.all_groups - {"", "/"})),
label="Group deletion target",
)
prefix, group_name = split_prefix_name(group_path)
note(f"Deleting group '{group_path=!r}', {prefix=!r}, {group_name=!r} using delete")
members = zarr.open_group(store=self.model, path=group_path).members(max_depth=None)
Expand All @@ -359,9 +359,7 @@ def delete_group_using_del(self, data: DataObject) -> None:
group = zarr.open_group(store=store, path=prefix)
group[group_name] # check that it exists
del group[group_name]
if group_path != "/":
# The root group is always present
self.all_groups.remove(group_path)
self.all_groups.remove(group_path)

# # --------------- assertions -----------------
# def check_group_arrays(self, group):
Expand Down