File size: 1,320 Bytes
c4e85f9
 
 
35eccef
c4e85f9
e75dea4
35eccef
 
 
c4e85f9
35eccef
c70aef4
35eccef
 
 
 
 
f4cafbc
 
 
35eccef
 
926afdb
3c79350
926afdb
35eccef
f4cafbc
926afdb
f4cafbc
 
 
 
926afdb
 
aa758d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import streamlit as st
import os
from git import Repo
import sys

# GitHub Reposi tory and Directory Setup
repo_url = st.secrets["REPO_URL"]  # The private repository URL
github_token = st.secrets["GITHUB_PAT"]  # GitHub Personal Access Token
local_dir = "repo"

# Clone the private repository if it doesn't exist locally
if not os.path.exists(local_dir):
    try:
        repo_url = repo_url.replace("https://", f"https://{github_token}@")
        st.write("Cloning the repository...")
        Repo.clone_from(repo_url, local_dir)
        st.success("Repository cloned successfully!")
        
        # Add the repo directory to the system path
        sys.path.insert(0, local_dir)
    except Exception as e:
        st.error(f"Error cloning repository: {e}")
        st.stop()  # Stop the app if the repo can't be cloned

# Dynamically import and execute the app.py from the cloned repository
try:
    import importlib.util
    spec = importlib.util.spec_from_file_location("cloned_app", os.path.join(local_dir, "app.py"))
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)

except Exception as e:
    st.error(f"Error running the app from the cloned repo: {e}")
    st.stop()  # Stop the app if the cloned app can't be executed
    st.error(f"Failed to process video: {str(e)}")