tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Allow for uvicorn reload option for development workflow

Open edbarnard opened this issue 1 year ago • 2 comments

It would be nice to run the server in reload mode for debugging. It is possible to do this with FastAPI and uvicorn with the uvicorn --reload option. It is possible to send uvicorn this option via the config.yml as follows:

uvicorn:
  reload: true

However, tiled serve is not setup correctly to allow for this to work. Here is the error returned when uvicorn:reload:true:

[-] WARNING:  You must pass the application as an import string to enable 'reload' or 'workers'.

edbarnard avatar Dec 17 '24 21:12 edbarnard

Looking at the tiled.commandline._serve file, this may be more complex to change, due to the creation of the custom web_app object being dynamically generated with build_app rather than a direct import

edbarnard avatar Dec 18 '24 00:12 edbarnard

Actually, this can work. You have to use a config file, as there is no way to route CLI args to tiled (they go to uvicorn):

TILED_CONFIG=... uvicorn tiled.server.app:app

The app object uses module __getattr__ to dynamically build an app instance.

danielballan avatar Jan 13 '25 21:01 danielballan