Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 17:09

    tiangolo on 0.45.0

    (compare)

  • 17:05

    tiangolo on master

    :bookmark: Release version 0.45… (compare)

  • 17:03

    tiangolo on master

    :memo: Update release notes (compare)

  • 16:58

    tiangolo on master

    :sparkles: Add support for Open… (compare)

  • 16:58
    tiangolo closed #722
  • 16:57
    tiangolo commented #722
  • 16:54
    codecov[bot] commented #722
  • 16:53
    codecov[bot] commented #722
  • 16:53
    codecov[bot] commented #722
  • 16:50
    codecov[bot] commented #722
  • 16:50
    codecov[bot] commented #722
  • 16:50
    tiangolo synchronize #722
  • 12:18
    Charlie-iProov closed #779
  • 12:18
    Charlie-iProov commented #779
  • 09:55
    kkinder opened #784
  • 09:18
    madkote commented #596
  • 05:47
    codecov[bot] commented #722
  • 05:47
    codecov[bot] commented #722
  • 05:47
    codecov[bot] commented #722
  • 05:46
    codecov[bot] commented #722
dmontagu
@dmontagu
can you print sys.executable
Guilherme Carvalho
@homeguii_twitter
Hi guys, already needed to use ACL + fastpi, what do they indicate?
tks
Marisha Parker
@intrepidOlivia
sys.path is identical between the two
dmontagu
@dmontagu
is sys.executable also identical
Marisha Parker
@intrepidOlivia
sys.executable is not
dmontagu
@dmontagu
huh, well that is probably related!
Marisha Parker
@intrepidOlivia
sys.path: ['C:\\Repositories\\project_root\\project_service', 'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2019.1.2\\plugins\\python-ce\\helpers\\pydev', 'C:\\Repositories\\project_root', 'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2019.1.2\\plugins\\python-ce\\helpers\\third_party\\thriftpy', 'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2019.1.2\\plugins\\python-ce\\helpers\\pydev', 'C:\\Users\\m_parker2\\.PyCharmCE2019.3\\system\\cythonExtensions', 'C:\\Users\\m_parker2\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\m_parker2\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\m_parker2\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\m_parker2\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Repositories\\project_root\\venv', 'C:\\Repositories\\project_root\\venv\\lib\\site-packages']
sys.executable C:\Repositories\project_root\venv\Scripts\python.exe
INFO: Uvicorn running on http://0.0.0.0:8888 (Press CTRL+C to quit)
INFO: Started reloader process [7052]
sys.path: ['C:\\Repositories\\project_root\\project_service', 'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2019.1.2\\plugins\\python-ce\\helpers\\pydev', 'C:\\Repositories\\project_root', 'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2019.1.2\\plugins\\python-ce\\helpers\\third_party\\thriftpy', 'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2019.1.2\\plugins\\python-ce\\helpers\\pydev', 'C:\\Users\\m_parker2\\.PyCharmCE2019.3\\system\\cythonExtensions', 'C:\\Users\\m_parker2\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\m_parker2\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\m_parker2\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\m_parker2\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Repositories\\project_root\\venv', 'C:\\Repositories\\project_root\\venv\\lib\\site-packages']
sys.executable C:\Users\m_parker2\AppData\Local\Programs\Python\Python37\python.exe
dmontagu
@dmontagu
is the python.exe in the project venv also python 3.7
Marisha Parker
@intrepidOlivia
Yes
I've finally got someone responding to my ticket on the Pycharm forums, so maybe that'll lead somewhere
This has been baffling to myself and everyone around me 😢
dmontagu
@dmontagu
yeah, I definitely think it's related to the sys.executable being different
Marisha Parker
@intrepidOlivia
When uvicorn runs normally, outside of the injector, how would I get it to use a different python environment if I wanted to?
dmontagu
@dmontagu
you would call it in the same way, and it would run in the same interpreter the script was called with
Marisha Parker
@intrepidOlivia
Right but would there be a way to make it run with another interpreter?
dmontagu
@dmontagu
not different than the one that called it, at least not using the uvicorn api, as far as I'm aware
Syniex
@Syniex
Hey,
did anyone try to add GZipMiddleware? i couldn't get it working
Marisha Parker
@intrepidOlivia
@Syniex Have you had success with other Middleware or is GZip your only one?
Guillaume Gomez
@GuillaumeGomez
Hi, how can I set the port without going through an external "service"?
I'd like to just start it on 5000 to run like my previous server
from what I saw, starlette doesn't allow it so I expect it to not be possible but just in case...
nevermind, apparently, we can't start it without uvicorn
my bad
Paul Weidner
@paul121
Hey all, question on using GitLab CI
I'm getting this error from my pipeline job:
error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on 169.254.169.254:53: no such host
There's a lot of issues floating around about this, but didn't see any issues on the tiangolo/docker-with-compose repo

Related blog post from GitLab with solution: https://about.gitlab.com/blog/2019/07/31/docker-in-docker-with-docker-19-dot-03/

But this didn't work for the docker-with-compose image. I'm not sure if it is built from the same thing?

Paul Weidner
@paul121

Well, got it working with the official docker/compose image. Created an issue tiangolo/docker-with-compose#10

Any idea why docker-with-compose isn't working?

euri10
@euri10
what type of runner do you use ?
Syniex
@Syniex
@intrepidOlivia just trying hzip
Paul Weidner
@paul121
@euri10 using the public shared runner. Is that the problem? It seemed like you could still work around that.
Syniex
@Syniex
i am also trying to model something special but couldn't get it to work

any idea what is the right way to do so:
class VC4(BaseModel):
J: int

class VC3(VC4):
K: int

class VC12(VC3):
L: int
M: int

class Channel(Enum):
vc4 = VC4
vc3 = VC3
vc12 = VC12

so i want channel to be OneOf these models
Peter van der Does
@petervanderdoes
Can I DRY the query parameters?
async def get_all_items(
    request: Request,
    start: Optional[int] = Query(None, title="Starting point", ge=1),
    limit: int = Query(20, title="Records per request", ge=1, le=50),
    sort: Optional[SortFields] = Query(
        None,
        title="Optional field to sort by. Prepend field with a dash to sort "
        "descending.",
    ),
    current_user: User = Depends(get_current_active_user),
) -> schema.Items:
The start and limit parameters come in play with several other endpoints.
I was Wondering if I could do something like:
async def get_all_items(
    request: Request,
    model: PaginationQuery,
    sort: Optional[SortFields] = Query(
        None,
        title="Optional field to sort by. Prepend field with a dash to sort "
        "descending.",
    ),
    current_user: User = Depends(get_current_active_user),
) -> schema.Items:
class PaginationQuery():
    start: Optional[int] = Query(None, title="Starting point", ge=1),
    limit: int = Query(20, title="Records per request", ge=1, le=50),
Peter van der Does
@petervanderdoes
So I got it almost working, it's just missing the title and validation in the openapi.json
async def get_all_items(
    request: Request,
    pagination: PaginationQuery = Depends(get_pagination_query),
    sort: Optional[SortFields] = Query(
        None,
        title="Optional field to sort by. Prepend field with a dash to sort "
        "descending.",
    ),
    current_user: User = Depends(get_current_active_user),
) -> schema.Items:

class PaginationQuery(BaseModel):
    start: Optional[int] = Field(None, title="Starting point", ge=1)
    limit: int = Field(20, title="Records per request", ge=1, le=50)

def get_pagination_query(start: Optional[int] = 1, limit: int = 20,) -> PaginationQuery:
    return PaginationQuery(start=start, limit=limit)
BTW, the order of the classes and methods might be wrong in the code, I just copied/pasted the needed code.
euri10
@euri10

@euri10 using the public shared runner. Is that the problem? It seemed like you could still work around that.

long time I had not touched the shared runner sorry, but I had those issues a while ago and depending on the executor you were using the fix was different, it was well explained here https://docs.gitlab.com/ee/ci/docker/using_docker_build.html

@paul121
Neil Shapiro
@nrshapiro

Has anyone successfully run FastAPI on elasticbeanstalk? It looks like a nice way to launch and monitor production code. I'm playing with a simple sample -- it works fine for the Flask demo I tried, but when I changed over to a simple FastAPI example, it failed. (It failed the same weird way when I tried to run my working FastAPI code too. The simple sample was trying to see if under the most basic conditions I could get it to run. It would be really nice to see this working there!

Flask Sample:

from flask import Flask

# print a nice greeting.
def say_hello(username = "World"):
    return '<p>Hello %s!</p>\n' % username

# some bits of text for the page.
header_text = '''
    <html>\n<head> <title>EB Flask Test</title> </head>\n<body>'''
instructions = '''
    <p><em>Hint</em>: This is a RESTful web service! Append a username
    to the URL (for example: <code>/Thelonious</code>) to say hello to
    someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'

# EB looks for an 'application' callable by default.
application = Flask(__name__)

# add a rule for the index page.
application.add_url_rule('/', 'index', (lambda: header_text +
    say_hello() + instructions + footer_text))

# add a rule when the page is accessed with a name appended to the site
# URL.
application.add_url_rule('/<username>', 'hello', (lambda username:
    header_text + say_hello(username) + home_link + footer_text))

# run the app.
if __name__ == "__main__":
    # Setting debug to True enables debug output. This line should be
    # removed before deploying a production app.
    application.debug = True
    application.run()

FastAPI sample: (both named application.py since that's what elasticbeanstalk looks for:

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def read_main():
    return {"msg": "Hello World"}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="development.org", port=5000, debug=True)
Sebastián Ramírez
@tiangolo
New release! :tada: :rocket:
(by FastAPI bot)

0.45.0

Justin Martel Reddick
@justinreddick
Hello all. Has anyone successfully defined a bearer format for the HTTPBearer? Could anyone explain how to do so?
from fastapi.security import HTTPBearer

auth_scheme = HTTPBearer(bearerFormat=)
RES
@madkote
hi all, I am looking at fullstack-templates - postgresql and couchbase. mysql is ok for my needs, so which of templates would be best to start with and modify to mysql?