nateraw commited on
Commit
2b046ab
1 Parent(s): 7f94c54

Update status_checker.py

Browse files
Files changed (1) hide show
  1. status_checker.py +7 -10
status_checker.py CHANGED
@@ -6,10 +6,7 @@ from huggingface_hub import upload_folder, HfFolder, delete_repo
6
  import sys
7
  import time
8
  import subprocess
9
- from huggingface_hub.utils import logging
10
 
11
- logging.set_verbosity_debug()
12
- logger = logging.get_logger(__name__)
13
 
14
  HfFolder().save_token(os.getenv("HF_TOKEN"))
15
 
@@ -18,7 +15,7 @@ output_dataset_id = "nateraw/asdf123"
18
  outputs_dir = Path('outputs')
19
 
20
  process_pid = os.getenv('USER_SCRIPT_PID', None)
21
- logger.debug(f"USER SCRIPT PID? - {process_pid} - type {type(process_pid)}")
22
 
23
 
24
  def process_is_complete():
@@ -33,22 +30,22 @@ def process_is_complete():
33
  output_file = Path('done.txt')
34
 
35
  def status_checker():
36
- logger.debug("Waiting to find output_file to check if script is done running")
37
  while True:
38
- logger.debug(f"Process is complete? {process_is_complete()}")
39
  if output_file.exists():
40
- logger.debug("Found the output file - Uploading the outputs from the script")
41
  upload_folder(repo_id=output_dataset_id, folder_path=str(outputs_dir), path_in_repo='.', repo_type='dataset')
42
- logger.debug("Finished uploading outputs from script. Done now!")
43
  return
44
- logger.debug("Didn't find it...sleeping for 5 seconds.")
45
  time.sleep(5)
46
 
47
  with gr.Blocks() as demo:
48
  gr.Markdown(Path('about.md').read_text())
49
 
50
  if not output_file.exists():
51
- logger.debug("Didnt find output file on init, so starting thread to watch for it!")
52
  thread = Thread(target=status_checker, daemon=True)
53
  thread.start()
54
 
 
6
  import sys
7
  import time
8
  import subprocess
 
9
 
 
 
10
 
11
  HfFolder().save_token(os.getenv("HF_TOKEN"))
12
 
 
15
  outputs_dir = Path('outputs')
16
 
17
  process_pid = os.getenv('USER_SCRIPT_PID', None)
18
+ print(f"USER SCRIPT PID? - {process_pid} - type {type(process_pid)}")
19
 
20
 
21
  def process_is_complete():
 
30
  output_file = Path('done.txt')
31
 
32
  def status_checker():
33
+ print("Waiting to find output_file to check if script is done running")
34
  while True:
35
+ print(f"Process is complete? {process_is_complete()}")
36
  if output_file.exists():
37
+ print("Found the output file - Uploading the outputs from the script")
38
  upload_folder(repo_id=output_dataset_id, folder_path=str(outputs_dir), path_in_repo='.', repo_type='dataset')
39
+ print("Finished uploading outputs from script. Done now!")
40
  return
41
+ print("Didn't find it...sleeping for 5 seconds.")
42
  time.sleep(5)
43
 
44
  with gr.Blocks() as demo:
45
  gr.Markdown(Path('about.md').read_text())
46
 
47
  if not output_file.exists():
48
+ print("Didnt find output file on init, so starting thread to watch for it!")
49
  thread = Thread(target=status_checker, daemon=True)
50
  thread.start()
51