Skip to content

Stabilize experimental Cell Space as mesa.discrete_space #2610

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

Merged
merged 14 commits into from
Feb 10, 2025

Conversation

quaquel
Copy link
Member

@quaquel quaquel commented Jan 10, 2025

As part of the stabilization of cell spaces, this PR moves everything to mesa.discrete_space. I have kept the mesa.experimental.cell_space, which should continue to function but will issue a deprecation warning.

I updated all tests and all examples that use cell spaces.

@tpike3
Copy link
Member

tpike3 commented Jan 11, 2025

I think the deprecation warning needs to be updated, from the build failure in test examples it is saying

"DeprecationWarning: you are importing from mesa.discrete_space, all cell spaces have been moved to mesa.discrete_space"

shouldn't this be "DeprecationWarning: you are importing from mesa.experimental.cell_space, all cell spaces have been moved to mesa.discrete_space"

Copy link
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

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

@quaquel Thanks for doing this!

Before you merge could you update the tests or the pyproject so the build isn't failing with the deprecation warning.

@EwoutH
Copy link
Member

EwoutH commented Jan 12, 2025

I would like to take a good look at namespaces, also to make it futureproof for other network spaces etc. Hopefully I can do that Tuesday.

Also we should split off a 3.1 maintenance branch before merging.

@quaquel
Copy link
Member Author

quaquel commented Jan 12, 2025

Before you merge could you update the tests or the pyproject so the build isn't failing with the deprecation warning.

Yes, this is very much on my list of things to do before merging.

I would like to take a good look at namespaces, also to make it futureproof for other network spaces etc

No idea what you mean with this. There is a network in the current mesa.spaces, and one in mesa.experimental.cell_spaces. These both assume that the network structure is fixed. So there is room for a changing network space (although I am not sure about a real use case for it).

@quaquel
Copy link
Member Author

quaquel commented Jan 12, 2025

build/examples is now failing on the deprecation warning as intended. This is running mesa-examples. All other tests and builds work fine.

@tpike3
Copy link
Member

tpike3 commented Jan 13, 2025

build/examples is now failing on the deprecation warning as intended. This is running mesa-examples. All other tests and builds work fine.

If possible, can you ensure the build passes, just because it may hide other issues, pytest should be able to handle it either

in the test_examples with something like

def test_with_deprecation():
    with pytest.warns(DeprecationWarning, match="you are importing from mesa.experimental.cell_space, all cell spaces have been moved to mesa.discrete_space"):
        warnings.warn("you are importing from mesa.experimental.cell_space, all cell spaces have been moved to mesa.discrete_space", DeprecationWarning)

or globally in the pyproject.toml

[pytest]
filterwarnings =
    ignore:.*some specific warning message.*:DeprecationWarning

@EwoutH
Copy link
Member

EwoutH commented Jan 18, 2025

Currently the from mesa.discrete_space.discrete_space import DiscreteSpace feels a bit weird. Maybe it makes more sense to keep the top level space named cell_space, it would make it very distinct and the concept of cell is intuitive.

Otherwise, if you, Tom and other @projectmesa/maintainers agree, don't let me block you.

@quaquel
Copy link
Member Author

quaquel commented Jan 18, 2025

you can actually use a shorter import: from mesa.discrete_space import DiscreteSpace.

@quaquel
Copy link
Member Author

quaquel commented Jan 19, 2025

@tpike3: the failing action is the one that runs mesa-examples. So, this build runs all examples in the mesa-examples repo. All tests on the mesa repo itself, including the examples that ship with mesa itself, pass without problems. Our most complete integration test is erroring and only because of a deprecation warning.

About the only thing I see that can be done to get the built to pass is to explicitly ignore the deprecation warnings by changing this line in built_lint.yml. Let me know what you think about that.

@tpike3
Copy link
Member

tpike3 commented Jan 19, 2025

@tpike3: the failing action is the one that runs mesa-examples. So, this build runs all examples in the mesa-examples repo. All tests on the mesa repo itself, including the examples that ship with mesa itself, pass without problems. Our most complete integration test is erroring and only because of a deprecation warning.

About the only thing I see that can be done to get the built to pass is to explicitly ignore the deprecation warnings by changing this line in built_lint.yml. Let me know what you think about that.

Works for me, thanks!

@quaquel
Copy link
Member Author

quaquel commented Jan 19, 2025

Ok, all tests now pass correctly so this is ready to be merged. However, I want to hold of for a short while still. (1). we need to first create a 3.1 maintenance branch, and (2) I ran into a small bug in hexgrid. I know how to resolve the bug, which is due to mixing up (row, column) indexing in hexgrid and (x, y) coordinates when visualizing.

Copy link
Member

@EwoutH EwoutH left a comment

Choose a reason for hiding this comment

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

Thanks for all your work so far. Perfect is the enemy of done, once it's in we can start updating the example models and tutorial. Let's drive this home!

@quaquel quaquel added experimental Release notes label deprecation When a new deprecation is introduced labels Feb 10, 2025
@quaquel quaquel merged commit 6f71fcd into projectmesa:main Feb 10, 2025
11 checks passed
@quaquel quaquel deleted the discrete_space branch February 12, 2025 18:45
@EwoutH EwoutH added feature Release notes label and removed experimental Release notes label labels Apr 25, 2025
Copy link

coderabbitai bot commented Apr 25, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@EwoutH EwoutH changed the title Move mesa.experimental_cell to mesa.discrete_space Stabilize experimental Cell Space as mesa.discrete_space Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation When a new deprecation is introduced feature Release notes label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants