wintergw commited on
Commit
41d170f
·
verified ·
1 Parent(s): 42c3e2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -32
app.py CHANGED
@@ -44,38 +44,17 @@ os.chdir(repo_dir)
44
  # # Add repo directory to sys.path so Python can find modules inside it
45
  sys.path.append(repo_dir)
46
 
47
- # Now you can directly load and execute `app.py` from the snapshot directory
48
-
49
- # List all files in the repo_dir to check where app.py is located
50
- print(f"Files in downloaded repo directory: {os.listdir(repo_dir)}")
51
-
52
- # Check if the app.py file exists
53
- app_path = os.path.join(repo_dir, 'app.py')
54
- if not os.path.exists(app_path):
55
- print(f"Error: {app_path} does not exist.")
56
- # You can also print out subdirectories if app.py is in a subfolder
57
- subdirectories = [d for d in os.listdir(repo_dir) if os.path.isdir(os.path.join(repo_dir, d))]
58
- print(f"Subdirectories in repo: {subdirectories}")
59
- else:
60
- # Load and execute `app.py`
61
- spec_app = importlib.util.spec_from_file_location("*", app_path)
62
- app_module = importlib.util.module_from_spec(spec_app)
63
- spec_app.loader.exec_module(app_module)
64
-
65
- # Now you can use functions from the app_module
66
- result = app_module.main()
67
-
68
 
69
  # Download specific files (if snapshot_download wasn't used)
70
- # app_path = hf_hub_download(
71
- # repo_id=REPO_ID,
72
- # filename="app.py",
73
- # repo_type=REPO_TYPE
74
- # )
75
 
76
- # # Load and execute `app.py`
77
- # spec_app = importlib.util.spec_from_file_location("*", app_path)
78
- # app_module = importlib.util.module_from_spec(spec_app)
79
- # spec_app.loader.exec_module(app_module)
80
- ## Now you can use functions from utils_module
81
- #result = app_module.main()
 
44
  # # Add repo directory to sys.path so Python can find modules inside it
45
  sys.path.append(repo_dir)
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  # Download specific files (if snapshot_download wasn't used)
49
+ app_path = hf_hub_download(
50
+ repo_id=REPO_ID,
51
+ filename="app.py",
52
+ repo_type=REPO_TYPE
53
+ )
54
 
55
+ # Load and execute `app.py`
56
+ spec_app = importlib.util.spec_from_file_location("*", app_path)
57
+ app_module = importlib.util.module_from_spec(spec_app)
58
+ spec_app.loader.exec_module(app_module)
59
+ # Now you can use functions from utils_module
60
+ result = app_module.main()