Skip to content

TESTS: don't force rectilinear config true in the test#3909

Open
ianhi wants to merge 2 commits intozarr-developers:mainfrom
ianhi:ian/stateful-chunks
Open

TESTS: don't force rectilinear config true in the test#3909
ianhi wants to merge 2 commits intozarr-developers:mainfrom
ianhi:ian/stateful-chunks

Conversation

@ianhi
Copy link
Copy Markdown
Contributor

@ianhi ianhi commented Apr 15, 2026

The new array strategy for stateful testing was ignoring the config setting and forcibly changing it - which gives no way for a downstream consumer to opt of out. This makes it respect the config. There is a small worry that now one of our strategies depends on a global state (potential cause of flakyiness) but I'm not really sure there's a clean way around that.

@dcherian

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Apr 15, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.08%. Comparing base (2fbd30a) to head (2e49ae3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3909      +/-   ##
==========================================
- Coverage   93.08%   93.08%   -0.01%     
==========================================
  Files          85       85              
  Lines       11230    11225       -5     
==========================================
- Hits        10454    10449       -5     
  Misses        776      776              
Files with missing lines Coverage Δ
src/zarr/testing/strategies.py 92.91% <100.00%> (-0.13%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

draw: st.DrawFn, *, shape: tuple[int, ...]
) -> RegularChunkGridMetadata | RectilinearChunkGridMetadata:
"""Generate either a RegularChunkGridMetadata or RectilinearChunkGridMetadata.
Depending on whether the config is set (WARN: look here if we get a flaky error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

huh?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That was all me - so any confusion is my fault.

This makes this strategy dependent on global state, i.e. a recipe for a flaky strategy down the line. I wanted to leave a note for the future in case that happens. Don't think I really hit the mark here though

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok let's write in a longer comment then :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
Depending on whether the config is set (WARN: look here if we get a flaky error)
This strategy depends on the global state of the config having rectilinear chunk grids enabled or not.
This means that it may be a possible source of a hypothesis FlakyStrategy error due dependence
on global state. However, in practice this seems unlikely to happen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dcherian how is that?

@d-v-b
Copy link
Copy Markdown
Contributor

d-v-b commented Apr 15, 2026

i'm confused -- don't we want to turn on rectilinear chunks explicitly before this test?

@d-v-b
Copy link
Copy Markdown
Contributor

d-v-b commented Apr 15, 2026

or is the idea to leave that detail to the configuration at test time

@d-v-b
Copy link
Copy Markdown
Contributor

d-v-b commented Apr 15, 2026

also... we should rethink putting the config check inside the chunk grid class itself. If someone wants to import the class and construct it, that should be allowed.

@ianhi
Copy link
Copy Markdown
Contributor Author

ianhi commented Apr 15, 2026

i'm confused -- don't we want to turn on rectilinear chunks explicitly before this test?

Yes for the zarr-python tests, but not within the the strategy. The strategy is public API and might be run on a system that doesn't support rectilinear chunks. For example icechunk format 1 just straight up doesn't support it, so I need to be able to turn it off via the config and have that be respected.

In the actual zarr-python stateful tests it gets turned on by default:

@pytest.fixture(autouse=True)
def _enable_rectilinear_chunks() -> Generator[None, None, None]:
"""Enable rectilinear chunks since strategies may generate them."""
with zarr.config.set({"array.rectilinear_chunks": True}):
yield

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs release notes Automatically applied to PRs which haven't added release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants