File size: 960 Bytes
b180c60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136a5d3
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
import os
import shutil
from pathlib import Path
from urllib.parse import urlparse

os.system("pip install GitPython")

from git import Repo

token = os.getenv('GH_TOKEN')
repo_url = os.getenv('REPO')

REPO_URL, BRANCH_NAME = repo_url.split('@')
OWNER_REPO_NAME = urlparse(REPO_URL).path.lstrip("/")
REPO_DIR_NAME = Path(urlparse(REPO_URL).path).stem

Repo.clone_from(f"https://{token}@github.com/{OWNER_REPO_NAME}", REPO_DIR_NAME, branch=BRANCH_NAME)
 
for item in Path(REPO_DIR_NAME).iterdir():
    shutil.copytree(item, Path.cwd() / item.name, dirs_exist_ok=True) if item.is_dir() else shutil.copy2(item, Path.cwd())

def del_error_handler(func, path, exc_info):
    if not os.access(path, os.W_OK):
        os.chmod(path, 0o600)
        func(path)
    else:
        raise
shutil.rmtree(REPO_DIR_NAME, onerror=del_error_handler)

os.system("pip install -r requirements.txt")

from gradio_app import demo

demo.queue(concurrency_limit=1, max_size=1).launch()