Module loading error after changes
After any changes inside my custom modules solara crashes when attemptin to reload them, if i stop the app and restart it runs without a problem. Changes just as simple as a new space will break the hot reloading capabilites. The call stack is showing there is an issue with the a key (module name) in the autorouting package. I also noticed that as im working with the app running it periodically reloads and crashes in the same manner.
6 Replies
Thanks you for letting us know.
Can you share the error?
Not a problem here is the callstack I am getting:
(venv) PS C:\Program\Process> solara run solara_main.py
Solara server is starting at http://localhost:8765
Traceback (mist recent call last):
File "C:\C:\Program\Process\venv\lib\site-packages\solara\server\app.py", line 319, in load_app_widget
widget, render_cotext = _run_app(
File "C:\C:\Program\Process\venv\lib\site-packages\solara\server\app.py", line 267, in _run_app
main_object = app_script.run()
File "C:\C:\Program\Process\venv\lib\site-packages\solara\server\app.py", line 199, in run
self._first_execute_app = self.execute()
File "C:\C:\Program\Process\venv\lib\site-packages\solara\server\app.py", line 116, in _execute
routes = [solara.autorouting._generate_route_path(self.path, first=True, initial_namespace=init)]
File "C:\C:\Program\Process\venv\lib\site-packages\solara\server\autorouting.py", line 507, in
_gerate_route_path
module = source_to_module(subpath, initial_namespace=initial_namespace)
File "C:\C:\Program\Process\venv\lib\site-packages\solara\server\autorouting.py", line 37, in
source_to_module
exec(ast, mod.dict)
File "C:\C:\Program\Process\solara_main.py", line 18 in <module>
from app.models.basemodel import BaseModel
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 925, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1423, in find_spec
File "<frozen importlib._bootstrap_external>", line 1389, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1252, in iter
File "<frozen importlib._bootstrap_external>", line 1239, in _recalculate
File "<frozen importlib._bootstrap_external>", line 1235, _get_parent_path
KeyError: 'app.models'
hmm, where is the app directory? (i.e. what is the absolute path of app/init.py) ?
Here is what my Root looks like:
Process/solara_main.py
Process/app/models/basemodel.py
Process/app/init.py
Process/models/init.py
Process/app/helpers/init.py
Process/app/helpers/helpers.py
I can kind of reproduce this when I don't add a
__init__.py
in app/models, then I get a keyerror for 'app'
could you try adding an __init__.py
file in that directory, otherwise it's a namespace package, and it seems that either python acts weird with that, or solara should remove some caches in python to fix this.
Either way, would be nice to get a confirmation is this workaround works for you.Let me give it a try a little later today and get back to you, thanks for the assistance!
This appears to have solved the initial refresh problem, that being said i've encountered and other issue which I will investigate. Thanks for the assistance