-
Notifications
You must be signed in to change notification settings - Fork 878
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
fix: Initialize model _steps and _time during __new__ #2026
Conversation
Tested manually by running https://github.com/projectmesa/mesa-examples/blob/34e92d2c29a99e950bc17f7cac860c5b13156b21/examples/bank_reserves/batch_run.py without model |
Performance benchmarks:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, quick fix.
This is to retain backward compatibility with Mesa 2.1.x behavior where a model `super().__init__()` is not necessary.
cc: @EwoutH for patch release. |
Will try to do tonight, and will make screen recording so others can do it as well. Only this PR needs to be included right? |
Could someone write a 3-sentence summary with which problem this fixes for the 2.2.5 release notes? |
The problem is that #1942 added |
@EwoutH amended PR description. You may pick whichever version you prefer. |
@EwoutH I know about doing the cherry picking and adding a tag for a release, but I'm not sure about the auto-draft for the release note. Still pending a release checklist (which has more automation than in the past) from your end. |
Checklist is here: #1917 (comment) Could you also convert https://github.com/projectmesa/mesa/blob/main/CONTRIBUTING.rst to markdown? Then I will add the checklist to it. Go ahead of the patch release. Make sure to cherry pick from |
I looked at the checklist. Step 1 definitely can be scripted in a code as an automated check. Step 2 can be automated as well (API call with draft boolean). Step 3 can be input as a CLI flag. And so on. |
I made the script for step 1 with the help of ChatGPT: $ python fetch_unlabeled_prs.py
PR #2039: tests: Speed up test_batch_run - Merged at: 2024-02-16T12:58:38Z
PR #2029: [pre-commit.ci] pre-commit autoupdate - Merged at: 2024-02-05T22:57:38Z Will update once I have automated the rest. |
# TODO: Remove these 2 lines just before Mesa 3.0 | ||
obj._steps = 0 | ||
obj._time = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remind me why we need to remove these lines? Seems like the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because they are already specified in __init__
. This was a hack to people who forget to super().__init__
their model.
The problem is that #1942 added
_steps
and_time
during model__init__
._steps
is used in the data collector andbatch_run
, so that both support a scheduler-less model implementation. #1942 broke backward compatibility because it requiressuper().__init__()
inside user's model__init__
.This is to retain backward compatibility with Mesa 2.1.x behavior where a model
super().__init__()
is not necessary.