Spaces:
Runtime error
Runtime error
Commit
·
7e5fab7
1
Parent(s):
1d39d61
:art: cleanup
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
import sys
|
3 |
from subprocess import call
|
4 |
|
@@ -6,7 +7,11 @@ import streamlit as st
|
|
6 |
from huggingface_hub import Repository
|
7 |
|
8 |
|
|
|
|
|
|
|
9 |
def run_cmd(command):
|
|
|
10 |
try:
|
11 |
print(command)
|
12 |
call(command, shell=True)
|
@@ -15,12 +20,18 @@ def run_cmd(command):
|
|
15 |
sys.exit(1)
|
16 |
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
if os.environ.get("DO_DOWNLOAD_CACHE") and 'cache_is_downloaded' not in st.session_state:
|
21 |
-
with st.spinner("Downloading cache..."):
|
22 |
-
repo = Repository(local_dir="cache_dir", clone_from='nateraw/fairface', repo_type='dataset')
|
23 |
|
24 |
-
|
25 |
-
st.
|
26 |
-
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
import shutil
|
3 |
import sys
|
4 |
from subprocess import call
|
5 |
|
|
|
7 |
from huggingface_hub import Repository
|
8 |
|
9 |
|
10 |
+
CACHE_DIR = 'cache_dir/'
|
11 |
+
|
12 |
+
|
13 |
def run_cmd(command):
|
14 |
+
"""Runs CLI commands from Python, with outputs printed to shell"""
|
15 |
try:
|
16 |
print(command)
|
17 |
call(command, shell=True)
|
|
|
20 |
sys.exit(1)
|
21 |
|
22 |
|
23 |
+
def download_cache(cache_dir: str, repo_name: str):
|
24 |
+
"""Clones a repo from HuggingFace Hub to a cache directory"""
|
25 |
+
if os.environ.get("DO_DOWNLOAD_CACHE") and 'cache_is_downloaded' not in st.session_state:
|
26 |
+
with st.spinner("Downloading cache..."):
|
27 |
+
repo = Repository(local_dir=cache_dir, clone_from=repo_name, repo_type='dataset')
|
28 |
+
# repo.git_pull() # Needed?
|
29 |
|
|
|
|
|
|
|
30 |
|
31 |
+
def main():
|
32 |
+
st.title("Spaces LFS Workflow")
|
33 |
+
download_cache('cache_dir', 'nateraw/fairface')
|
34 |
+
st.write(os.listdir('.'))
|
35 |
+
st.write(os.listdir('./cache_dir'))
|
36 |
+
st.json(os.environ)
|
37 |
+
run_cmd('ls -lash cache_dir/')
|