Running a file vs running a module
Hello! I am trying to get solara up and running for use with mesa but am having some issues. I structured my code as a python package and would like to be able to run
solara run my-package
(or even better, just my-package
) in the cli to start the server. Currently, running solara run __main__.py
works, but for some reason running solara run my-package
does not. Adding a print statement to __main__.py
, I can see it being printed but solara does not appear to be able to find the route:
My __main__.py
looks like this:
Is there a way to just "run" the page, similar to Flask's app.run()
and if not, how can I make the solara
CLI tool pick up the page even when running the module instead of the __main__.py
directly? Thanks5 Replies
@Razzle I work on mesa and you can runn and app form the command line using
solara run <name>.py
and exmaple is located in the mesa example repo boltzmann_wealth_experimentalGitHub
mesa-examples/examples/boltzmann_wealth_model_experimental at main ...
Seminal agent-based models developed using Mesa. Contribute to projectmesa/mesa-examples development by creating an account on GitHub.
Thank you! I understand that, I am looking for how to integrate this "single-file" approach into a python pacakge, so that I don't have to ship the python file to the end user, and can just instruct them to run
pip install mypackage
, followied by solara run mypackage
Did you try to put it in
my-package/__init__.py
?Yes, I still get a
Page not found by Solara router
:(if solara run solara.website.pages runs, then you should check what the difference is.
One thing I wonder about is if you also have a directory my-package?
Although, that should give you the same result.
Just as a sanity check, please define a
Page
component (since in the above i see a page element being used, which seems to be the only difference I think)