File size: 1,097 Bytes
ecda8f8
4f86110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pathlib import Path
from threading import Thread
import gradio as gr
from huggingface_hub import upload_folder, HfFolder, delete_repo
import sys
import time


HfFolder().save_token(os.getenv("HF_TOKEN"))

output_dataset_id = "nateraw/asdf123"
outputs_dir = Path('outputs')
output_file = Path('done.txt')

def status_checker():
    while True:
        if output_file.exists():
            print("FOUND THE OUTPUT FILE WOAHH. Uploading the outputs from the script")
            upload_folder(repo_id=output_dataset_id, folder_path=str(outputs_dir), path_in_repo='.', repo_type='dataset')
            print("Finished uploading outputs from script. Done now!")
            return
        print(f"Waiting to find output file...sleeping for 1 second. Outputs Dir Exists - {outputs_dir.exists()}")
        time.sleep(1)

with gr.Blocks() as demo:
    gr.Markdown(Path('about.md').read_text())

if not output_file.exists():
    print("Didnt find output file on init, so starting thread to watch for it!")
    thread = Thread(target=status_checker, daemon=True)

thread.start()
demo.launch()