by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 19:11
    tiangolo labeled #1273
  • 19:11
    tiangolo commented #1273
  • 19:10
    tiangolo labeled #1263
  • 19:09
    tiangolo commented #1263
  • 19:05
    tiangolo labeled #1278
  • 19:05
    tiangolo commented #1278
  • 19:01
    tiangolo labeled #1257
  • 19:01
    tiangolo commented #1257
  • 17:54
    fhscholl closed #1193
  • 17:54
    fhscholl commented #1193
  • 17:19
    tiangolo commented #240
  • 17:08
    Jackovic closed #1508
  • 16:55
    tiangolo labeled #1270
  • 16:55
    tiangolo commented #1270
  • 16:45
    tiangolo edited #1111
  • 16:44
    tiangolo labeled #1111
  • 16:44
    tiangolo unlabeled #1111
  • 16:44
    tiangolo labeled #1111
  • 16:44
    tiangolo commented #1111
  • 16:35
    tiangolo commented #1193
weleo
@weleo
I have no idea, I just got into docker
also make sure all containers stopped before clearing everythign
weleo
@weleo

I also have a question regarding fastapi and docker, which is more of a set up problem because I don't get docker yet.

I want to access a selenium standalone chrome webdriver container from the fast api container, but it does not work for me.

docker-compose.yml

version: "3.3"

volumes:
  volume_fastapi:
  volume_selenium:

networks:
  web:
    external: true

services:
  fastapi:
    image: "fastapi:latest"
    container_name: "fastapi0"
    hostname: "fastapi"
    restart: "unless-stopped"
    volumes:
      - "volume_fastapi:/fastapi"
    networks:
      - "web"

  selenium:
    image: "selenium/standalone-chrome:latest"
    container_name: "selenium0"
    hostname: "selenium"
    restart: "unless-stopped"
    volumes:
      - "volume_selenium:/selenium"
    networks:
      - "web"

main.py in container built fromtiangolo/uvicorn-gunicorn-fastapi:python3.7

from bs4 import BeautifulSoup
from fastapi import FastAPI
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

app = FastAPI()


def get_test():
    driver = webdriver.Remote("http://selenium:4444/wd/hub", DesiredCapabilities.CHROME)
    driver.get('https://google.com')
    soup_article = BeautifulSoup(driver.page_source, 'html5lib')
    driver.quit()
    return soup_article


@app.get("/")
async def read_root():
    return {"Hello": "world!"}


@app.get("/test")
async def read_xv():
    response = get_test()
    return response
any idea what I am missing?
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='selenium', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f82a29e44d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
weleo
@weleo
it works when I spin up the selenium container inside the fastapi container, but that's not really ideal
Awanish Kumar
@MrAwanishKumar
Hi, when I try to map many to one in pydantic getting error -
File "/usr/lib/python3.8/site-packages/sqlalchemy/orm/mapper.py", line 3428, in missing
raise orm_exc.UnmappedColumnError(
sqlalchemy.orm.exc.UnmappedColumnError: No column businessDailyProducts.productId is configured on mapper mapped class BusinessDailyProducts->businessDailyProducts...
Where mysql table "businessDailyProducts" have productId as foreign key like this
productId = Column(Integer, ForeignKey("dataProducts.id"))
where dataProducts table id is primary key
I unable to find the solution. Need help
Thanks
JoeyG1973
@JoeyG1973
hey folks i am trying to do somethng clever here where the description and the regex are assigned via a config file where the key is the name of the function
        description="Platform type must one of {}".format(
            app_config.SUPPORTED_PLATFORMS[inspect.currentframe().f_code.co_name][
                "platforms"
            ]
        )
however i keep getting an error because the function is not being called. The swagger/OpenAPI is generated as part of the main and it of course only returns <module> as the value since the it is main not the function that is called.
i do notice that FastAPI is however putting the function name in the swagger interface
is there a way to get the value that fastapi has on the function name?
SkyWatcher
@beyondskyway

hi everyone, i use pydantic, when i have a big data, it cost too much when i create a pydantic model. Such as:

class TsData(BaseModel):
    value: List[float] = []
    timestamp: List[int] = []

ts_data = TsData(value=data.value, timestamp=data.timestamp)

the length of data.value is 20000, ts_data = TsData(value=data.value, timestamp=data.timestamp)will cost 50-80ms, it seems get a copy of the data in the memory. It's too slow, any solution? ths 🙏

4 replies
fastapi-bridge
@fastapi-bridge
[telegram] <HelioSAraujo> Howdy, folks!
Can I ask here basic questions about deploying FastAPI apps on GoogleCloudServer?
aditya-08
@aditya-08
Hello guys, have anyone managed to deploy fastapi app in any of the cloud service as serverless function.? Am looking for simple guide to help me do that.
wedward
@wedwardbeck
For those of you working with asyncpg, what base OS / image are you running with? Any issues/concerns with a specific flavor? Alpine seems like the popular choice, but asynpg requires glibc to build and I'm not sure running that on Alpine would be the best idea to save some disk/image space. Any insights would be great.
Chris Allnutt
@chris-allnutt
@wedwardbeck I’ve had luck with the debian buster images https://hub.docker.com/_/python
1 reply
David Saeger
@wuhland

ive been developing with the fastapi postgres full stack project for a bit and all of a sudden the backend wont build with error

ERROR: for paintbin_backend_1  Cannot start service backend: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"./start-reload.sh\": stat ./start-reload.sh: no such file or directory": unknown

where does start_reload even come from, I dont see it in the repo and why would it dissapear from the image?

Jacob Amrany
@jamra
Does anyone know the max websocket connections supported or suggested?
Andrew Gonchar
@ExplosiveJam
Hi friends! Is there a way to get all query params from handler? Like
@app.get('/)
async def handler(q1, q2, q3):
    db.execute(sql, all_params)
TheRede
@TheRede
Hi, does anyone have success with Keycloak + FastAPI? Can't find an example on it
Daniel
@danieljfarrell
@TheRede what’s Keycloak?!
TheRede
@TheRede
oidc and sso solution
https://www.keycloak.org/
JH
@JHBalaji

Anyway to achieve a subclass serialization in Pydantic

class User0(BaseModel):
    regid: int
    regtime: str


class User4(BaseModel):
    name: str
    others: User0

# Output: {"name":"User", "regid":5854225, "regtime":"2012-07-20 04:5:58"}

I cant do (User4, User0) because it has to do with Field Ordering that works in a certain way.

Daniel
@danieljfarrell
@TheRede oh that looks cool! And timely! I was considering looking into Firebase for Auth recently. I prefer to manage it all myself, but I’m thinking that clients will prefer using an ISO standard audited provider.
Saurav Pandit
@sauravpandit
Dockerhub is block in my organization. Can someone share content of docker file
I will build it for deployment
DontFight
@DontFight_twitter
The swagger ui in fastapi is loading js file from a cdn, is there anyway to load those files locally? And redoc as well.
Beattwits
@beat_return_twitter

I'm not sure if it right place to question, but i have no idea what to do now. How to run in production mode (that works 24/7, writing logs, etc.) FastAPI with Uvicorn on Ubuntu. I have tried several configuration:

  1. Install Nginx and configure all settings with this guide → https://www.uvicorn.org/deployment/#running-behind-nginx
    In this case i have running uvicorn like: sudo ~/.local/bin/uvicorn main:app --uds /var/sockets/uvicorn --proxy-headers, where i have created file /var/sockets/uvicorn by myself.
  2. Install Nginx and configure proxy_pass parameter in nginx.conf to specified port, when starting uvicorn if default mode: uvicorn main:app (default host 127.0.0.1, port 8000). BUT this doesn't work. Binding with UDS working, but with ports not.
  3. Running uvicorn in host 0.0.0.0 and port 80: sudo ~/.local/bin/uvicorn main:app --host 0.0.0.0 --port 80.

And have tried search step-by-step guide for this case, but everything i found was extremely hard or unclear.

6 replies
fastapi-bridge
@fastapi-bridge

[telegram] <R3d_sa> You need to list the images first.

docker images

and then if the image in the list, you can delete it by passing the image ID to the delete command.

docker rmi IMAGE ID

you also can use this command to see how many images you have
docker info
I tried before to use these commands but didn't do the work

docker system prune

docker image prune (re @fastapi_bridge_bot: gitter <NomeChomsky> but I don't have any of the code used to serve that on my laptop, and I just deleted docker and even the partition that drives docker. I can only assume there's a docker image still running in a detatched state all this time and I just can't see or find it anywhere.)

Marwan Rabbâa
@waghanza
Tất Đạt Phạm
@tatdatpham
Hi everyone, does FastAPi support MFA authentication ?
Shervin Rohani
@shervinir_gitlab
Hi everyone, I wanna use fullstack-template of fastapi. But Idk, how can I send_task from end_points to celery worker. Can anyone help me? or show me how to test, test_celery task in fastapi?
2 replies
TheRede
@TheRede
@kesavkolla could you please help with your way of integrating FastAPI and Keycloak? Found your message from February where you told you have it working
Daniel Taborda
@danieltaborda
Hi all
sunandosamaddar
@sunandosamaddar
Hi, does anybody think Pydantic is bloatware? I mean do we need so many blocks just to build a standard web app? The trends are pushing people take decisions all the time about using code from some foreign repo.
Daniel
@danieljfarrell
@sunandosamaddar do you think it’s bloatware? Not too sure what bloatware is.
sunandosamaddar
@sunandosamaddar
@danieljfarrell Why do we need Pydantic or say something like python-dotenv?
Ajit Krishna
@AjitZK
Hi everyone, I'm unable to upload a 2.5MB video on localhost using UploadFile.. I always get the error 413 Request Entity Too Large. How do I increase limits?
2 replies
Shawn Wall
@shawnwall
@sunandosamaddar it adds in a layer to assist in serialization/deserialization along with self-documentation. If you wish to simply create hyperfast services without these built in mechanisms starlette alone can be used. Personally I feel there are use cases for both fastapi and starlette.
Additionally, you dont have to use request/response models in fastapi.
wedward
@wedwardbeck
@sunandosamaddar not sure you have the right interpretation of bloatware. It does not slow down the app or cause other issues, just adds more dev tasks. For me, Pydantic was a pain to figure out , but once it clicked it made sense to have it. Data validation alone is worth it for me. dotenv - what are you using to manage your environment variables (settings, secrets, passwords, etc.)?
Nikita Davydov
@ndavydovdev

Hello, everyone! Have you ever tried to pickle GenericModel pydantic instance?
I've got error like that

_pickle.PicklingError: Can't pickle <class 'libs.my_lib.file.MyGenericModel[MyType]'>: attribute lookup MyGenericModel[MyType] on libs.my_lib.file failed

If you have any advice how to fix it without extra serialization, I will be very happy

Scott Sturdivant
@ScottSturdivant
To me, it was 100% bloatware. I was trying to use fastapi on an "embedded" platform with an ARM processor. The pydantic .whl for ARM is 21MB in size once extracted. Because of that, I just went with starlette natively. In other projects, I embrace pydantic. So I will say that I wish fastapi wasn't so opinionated.
flapili
@flapili

Hi, I come from to Tornado world so I don't know a lot about uvicorn/gunicorn/ect and I have few questions about logging.
For now in each Tornado process (the process could be on different host), I send logs to an another process via logging.handlers.SocketHandler (with Queue/QueueHandler/QueueListener thread). In the process which listen logs I have TimedRotatingFileHandler (1 per level) and SMTPhandler.

where should I configure SocketHandler with FastApi ? in the code ? in uvicorn ?
if I do it in code should I run uvicorn programmatically ?
if I do it via a config file and pass it to uvicorn can I deal with blocking handlers ?

Chris
@kfot
Hey fellas, I came from https://www.reddit.com/r/FastAPI/comments/fsy529/using_fastapi_with_pony_orm/ with exactly the same questions and I would really appreciate if you could share your wisdom about using FastAPI together with PonyORM. For the starter, do you suggest making use of pony's db_session dec (and where) and where in the app do you prefer instantiating the db?