Endpoint für Auslastung einer Region #7

Open
opened 2025-01-09 18:26:33 +01:00 by dianigionath · 2 comments

Neuer Endpoint genau so aufgebaut wie @app.get("/property/{id}/capacities") aber für Regionen (-1,0,1...)
Würde dazu den bestehende @app.get("/region/{id}/capacities") zu @app.get("/region/{id}/properties/capacities") umbenennen und dafür den hier beschriebenen Endpoint @app.get("/region/{id}/capacities") nennen.

Neuer Endpoint genau so aufgebaut wie `@app.get("/property/{id}/capacities")` aber für Regionen (-1,0,1...) Würde dazu den bestehende `@app.get("/region/{id}/capacities")` zu `@app.get("/region/{id}/properties/capacities")` umbenennen und dafür den hier beschriebenen Endpoint `@app.get("/region/{id}/capacities")` nennen.
stoffelmauro was assigned by dianigionath 2025-01-09 18:26:44 +01:00
Poster
Collaborator

Bei mir kommen Fehlermeldungen:

INFO:     127.0.0.1:37032 - "GET /region/2/capacities HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/series.py", line 310, in _construct_series_with_fallbacks
    return constructor(name, values, strict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'int' object cannot be converted to 'PyString'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__
    raise exc
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/fastapi/routing.py", line 214, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2441, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 943, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/src/api/main.py", line 75, in region_capacities_data
    capacities = etl_rc.region_capacities(id)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/src/data/etl_region_capacities.py", line 36, in region_capacities
    df = pl.DataFrame(gridData)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/dataframe/frame.py", line 375, in __init__
    self._df = sequence_to_pydf(
               ^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/dataframe.py", line 460, in sequence_to_pydf
    return _sequence_to_pydf_dispatcher(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/functools.py", line 907, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/dataframe.py", line 600, in _sequence_of_sequence_to_pydf
    pl.Series(
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/series/series.py", line 289, in __init__
    self._s = sequence_to_pyseries(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/series.py", line 295, in sequence_to_pyseries
    return _construct_series_with_fallbacks(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/series.py", line 313, in _construct_series_with_fallbacks
    return PySeries.new_from_any_values(name, values, strict=strict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unexpected value while building Series of type String; found value of type Int64: 427

Hint: Try setting `strict=False` to allow passing data with mixed types.

Bei mir kommen Fehlermeldungen: ```bash INFO: 127.0.0.1:37032 - "GET /region/2/capacities HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/series.py", line 310, in _construct_series_with_fallbacks return constructor(name, values, strict) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'int' object cannot be converted to 'PyString' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__ await self.middleware_stack(scope, receive, send) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ raise exc File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ await self.app(scope, receive, _send) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__ await self.middleware_stack(scope, receive, send) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 735, in app await route.handle(scope, receive, send) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/routing.py", line 73, in app response = await f(request) ^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/fastapi/routing.py", line 301, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/fastapi/routing.py", line 214, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool return await anyio.to_thread.run_sync(func, *args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2441, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 943, in run result = context.run(func, *args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/src/api/main.py", line 75, in region_capacities_data capacities = etl_rc.region_capacities(id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/src/data/etl_region_capacities.py", line 36, in region_capacities df = pl.DataFrame(gridData) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/dataframe/frame.py", line 375, in __init__ self._df = sequence_to_pydf( ^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/dataframe.py", line 460, in sequence_to_pydf return _sequence_to_pydf_dispatcher( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/functools.py", line 907, in wrapper return dispatch(args[0].__class__)(*args, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/dataframe.py", line 600, in _sequence_of_sequence_to_pydf pl.Series( File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/series/series.py", line 289, in __init__ self._s = sequence_to_pyseries( ^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/series.py", line 295, in sequence_to_pyseries return _construct_series_with_fallbacks( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gio/Code/ConsultancyProject_2_ETL/etl/.pixi/envs/default/lib/python3.12/site-packages/polars/_utils/construction/series.py", line 313, in _construct_series_with_fallbacks return PySeries.new_from_any_values(name, values, strict=strict) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unexpected value while building Series of type String; found value of type Int64: 427 Hint: Try setting `strict=False` to allow passing data with mixed types. ```

Es funktioniert bei mir lokal. Muss das morgen überprüfen image

Es funktioniert bei mir lokal. Muss das morgen überprüfen ![image](/attachments/01c9183f-7fe4-4060-abde-603a3a8c7cc4)
101 KiB
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: stoffelmauro/ConsultancyProject_2_ETL#7
There is no content yet.