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

Run directly from Python script #11

Open
EwoutH opened this issue Dec 11, 2023 · 12 comments
Open

Run directly from Python script #11

EwoutH opened this issue Dec 11, 2023 · 12 comments

Comments

@EwoutH
Copy link
Contributor

EwoutH commented Dec 11, 2023

Instead of using

solara run script.py

would it be possible to run directly from the Python script? Something like:

page = MesaInteractive()
page.run()

For some applications it would be nice to run the Python script directly instead of having to run it from the terminal.

@zain581
Copy link

zain581 commented Apr 22, 2024

@EwoutH wanted to work on this issue .

@EwoutH
Copy link
Contributor Author

EwoutH commented Apr 22, 2024

@zain581 that would be greatly appreciated, go ahead!

Edit: Note that this issue is the same for the main Mesa visualisation. Maybe better to provide an implementation in that repo first.

@zain581
Copy link

zain581 commented Apr 23, 2024

@EwoutH thanks for your kind reply will start working on it and let you know when got something .

@zain581
Copy link

zain581 commented Apr 24, 2024

@EwoutH while running the solara run app.py got this error: "the agent is not a list".

def get_agent_data_from_coord_iter(agents_per_coordinate):
    for agents, (x, y) in agents_per_coordinate:
        if agents:  # Checking if the list is non-empty
            for agent in agents:
                agent_data = json.loads(
                    json.dumps(agent.__dict__, skipkeys=True, default=str)
                )
                agent_data["x"] = x
                agent_data["y"] = y
                agent_data.pop("model", None)
                agent_data.pop("pos", None)
                yield agent_data

Screenshot from 2024-04-24 07-55-30

@EwoutH
Copy link
Contributor Author

EwoutH commented Apr 24, 2024

Can you fix this issue first in Mesa itself? This repo is a bit outdated.

The new Mesa visualization is in https://github.com/projectmesa/mesa/blob/main/mesa/experimental/jupyter_viz.py

@zain581
Copy link

zain581 commented Apr 24, 2024

OKAY ,i wanted to ask is it possible when the agent running script is done then we will automatically visualization the result but not running solara command but the agent class .

@EwoutH
Copy link
Contributor Author

EwoutH commented Apr 24, 2024

Sorry, what do you mean exactly?

@zain581
Copy link

zain581 commented Apr 25, 2024

running the code from the class solara run app.py using app.run() or app.page()

@EwoutH
Copy link
Contributor Author

EwoutH commented Apr 25, 2024

Sorry, I still don’t understand your question or point 😅

@zain581
Copy link

zain581 commented Apr 26, 2024

okay ,what i am trying to say that we can run the same process of solara run app.py but using a class in main

@EwoutH
Copy link
Contributor Author

EwoutH commented Apr 26, 2024

Sounds good!

@EwoutH
Copy link
Contributor Author

EwoutH commented May 15, 2024

@zain581 would you still like to work on this? If so, please check out: https://github.com/projectmesa/mesa/tree/main/mesa/visualization

I would really love to have that feature in there!

CC @rht

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

No branches or pull requests

2 participants