Namespace Issue with FastAPI and FastAI Model: CLI vs. Programmatic Uvicorn Start #2272
SmilingXinyi
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on a FastAPI project that utilizes a FastAI model for certain operations. During the model's training phase, we've defined a custom function is_cat. Everything works perfectly when I start the Uvicorn server programmatically using uvicorn.run() within my Python code. However, I encounter an attribute error related to the is_cat function not being available in the namespace when I attempt to start the server using Uvicorn's command-line interface (CLI).
The exact error message I encounter is as follows:
Ensuring that the is_cat function is defined in the global namespace before the model is loaded.
Re-declaring the is_cat function in various places (e.g., the application's root directory, within submodules, etc.).
It appears that the issue might be related to differences in how the Python namespace is handled between starting the server via the Uvicorn CLI and using uvicorn.run().
Beta Was this translation helpful? Give feedback.
All reactions