Light Mode In Community Cloud?

Hi, How do I change the light mode dark mode theme in streamlit community cloud. When I was running my app locally i did the ./config and toml file stuff and set the theme to light there. But now in community cloud that doesn’t seem to work

I also have another doubt. In my git repo, I have another python file. I want a button in my first file (onclick) should start running the 2nd file (which is another streamlit app). I used to use os library for this locally but since I’m using cloud I’m not sure what to do

Could you kindly provide a link to your GitHub repository?

Yes here’s the link:

This is the app name: https://nortoninsightgenerator.streamlit.app/

There is no .streamlit/config.toml file in your GitHub repository. You can use the example below:

[theme]
base="dark"
1 Like

It looks like you forgot doing the ./config and toml file stuff in your repo.

To dynamically construct the file path for server deployment in Streamlit, you’ll want to avoid hardcoding the absolute file path, as it may vary depending on the environment or server structure. Instead, you can use relative paths or use os or pathlib to build paths dynamically, making your code more portable across different environments.

import os
import subprocess
import streamlit as st

# Get the current directory (assuming the script is in the same directory)
current_directory = os.getcwd()

# Construct the relative path to your target script
target_script = os.path.join(current_directory, "Another_AI_Test.py")

# Button to trigger the subprocess
if st.button("Open Feedback Insight Chat"):
    subprocess.Popen(["streamlit", "run", target_script])
    st.rerun()

Hi the thing is we can’t us the os library when working streamlit cloud. Its not compatible with the community cloud. Otherwise I would’ve used this previously. Is there any other way to run the file since its in the same git repo?

You can use os in streamlit cloud. What you can’t do is run another file as a different streamlit application. If you want that, you need to deploy them as two separate applications. If you want something else, please explain.

The most common way of running code in another file is importing it.

Is there a way I can share a screen recording to explain what Im trying to achieve?

I tried this out (You can check the code in my git repo as well) but it lags and doesnt do anything. So I’m not sure if it considers the file in the same directory even though they’re both in the same repo.

I’m also getting this error because I’m using BigQuery in my code:

TransportError: Failed to retrieve 
http://metadata.google.internal/computeMetadata/v1/universe/universe-domain from
the Google Compute Engine metadata service. Compute Engine Metadata server 
unavailable

Ever heard of youtube? vimeo? There are many others

It seems like this error is related to authentication failure, likely due to invalid credentials. To resolve this, you’ll need to create a service account in the Google Cloud Console, download the corresponding JSON key file, and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to that file.

GOOGLE_APPLICATION_CREDENTIALS="path_to_your_service_account_key.json"

Additionally, I would like to suggest refactoring your code. Breaking it into smaller, more manageable files will improve its structure. Adhering to Python conventions and following best practices for readability and maintainability will also enhance collaboration, making it easier for other developers to contribute.

Lmao I know how to record a video/screen, I meant there’s no option for me to attach something here besides images

Alright thank you for your help and advice. Is there anything you’d suggest regarding using os/pathlib for the button to open a new window/run another file. I tried the

current_directory = os.getcwd()

solution you posted above, but nothing happened. Do I need to change the git repo as well?

You can attach only images, everything else you can store it elsewhere and post a link.