rl-institut / tier_spatial_planning

Part of the people Sun project
GNU Affero General Public License v3.0
4 stars 1 forks source link

Bug: Internal server error occurs when trying to download excel results #40

Open paulapreuss opened 1 month ago

paulapreuss commented 1 month ago

Full traceback:

pps_app           | [2024-07-23 07:46:28 +0000] [78] [ERROR] Exception in ASGI application
pps_app           | Traceback (most recent call last):
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
pps_app           |     result = await app(  # type: ignore[func-returns-value]
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
pps_app           |     return await self.app(scope, receive, send)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/fastapi/applications.py", line 271, in __call__
pps_app           |     await super().__call__(scope, receive, send)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/starlette/applications.py", line 118, in __call__
pps_app           |     await self.middleware_stack(scope, receive, send)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in __call__
pps_app           |     raise exc
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in __call__
pps_app           |     await self.app(scope, receive, _send)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
pps_app           |     raise exc
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
pps_app           |     await self.app(scope, receive, sender)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
pps_app           |     raise e
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
pps_app           |     await self.app(scope, receive, send)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/starlette/routing.py", line 706, in __call__
pps_app           |     await route.handle(scope, receive, send)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/starlette/routing.py", line 276, in handle
pps_app           |     await self.app(scope, receive, send)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/starlette/routing.py", line 66, in app
pps_app           |     response = await func(request)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/fastapi/routing.py", line 237, in app
pps_app           |     raw_response = await run_endpoint_function(
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
pps_app           |     return await dependant.call(**values)
pps_app           |   File "/src/fastapi_app/main.py", line 1245, in export_data
pps_app           |     excel_file = project_data_df_to_xlsx(input_parameters_df, energy_system_design, energy_flow_df, results_df,
pps_app           |   File "/src/fastapi_app/python/helper/project_data_to_excel.py", line 70, in project_data_df_to_xlsx
pps_app           |     nodes_df = nodes_df.drop(columns=['distribution_cost', 'parent'])
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/pandas/util/_decorators.py", line 311, in wrapper
pps_app           |     return func(*args, **kwargs)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/pandas/core/frame.py", line 4906, in drop
pps_app           |     return super().drop(
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/pandas/core/generic.py", line 4150, in drop
pps_app           |     obj = obj._drop_axis(labels, axis, level=level, errors=errors)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/pandas/core/generic.py", line 4185, in _drop_axis
pps_app           |     new_axis = axis.drop(labels, errors=errors)
pps_app           |   File "/opt/conda/envs/py38/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 6017, in drop
pps_app           |     raise KeyError(f"{labels[mask]} not found in axis")
pps_app           | KeyError: "['distribution_cost' 'parent'] not found in axis"
paulapreuss commented 1 month ago

Duplicating the project and downloading it after re-running seems to circumvent the issue