Skip to content

fix(compatibility): 🐛 Introduce mesa-geo compatibility handling and regression tests#148

Merged
SongshGeo merged 1 commit intomasterfrom
dev
Apr 7, 2026
Merged

fix(compatibility): 🐛 Introduce mesa-geo compatibility handling and regression tests#148
SongshGeo merged 1 commit intomasterfrom
dev

Conversation

@SongshGeo
Copy link
Copy Markdown
Collaborator

@SongshGeo SongshGeo commented Apr 7, 2026

This commit adds a new module mesa_raster_compat.py to manage compatibility between different versions of mesa and mesa-geo, addressing initialization differences in raster layers. It also updates the PatchModule to safely handle transformations and cell synchronization. Additionally, a new CI job is introduced to test compatibility across minimum and latest versions of these dependencies, along with regression tests to ensure stability in raster initialization. Documentation is updated to reflect these changes and clarify dependency management.

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated Python version requirement to 3.11+.
    • Updated minimum versions for mesa, mesa-geo, pendulum, and other dependencies.
    • Added guidance on mesa/mesa-geo compatibility handling.
  • Chores

    • Added CI job for testing dependency compatibility across minimum and latest package versions.
    • Enhanced internal compatibility handling for spatial functionality.

…egression tests

This commit adds a new module `mesa_raster_compat.py` to manage compatibility between different versions of `mesa` and `mesa-geo`, addressing initialization differences in raster layers. It also updates the `PatchModule` to safely handle transformations and cell synchronization. Additionally, a new CI job is introduced to test compatibility across minimum and latest versions of these dependencies, along with regression tests to ensure stability in raster initialization. Documentation is updated to reflect these changes and clarify dependency management.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

This PR introduces dependency compatibility handling for mesa and mesa-geo packages. It adds a new CI job testing minimum and latest supported versions, creates a compatibility module with version-tolerant helper functions, updates PatchModule initialization logic, documents new version constraints, and includes regression tests for raster initialization across versions.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/tests.yml
Added deps-compat job that tests against minimum (mesa==3.1.0, mesa-geo==0.9.1) and latest upstream versions using a two-leg matrix, running targeted regression tests on patch, nature, and foundation modules.
Compatibility Module
abses/space/mesa_raster_compat.py
New module providing two version-tolerant helpers: raster_base_update_transform() applies RasterBase affine transform updates, and maybe_sync_cell_xy() conditionally synchronizes cell coordinates while gracefully handling missing attributes across mesa-geo versions.
PatchModule Integration
abses/space/patch.py
Added _update_transform() method invoking compatibility helpers, and refactored __getattr__ to avoid recursive initialization issues by using object.__getattribute__ for early-stage attribute access.
Documentation Updates
docs/home/dependencies.md, docs/home/dependencies.zh.md
Updated Python requirements (>=3.11,<3.14), tightened dependency bounds (hydra-core, mesa, mesa-geo, xarray, pendulum, geopandas), and added new "Mesa / mesa-geo compatibility" sections explaining lower-bound declarations and code-based initialization handling.
Project Configuration
pyproject.toml
Added comment clarifying that mesa/mesa-geo dependency bounds are intentionally loose and that raster initialization differences are handled in code and CI.
Regression Tests
tests/api/test_patch_mesa_compat.py
New test module with four parametrized tests validating raster initialization order, transform updates, cell synchronization without stored cells, and various grid shapes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Through mesa's versions we now hop and dance,
From 3.1.0 to the latest chance,
With patches and rasters in perfect stride,
Our rabbit's verified with utmost pride,
Compatibility tests by our side! 🌾

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective: introducing mesa-geo compatibility handling and regression tests. It's specific, concise, and clearly reflects the primary changes across the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/home/dependencies.md`:
- Line 12: Update the dependency table row for the fiona entry so the
description uses the correct abbreviation punctuation: change "For reading and
writing vector data (shapefiles, etc)" to "For reading and writing vector data
(shapefiles, etc.)" in the table row containing "fiona" and its version ">1.8".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 078f32de-f3cd-4e0f-b3a0-c8c5b33f4282

📥 Commits

Reviewing files that changed from the base of the PR and between 3df8c56 and c92eefd.

📒 Files selected for processing (7)
  • .github/workflows/tests.yml
  • abses/space/mesa_raster_compat.py
  • abses/space/patch.py
  • docs/home/dependencies.md
  • docs/home/dependencies.zh.md
  • pyproject.toml
  • tests/api/test_patch_mesa_compat.py

| mesa | ">=3.1.0" | Agent-based scheduling and core utilities |
| mesa-geo | ">=0.9.1" | Spatially explicit layers and raster support |
| xarray | ">=2023" | To work with labelled multi-dimensional arrays |
| fiona | ">1.8" | For reading and writing vector data (shapefiles, etc) |
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix punctuation in the dependency table description.

Line 12 should use etc. instead of etc for correct abbreviation punctuation.

Suggested edit
-| fiona         | ">1.8"            | For reading and writing vector data (shapefiles, etc) |
+| fiona         | ">1.8"            | For reading and writing vector data (shapefiles, etc.) |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| fiona | ">1.8" | For reading and writing vector data (shapefiles, etc) |
| fiona | ">1.8" | For reading and writing vector data (shapefiles, etc.) |
🧰 Tools
🪛 LanguageTool

[style] ~12-~12: In American English, abbreviations like “etc.” require a period.
Context: ...ng and writing vector data (shapefiles, etc) | | rioxarray | ">=0.13" ...

(ETC_PERIOD)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/home/dependencies.md` at line 12, Update the dependency table row for
the fiona entry so the description uses the correct abbreviation punctuation:
change "For reading and writing vector data (shapefiles, etc)" to "For reading
and writing vector data (shapefiles, etc.)" in the table row containing "fiona"
and its version ">1.8".

@SongshGeo SongshGeo merged commit 877ea17 into master Apr 7, 2026
15 of 16 checks passed
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