用左 pandas / numpy + fastapi / pydantic => ValueError: Out of range float values are not JSON compliant 

dump 晒成個 想 response 既 dict 出黎望

望下有無 d value 有無 nan 先啦 (多既話都難睇既)

尤其用左 pandas dataframe, numpy 呢d 

佢計唔到數就會出NAN, 咁o岩個 fastapi 定 pydantic 想要float 就會出呢個 err 

你改佢做0 又好 , 一d 數字又好 

就有機會出到 response (which is json) 

一般 Class, Dataframe 應該都過到 fastapi response … 通常死係 float NAN 到

Add vs code server service to docker compose service (for royroycat.com)

  code-server:
    image: codercom/code-server:4.22.0-ubuntu
    expose: 
      - 8888
    environment:
      - PASSWORD=${CODE_SERVER_PASSWORD} # change password in env file
    volumes:
      - ./config:/config
      - $PWD:/home/coder/workspace
    ports:
      - 8080:8888
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.codeserver.rule=Host(`subdomain.${DOMAIN_NAME}`)"
      - "traefik.http.routers.codeserver.entrypoints=websecure"
      - "traefik.http.routers.codeserver.tls.certresolver=letsencrypt"

用 docker 又加左 python scheduler 但又無 print 唔出野

但 call 其他野 print 又無啦啦彈翻晒出黎? 放心你個 schedulrr 同個 program 都無事

solution:

put this in docker-compose

PYTHONUNBUFFERED=1

ChatGPT ans:

If you’re using the apscheduler library in your FastAPI app running in a Docker container, and you’re not seeing print messages in the container logs, it’s possible that the messages are being buffered by the apscheduler library or the Python interpreter, and are not being immediately flushed to the Docker logs.

One way to force the print messages to be immediately flushed to the Docker logs is to set the PYTHONUNBUFFERED environment variable to 1 when running the container. This will disable output buffering in the Python interpreter, and ensure that print messages are immediately written to the Docker logs.