'After Cythonization Schemas are Gone in FastAPI Docs and Calls are not Working
I cythonized my project folder and removed all files except .so and .sh files. I was able to deploy it and it was up and running, but in docs schema information is gone and I'm not able to send information from docs into database as I had done previously. I got 500 error when I attempted to make POST calls with the data that was working before cythonization. What might be the reason?
My cythonization code:
import os
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
import shutil
extensions = []
for root, directory, files in os.walk('./api'):
if 'alembic' not in root:
for file in files:
if file.endswith('.py') and\
'keycloak' not in file:
module_name = os.path.join(root[2:], file)
package_name = root[2:].replace('/', '.')
print(package_name, ' ', module_name)
extensions.append(Extension(package_name, [module_name]))
setup(
name='Indexer',
cmdclass={'build_ext':build_ext},
ext_modules=cythonize(extensions,
compiler_directives={
'c_string_type': 'str',
'c_string_encoding': 'utf8',
'language_level': 3})
)
def delete_files():
for root, directory, files in os.walk('./'):
if 'alembic' not in root:
for file in files:
if not file.endswith('.so') and\
not file.endswith('.sh') :
module_name = os.path.join(root, file)
os.remove(module_name)
def delete_directories():
for root, directory, files in os.walk('./'):
if root != './':
shutil.rmtree(root)
def move_files():
for root, directory, files in os.walk('./api'):
if 'alembic' not in root:
for file in files:
if file.endswith('.so'):
module_name = os.path.join(root, file)
shutil.move(module_name, file)
move_files()
delete_files()
delete_directories()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

