Postgresql Sequence not increase by 1

I use a sequence in the PostgreSQL table with an 8-digits start number like: 20000101 20000102 And execute INSERT query with SQLAlchemy ORM in API (AWS lambda) like: result = session.query("select nextval(‘mydb.student_id_seq’)").one_or_none() id = result[0] student_model = Student( id=id, name="Name", class_id="Class ID", grade="A" ) But sometimes a sequence number increases by a random number or… Read More Postgresql Sequence not increase by 1

Access to fetch at 'http://localhost:8000/api/v1' from origin 'http://0.0.0.0:8000' has been blocked by CORS policy

This issue is well documented but my attempts have been unsuccessful… any suggestions are welcome! cookiecutter project on Github: Buuntu/fastapi-react Recreating Error cookiecutter gh:Buuntu/fastapi-react –no-input cd fastapi-react-project modified files before running build script (in order to address prior errors): frontend/Dockerfile line 7 RUN npm install –legacy-peer-deps docker-compose.yml line 37 # flower: # image: mher/flower #… Read More Access to fetch at 'http://localhost:8000/api/v1' from origin 'http://0.0.0.0:8000' has been blocked by CORS policy

Unable to requests FastAPI running in docker-compose

I have a Dockerfile which exposes an API on port 8000: # .. EXPOSE 8000 ENV PYTHONPATH="src/." CMD ["gunicorn", "-b :8000", "-k", "uvicorn.workers.UvicornWorker", "fingerprinter.api.server:app"] It’s just a simple FastAPI server with a simple endpoint: @app.get("/health") def health(): return "OK" This is the relevant part of the docker-compose.yaml: version: "3.7" services: fprint-api: container_name: fprint-api-v2 image: "fprint-api:v0.0.1"… Read More Unable to requests FastAPI running in docker-compose

How to update a global variable from a function in Python?

I want to update an empty string value which is declared globally. I want to update that variable from inside a function. Following id the code: import jwt import os from dotenv import load_dotenv load_dotenv() from rest_framework.exceptions import APIException jwtPrivateKey = (os.environ.get(‘SECRET_KEY’)) # VARIABLE DECALRED HERE token_value = "" def authenticate(auth_header_value): try: if auth_header_value is… Read More How to update a global variable from a function in Python?

Application runs with uvicorn but can't find Module (No module named 'app')

. ├── __pycache__ │ └── api.cpython-310.pyc ├── app │ ├── __pycache__ │ │ └── main.cpython-310.pyc │ ├── api_v1 │ │ ├── __pycache__ │ │ │ └── apis.cpython-310.pyc │ │ ├── apis.py │ │ └── endpoints │ │ ├── __pycache__ │ │ │ └── message_prediction.cpython-310.pyc │ │ └── message_prediction.py │ ├── config.py │ ├── main.py │… Read More Application runs with uvicorn but can't find Module (No module named 'app')

'FastAPI' object has no attribute 'default_response_class'

I am trying to include a router in the main FastAPI router: from fastapi import FastAPI from test.main.app.google_calendar_wrapper import app as calendar_manager_router app = FastAPI() # app.include_router(calendar_manager_router, prefix="/calendar_manager", tags=["calendar_manager"]) @app.get("/") def root(): return {"message": "Home Page"} However, when running uvicorn test.main.app.webhook.router:app –port 8050 –reload I get an error: AttributeError: ‘FastAPI’ object has no attribute ‘default_response_class’… Read More 'FastAPI' object has no attribute 'default_response_class'

How to monitor the status of model training running on the server via fast-api

By the following code, I want to get the status of training, just if it is started and when it is finished. app = FastAPI() @app.post("/train") async def train_on_background(): background_tasks.add_task(train, input_data, output_data) def train(input_data, output_data): dataset = prepare_dataset(input_data, output_data) model = Trainer(dataset) model.auto_train() filename = "Model" filename = filename + ".pkl" dump(model, open(filename, ‘wb’)) The… Read More How to monitor the status of model training running on the server via fast-api

The header name "headers" is not set in the GET request processing declaration

I’m trying to set the name of the header in the model description, but it remains empty in the documentation. What am I doing wrong? Example: @router.get(‘/hash_header’,response_model=models.hash_out,tags=["use-hash"],responses={ 200: { "model": models.hash_out, "description": "Return has code", "headers": [ {‘name’:"Secret-Code","description":"Secret code","type":"string"} ] } }) In the docs: >Solution : headers should be a dictionary with the name… Read More The header name "headers" is not set in the GET request processing declaration