Running a command before deploying

Hi,

I am using streamlit in conjunction with supabase and prisma to connect to a database which has been a great experience so far. However, prisma needs a command to be run to generate the types it needs, which is prisma generate dev. In deployment, this breaks my app.

Is it possible to run said command before launching the app?
Thanks

Hi @Wazarr94,

Unfortunately this isn’t possible with Streamlit Community Cloud, but I’d assume it’s possible with other platforms that aren’t necessarily geared towards deploying only Streamlit apps.

Caroline

It’s possible to use Prisma with Streamlit on the Streamlit community cloud. I have tried it here GitHub - vatsalsaglani/Streamlit-Prisma

Add this piece of code before you import Prisma. Everything should work perfectly.

def generate_prisma_client():
    """Generates the Prisma Client and loads it
    """
    print(f'GENERATING PRISMA CLIENT')
    subprocess.call(["prisma", "generate"])
    print(f'GENERATED PRISMA CLIENT')

generate_prisma_client()
try:
    from prisma import Prisma
except RuntimeError:
    from prisma_cleanup import cleanup
    cleanup()
    print(f'GOT RUNTIME ERROR')
    generate_prisma_client()
    from prisma import Prisma

The app is live at https://prisma.streamlitapp.com/

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.