Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:46
    HarshKhatore closed #3070
  • 16:46
    HarshKhatore commented #3070
  • 16:38
    Kludex commented #3070
  • 16:37
    Kludex commented #3070
  • 16:32
    HarshKhatore edited #3070
  • 16:24
    HarshKhatore labeled #3070
  • 16:24
    HarshKhatore opened #3070
  • 14:25
    github-actions[bot] commented #3069
  • 14:23
    codecov[bot] commented #3069
  • 14:21
    duarteocarmo opened #3069
  • 07:43
    ZimmerHao commented #2452
  • 03:29
    Kludex commented #1476
  • Apr 10 21:20
    flaviorangel commented #1089
  • Apr 10 21:01
    laanak08 commented #1018
  • Apr 10 21:01
    laanak08 commented #1018
  • Apr 10 21:00
    laanak08 commented #1018
  • Apr 10 21:00
    laanak08 commented #1018
  • Apr 10 20:59
    laanak08 commented #1018
  • Apr 10 20:15
    PrettyWood commented #1870
  • Apr 10 19:42
    laanak08 commented #1018
Marcelo Trylesinski
@Kludex
This has already been discussed on some issues and I have a PR on draft about it
There's a blocking point that I can't do anything about: swagger ui doesn't support openapi 3.1 yet
Alex Grönholm
@agronholm
@gautam-ergo the modern way would be to use OpenTelemetry, yes?
Anthony Reeves
@Anthoneeves_twitter
Hello! I'm using FastAPI on Google Cloud Run and have a question about dependencies. I currently use a dependency with yield to get a database session and close it after a request, but the session is closed AFTER the response has been delivered, which is great for most cases. Unfortunately, Cloud Run stipulates that no work should be done after the response has been delivered. Is there a way I can have the database session closed BEFORE the response has been delivered without doing this manually?
Nathan Zimmerman
@moradology
@Kludex thank you for the update
Gautam
@gautam-ergo

@agronholm Thanks for responding, I did end up finding OpenTelemetry but unfortunately no versions of azure-monitor-opentelemetry-exporter match >1.0.0-beta.3,<2.0.0, opentelemetry-instrumentation-fastapi (>=0.19b0,<0.20) is incompatible with azure-monitor-opentelemetry-exporter (>=1.0.0-beta.3,<2.0.0)

FastAPI Instrumentation
Azure Monitor

Not sure if I am looking at the right place. Thoughts ?

Thanks

Alex Grönholm
@agronholm
1.0.0 is fresh out of the oven so not all the plugins have been updated I suppos
you just need to wait (or contribute, if they allow that)
Gautam
@gautam-ergo

1.0.0 is fresh out of the oven so not all the plugins have been updated I suppos

Will try posting on their GH

Matt Gilene
@mdgilene

I need some help. I am running a uvicorn/fastapi app. Inside the "startup" event I create several infinite background tasks using loop.create_task. However, when sending the server a KeyboardInterrupt the server process exits however it appears as though the background tasks are not being killed since the app does not release control of the terminal. The only way to fully exit is to send the PID a kill signal.

I don't know if it matters but the background tasks are essentially running a confluent-kafka-python consumer loop. I.e.

while True:
    msg = consumer.poll(1)
    # ... processs messages
4 replies
Mariel García
@Garcia22Mariel_twitter
I need help deploying a fastapi project into open-shift. Which steps should I follow in order to get this done?
1 reply
iman bhlool
@ibhlool7_gitlab
Hello everybody
Is there possible to use DI in exception_handler?
for example:
@app.exception_handler(RequestValidationError)
async def exception_handler(_: Request, exception: RequestValidationError,
                            service: Foo = Depends()) -> Response:
Marcelo Trylesinski
@Kludex
no
Mahtab Alam
@alam-mahtab
Hello community,
i want to workon razorpay payment gateway, i want your help
mohammad alipour
@mohammadalipour94_gitlab
hi guys
could you help me to find an example for validating jwt with external provider implemented by opened connect and OAuth 2
chandrasekharsimhala
@chandrasekharsimhala
Hi Team, I want to use Graphql features in Fastapi... As FASTAPI is integrated with starelette from which we use Graphql features using Starelette's GraphqlApp module. But in github, I have seen GrahpqlApp is depreciated and going to removed in future release. Can anyone suggest me how can I use Grahpql along with FASTAPI. If not, do we have any better ASGI other than FASTAPI with all the features of FASTAPI and support for Graphql
Joshua Jamison
@codemation

hi guys
could you help me to find an example for validating jwt with external provider implemented by opened connect and OAuth 2

@mohammadalipour94_gitlab You might be interested in EasyAuth if you want to deploy your own provider - https://github.com/codemation/easyauth - Third party OAUTH ( google / other ) usually requires dns verification before it can be used.

Daniel Romberg
@djromberg
Hi, I am looking for a way to call an async function before my app has been created, i.e., from the non-async context. I start it using uvicorn. When I try to use asyncio.create_task(...) it looks like I can't wait/block for the result. Also running a coroutine with asyncio.run_until_complete(...) doesn't work as uvicorn already started it (starting it again leads to an exception). The third option I've tried is to create a new, temporary event loop using asyncio which was not allowed either (similar exception about existing event loop running). The last option I tried was to use the @app.on_event("startup") mechanism that allows an async function to be decorated. This worked in general, but one problem in my setup is that my APIRouter depends on the result of this async function and if I add the router within the startup event handler (which works), it breaks my unit tests, probably because they run before the startup event has been evaluated (might be a bug, though). Now I am out of ideas, maybe I am missing something obvious?
Marcelo Trylesinski
@Kludex
asgi_lifespan
image.png
this is the solution for: "before the startup event has been evaluated (might be a bug, though)"
Laurine
@Mylden
Hi everyone,
Do you have any idea how to use the refreshUrl parameter in OAuth2AuthorizationCodeBearer() in fastapi ? I need to exchange my access token when it is expired but I can't find any documentation to do so. How can I use the refresh token sent by my identity provider server in fastapi ?
Thank you a lot to anyone who could help me !
Daniel Romberg
@djromberg
@Kludex Great, that's exactly what I was looking for, thank you!
André Anjos
@anjos
Kudos for fastapi! Great library.
I'm trying to figure out how to send a single binary (image data) through a post request. My API side looks like:
@app.post("/predict")
def predict(image: bytes = Body(...)):
      data = numpy.frombuffer(image, dtype=int).astype(float)
      result = model.predict([data])
      return {"class": str(result[0])}
My client side looks like:
r = requests.post(base_url + "/predict", data=b'longbytesequence...')
But I always get: "POST /predict HTTP/1.1" 422 Unprocessable Entity
What am I doing wrong?
Alex Grönholm
@agronholm
@anjos what does the response body say?
André Anjos
@anjos
{'detail': 'There was an error parsing the body'} - it is actually a 400 error, not 422.
"POST /predict HTTP/1.1" 400 Bad Request
I also tried to modify the client side to include headers={'Content-Type': 'application/octet-stream'}, with no luck.
Alex Grönholm
@agronholm
so is that being passed in the request or not?
André Anjos
@anjos
The bytes go with the request, as far as I can tell.
What is curious is that, if I replace the longbytesquence by b'1234', then it works!
The "longbytesquence" is generated by a numpy array, so it has a lot of escape characters. Could this be the problem?
It actually looks like b'\x00\x00\x00\x00\x00\x00\x00...
Alex Grönholm
@agronholm
should not be a problem
André Anjos
@anjos
Setting data to data=b'\xf0\x9f\xa4\xa8', gives me 127.0.0.1:50901 - "POST /predict1 HTTP/1.1" 422 Unprocessable Entity, with the following response body:
{'detail': [{'loc': ['body', 0],
   'msg': 'Expecting value: line 1 column 1 (char 0)',
   'type': 'value_error.jsondecode',
   'ctx': {'msg': 'Expecting value',
    'doc': '🤨',
    'pos': 0,
    'lineno': 1,
    'colno': 1}}]}
André Anjos
@anjos

I managed to make it work:

# converting to text simply because our API is not optimal at this point
data = base64.b64encode(ndarray.tobytes()).decode("ascii")
r = requests.post(base_url + "/predict", data=f'"{data}"')
r.json()

The fastapi side could be kept as it was in this case. Apparently, JSON decoding does not work well with strings containing arbitrary scape sequences.

Alex Grönholm
@agronholm
@anjos base64 encoding is an ugly workaround, it should work as binary
Joween Flores
@joweenflores
Hi all, for Tortoise-ORM how can add the annotation ReverseRelation["Model"] in a multiple file setup without a circular import problem?
Prabhat
@rb1811
Hello FastApi community. Can some please help me with this
https://github.com/tiangolo/fastapi/discussions/3061
I am not sure which place is active so I am trying to post in both places. Not trying to spam. Any help is much appreciated.
Mahtab Alam
@alam-mahtab
I want little help from you guys, I raised an issue
https://github.com/tiangolo/fastapi/discussions/3050
kindly go through this everyone.
Marcelo Trylesinski
@Kludex
Our discord is more active than Gitter.
Prabhat
@rb1811
I am unable to join the discord. It gives me an error "Unable to accept the invite". I need help with my
https://github.com/tiangolo/fastapi/discussions/3061
Sebastian Noel Lübke
@sebastian:luebke.io
[m]
Why Discord switch to matrix ;)