Skip to content
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

Open
nicolas-starck opened this issue Dec 6, 2024 · 22 comments
Open

Visualization Tutorial #2535

nicolas-starck opened this issue Dec 6, 2024 · 22 comments
Labels
docs Release notes label good first issue

Comments

@nicolas-starck
Copy link

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".

image

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

@quaquel
Copy link
Member

quaquel commented Dec 6, 2024

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?

@nicolas-starck
Copy link
Author

nicolas-starck commented Dec 6, 2024 via email

@quaquel
Copy link
Member

quaquel commented Dec 6, 2024

Ok, just change the signature to the one from my snippet and you should be good to go.

so use def __init__(self, n=10, width=10, height=10, seed=None): instead of def __init__(self, n, width, height, seed=None).

The underlying issue that needs to be fixed is to to update the introductory tutorial to use keywords only on all model classes.

@quaquel quaquel added docs Release notes label good first issue labels Dec 6, 2024
@EwoutH
Copy link
Member

EwoutH commented Dec 6, 2024

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.

@quaquel
Copy link
Member

quaquel commented Dec 6, 2024

#2510 is adding this warning.

@tleung24
Copy link

tleung24 commented Dec 6, 2024

Screenshot 2024-12-06 141934

I am currently encountering the same issue as originally mentioned. I implemented the recommended change to def__init__ which fixed the error but is not giving me the expected output. My output is just the blank white bar at the bottom.

Versions I'm running:
MESA 3.1.0
Windows 11
Visual Studio Code 1.88.1

@quaquel
Copy link
Member

quaquel commented Dec 6, 2024

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
Copy link
Author

The offered solution worked to resolve the ValueError, however I am also seeing an empty cell output now that the code is executing. If this is likely something distinct, we can open a new issue for it.

image

@tpike3
Copy link
Member

tpike3 commented Dec 7, 2024

@nicolas-starck and @tleung24 That is a jupyter version issue; you need to update your version of jupyter

@nicolas-starck
Copy link
Author

@tpike3 - I just updated to jupyterlab 4.3.2 and see the same behavior.

image

@tpike3
Copy link
Member

tpike3 commented Dec 8, 2024

@tpike3 - I just updated to jupyterlab 4.3.2 and see the same behavior.

image

HMMM @nicolas-starck can you share your

iypthon
ipyvue
ipvuetify
and solara version

I am 90% sure this is a dependency issue, I am just hoping it is not a Mac issue.

@quaquel
Copy link
Member

quaquel commented Dec 8, 2024

I am on a mac and for me, everything works fine. So, it can work on a. mac.

@nicolas-starck
Copy link
Author

@tpike3 - here are the current versions of those packages in my environment.

iypthon - 8.27.0
ipyvue - 3.0.0a4
ipyvuetify - 3.0.0a2
solara - 1.42.0

@tpike3
Copy link
Member

tpike3 commented Dec 8, 2024

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
ipyvuetify ~1.2.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.

@tpike3 - here are the current versions of those packages in my environment.

iypthon - 8.27.0 ipyvue - 3.0.0a4 ipyvuetify - 3.0.0a2 solara - 1.42.0

@EwoutH
Copy link
Member

EwoutH commented Dec 8, 2024

Can we pin those dependencies <3 in our pyproject.toml?

Also @maartenbreddels is this incompatibility a known issue over at Solara?

@tpike3
Copy link
Member

tpike3 commented Dec 8, 2024

Can we pin those dependencies <3 in our pyproject.toml?

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

@nicolas-starck
Copy link
Author

@tpike3 - thanks for the suggestion! I was able to get it running with the following combination of packages:

ipyvue - 1.11.2
ipyvuetify - 1.10.0
jupyter lab - 4.2.6 (downgraded due to dependency errors with the other packages)

@tpike3
Copy link
Member

tpike3 commented Dec 9, 2024

Partially addressed in #2510 still need to update pyproject.toml

@renateevr
Copy link

I am also having an issue running the visualization
I have version:
mesa: 3.0.0
ipyvue: 1.11.2
ipyvuetify: 1.1.10
Solara: 1.42.0
Numpy: 1.26.4
Pandas: 2.2.3

I get an import error:
1 from mesa.visualization import (
ImportError: cannot import name 'make_plot_measure' from 'mesa.visualization'

Do I have a wrong version of something?

@EwoutH
Copy link
Member

EwoutH commented Dec 18, 2024

Could you start with updating to the latest Mesa version? (3.1.1)

@renateevr
Copy link

With Mesa 3.1.1 I still have the same problem

@maartenbreddels
Copy link

Can we pin those dependencies <3 in our pyproject.toml?

Also @maartenbreddels is this incompatibility a known issue over at Solara?

Those are pre-releases, which you should only get with pip install --pre, no need to pin (I consider this a user error). But it's good to know it's not working, because most thing should work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Release notes label good first issue
Projects
None yet
Development

No branches or pull requests

7 participants