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

App fails to start with 'NoneType' object has no attribute 'search' #20

Open
mfisher87 opened this issue Jan 11, 2025 · 2 comments · Fixed by #22
Open

App fails to start with 'NoneType' object has no attribute 'search' #20

mfisher87 opened this issue Jan 11, 2025 · 2 comments · Fixed by #22
Labels
bug Something isn't working

Comments

@mfisher87
Copy link
Member

mfisher87 commented Jan 11, 2025

Running solara run vegetation/app.py fails for me! 😭

Traceback snippet:

  File "/home/robatt/Projects/dse/mesa_abm_poc/vegetation/patch/space.py", line 168, in get_elevation_from_stac
    items_generator = self.pystac_client.search(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'search'

ERROR:    Application startup failed. Exiting.
Full log $ pixi run vegetation ✨ Pixi task (vegetation): solara run vegetation/app.py Solara server is starting at http://localhost:8765 /home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/IPython/core/interactiveshell.py:937: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv. warn( No local cache found, downloading elevation from STAC Collecting STAC Items ERROR: Traceback (most recent call last): File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/starlette/routing.py", line 693, in lifespan async with self.lifespan_context(app) as maybe_state: File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/starlette/routing.py", line 569, in __aenter__ await self._router.startup() File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/starlette/routing.py", line 672, in startup handler() File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/solara/server/starlette.py", line 573, in on_startup appmod.ensure_apps_initialized() File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/solara/util.py", line 345, in wrapper return_value = f() ^^^ File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/solara/server/app.py", line 524, in ensure_apps_initialized app.init() File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/solara/server/app.py", line 103, in init app = self._execute() ^^^^^^^^^^^^^^^ File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/solara/server/app.py", line 150, in _execute routes = [solara.autorouting._generate_route_path(self.path, first=True, initial_namespace=initial_namespace)] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/solara/autorouting.py", line 525, in _generate_route_path module = source_to_module(subpath, initial_namespace=initial_namespace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/robatt/Projects/dse/mesa_abm_poc/.pixi/envs/default/lib/python3.11/site-packages/solara/autorouting.py", line 39, in source_to_module exec(ast, mod.__dict__) File "/home/robatt/Projects/dse/mesa_abm_poc/vegetation/app.py", line 84, in model = Vegetation(bounds=TST_JOTR_BOUNDS) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/robatt/Projects/dse/mesa_abm_poc/vegetation/patch/model.py", line 228, in __init__ self.space.get_elevation() File "/home/robatt/Projects/dse/mesa_abm_poc/vegetation/patch/space.py", line 111, in get_elevation elevation = self.get_elevation_from_stac() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/robatt/Projects/dse/mesa_abm_poc/vegetation/patch/space.py", line 168, in get_elevation_from_stac items_generator = self.pystac_client.search( ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'search'

ERROR: Application startup failed. Exiting.

@mfisher87 mfisher87 added the bug Something isn't working label Jan 11, 2025
@GondekNP
Copy link
Contributor

Thanks for jumping in Matt!

I think this is happening because the check at here at line 76:

self.pystac_client = None
if not LOCAL_STAC_CACHE_FSTRING:
self.pystac_client = PystacClient.open(
DEM_STAC_PATH, modifier=planetary_computer.sign_inplace
)

The issue is that if the LOCAL_STAC_CACHE_FSTRING is populated, it doesn't instantiantiate pystac client. But what we really want is, if the LOCAL_STAC_CACHE_FSTRING is populated and the relevant is cache is there, don't instantiate pystac and instead grab the cache.

Truthfully this whole thing could use another pair of eyes - the elevation layer was the first one I set up for development and so some of the logic of get_elevation is probably meant to be in __init__ due to a fast and loose refactor a while back...

@mfisher87
Copy link
Member Author

I'll take a look and open another PR! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants