-
Notifications
You must be signed in to change notification settings - Fork 917
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
Visualization Tutorial #2535
Comments
I am unable to reproduce this problem on my machine using MESA 3.1, and the code provided in the docs folder of this repo. My hunch (combined with the info on elements) is that the version of the MoneyModel you are using is not correct. I have class MoneyModel(mesa.Model):
"""A model with some number of agents."""
def __init__(self, n=10, width=10, height=10, seed=None):
"""Initialize a MoneyModel instance.
Args:
N: The number of agents.
width: width of the grid.
height: Height of the grid.
"""
super().__init__(seed=seed)
self.num_agents = n
self.grid = mesa.space.MultiGrid(width, height, True) Where did you get the code for the money model from? Did you take it from the introductory tutorial? |
Yes, I am getting the error from my reproduced MoneyModel code and the code copied from the end of the Introductory Tutorial. The code below is what I was using for the model.
class MoneyModel(mesa.Model):
"""A model with some number of agents."""
def __init__(self, n, width, height, seed=None):
super().__init__(seed=seed)
self.num_agents = n
self.grid = mesa.space.MultiGrid(width, height, True)
self.running = True
# Create agents
for _ in range(self.num_agents):
a = MoneyAgent(self)
# Add the agent to a random grid cell
x = self.random.randrange(self.grid.width)
y = self.random.randrange(self.grid.height)
self.grid.place_agent(a, (x, y))
self.datacollector = mesa.DataCollector(
model_reporters={"Gini": compute_gini},
agent_reporters={"Wealth": "wealth", "Steps_not_given": "steps_not_given"},
)
def step(self):
self.datacollector.collect(self)
self.agents.shuffle_do("move")
self.agents.shuffle_do("give_money")
|
Ok, just change the signature to the one from my snippet and you should be good to go. so use The underlying issue that needs to be fixed is to to update the introductory tutorial to use keywords only on all model classes. |
Thanks for reporting this issue and finding the root cause of it. I think a more structural solution, would be to let SolaraViz give a proper warning that notifies the user that not all arguments are keyword arguments. |
#2510 is adding this warning. |
Does it say anything in the bar? This is most likely an issue in solara/javascript. I have seen others with similar issues but I so far haven't been able to figure out what is going on. |
@nicolas-starck and @tleung24 That is a jupyter version issue; you need to update your version of jupyter |
@tpike3 - I just updated to jupyterlab 4.3.2 and see the same behavior. |
HMMM @nicolas-starck can you share your iypthon I am 90% sure this is a dependency issue, I am just hoping it is not a Mac issue. |
I am on a mac and for me, everything works fine. So, it can work on a. mac. |
@tpike3 - here are the current versions of those packages in my environment. iypthon - 8.27.0 |
Ahhh got it, now I remember I need to document this. You are in the pre-release version of ipyvue and ipvuetify You want to uninstall and then use ipyvue ~1.11.2 Not sure this is what you did but if you install Mesa pre-release and dont have solara it will install the pre-release dependencies (ipyvue and ipyvuetify) as well causing this issue.
|
Can we pin those dependencies Also @maartenbreddels is this incompatibility a known issue over at Solara? |
Yes we should do that, just need to remember to undo it at some point; there has to be someway to add a dependency and even docker report to our CI/CD. Of course the trick will be to not just ignore it when we get an alert :) -- never enough time in the day |
@tpike3 - thanks for the suggestion! I was able to get it running with the following combination of packages: ipyvue - 1.11.2 |
Partially addressed in #2510 still need to update pyproject.toml |
I am also having an issue running the visualization I get an import error: Do I have a wrong version of something? |
Could you start with updating to the latest Mesa version? (3.1.1) |
With Mesa 3.1.1 I still have the same problem |
Those are pre-releases, which you should only get with |
When running the Visualization Tutorial for "Latest" with Mesa 3.1.0, the basic dashboard throws a ValueError for a missing model parameter - "Missing required model parameter: n".
Expected behavior
The expected behavior was the creation of the embedded page in the Jupyter Lab environment to interact with the MoneyModel.
To Reproduce
I am using the provided code for the MoneyModel, MoneyAgent, and compute_gini provided in the Introductory Tutorial in the "Additional agent reporter" section with the provided code from Part 1 of the Visualization Tutorial in a Jupyter Lab environment.
Additional context
I am running Jupyter Lab 4.2.5 on MacOS Sequoia 15.1.1
The text was updated successfully, but these errors were encountered: