Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ import os
|
|
8 |
from datetime import datetime
|
9 |
from typing import List, Dict
|
10 |
import requests
|
11 |
-
from huggingface_hub import login # Importing Hugging Face Spaces
|
12 |
import gradio as gr
|
13 |
import atexit
|
14 |
import subprocess
|
@@ -23,35 +22,23 @@ warnings.filterwarnings('ignore', category=UserWarning)
|
|
23 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
24 |
|
25 |
def initialize_zero_gpu():
|
26 |
-
"""Initialize Hugging Face ZeroGPU
|
27 |
-
logger.info("Initializing Hugging Face ZeroGPU...")
|
28 |
try:
|
29 |
-
# Check if CUDA is available
|
30 |
if torch.cuda.is_available():
|
31 |
-
# Initialize DeepSpeed with Zero Optimization
|
32 |
deepspeed.init_distributed()
|
33 |
print("ZeroGPU initialized successfully.")
|
34 |
else:
|
35 |
print("CUDA is not available. Using CPU instead.")
|
36 |
except Exception as e:
|
37 |
print(f"Error initializing Hugging Face ZeroGPU: {str(e)}")
|
38 |
-
logger.error(f"Error initializing Hugging Face ZeroGPU: {str(e)}")
|
39 |
-
|
40 |
-
# Check for the missing autotune file
|
41 |
-
autotune_file = '/home/user/.triton/autotune'
|
42 |
-
if not os.path.exists(autotune_file):
|
43 |
-
logger.warning(f"Missing autotune file: {autotune_file}. This may affect performance.")
|
44 |
-
print(f"Warning: Missing autotune file: {autotune_file}. This may affect performance.")
|
45 |
|
46 |
def initialize_environment():
|
47 |
"""Initialize application environment and configurations"""
|
48 |
-
# Create necessary directories
|
49 |
directories = ['logs', 'resolutions', 'repos']
|
50 |
for directory in directories:
|
51 |
os.makedirs(directory, exist_ok=True)
|
52 |
|
53 |
-
|
54 |
-
log_file = f"logs/github_bot_{datetime.now().strftime('%Y%m%d_%H%M%S')}.log"
|
55 |
logging.basicConfig(
|
56 |
level=logging.INFO,
|
57 |
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
@@ -61,7 +48,6 @@ def initialize_environment():
|
|
61 |
]
|
62 |
)
|
63 |
|
64 |
-
# Set up global exception handler
|
65 |
def handle_exception(exc_type, exc_value, exc_traceback):
|
66 |
if issubclass(exc_type, KeyboardInterrupt):
|
67 |
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
@@ -167,21 +153,21 @@ class GitHubBot:
|
|
167 |
f.write(f"# Resolution for Issue #{issue_number}\n\n{resolution}")
|
168 |
|
169 |
# Clone the forked repo
|
170 |
-
subprocess.run(['git', 'clone', forked_repo, '/tmp/' + forked_repo.split('/')[-1]])
|
171 |
|
172 |
# Change to the cloned directory
|
173 |
os.chdir('/tmp/' + forked_repo.split('/')[-1])
|
174 |
|
175 |
# Assuming manual intervention now
|
176 |
-
input("Apply the fix manually and stage the changes (press ENTER)? ")
|
177 |
|
178 |
# Commit and push the modifications
|
179 |
-
subprocess.run(['git', 'add', '.'])
|
180 |
-
subprocess.run(['git', 'commit', '-m', f"Resolved issue #{issue_number} ({urllib.parse.quote(resolution)})"])
|
181 |
-
subprocess.run(['git', 'push', 'origin', 'HEAD'])
|
182 |
|
183 |
# Open Pull Request page
|
184 |
-
webbrowser.open('https://github.com/
|
185 |
|
186 |
return f"Resolution saved: {resolution_file}"
|
187 |
|
@@ -420,4 +406,4 @@ if __name__ == "__main__":
|
|
420 |
logger.error(f"Error launching application: {str(e)}")
|
421 |
raise
|
422 |
finally:
|
423 |
-
logger.info("Application shutdown")
|
|
|
8 |
from datetime import datetime
|
9 |
from typing import List, Dict
|
10 |
import requests
|
|
|
11 |
import gradio as gr
|
12 |
import atexit
|
13 |
import subprocess
|
|
|
22 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
23 |
|
24 |
def initialize_zero_gpu():
|
25 |
+
"""Initialize Hugging Face ZeroGPU"""
|
|
|
26 |
try:
|
|
|
27 |
if torch.cuda.is_available():
|
|
|
28 |
deepspeed.init_distributed()
|
29 |
print("ZeroGPU initialized successfully.")
|
30 |
else:
|
31 |
print("CUDA is not available. Using CPU instead.")
|
32 |
except Exception as e:
|
33 |
print(f"Error initializing Hugging Face ZeroGPU: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
def initialize_environment():
|
36 |
"""Initialize application environment and configurations"""
|
|
|
37 |
directories = ['logs', 'resolutions', 'repos']
|
38 |
for directory in directories:
|
39 |
os.makedirs(directory, exist_ok=True)
|
40 |
|
41 |
+
log_file = f"logs/github_bot_{datetime.now(). strftime('%Y%m%d_%H%M%S')}.log"
|
|
|
42 |
logging.basicConfig(
|
43 |
level=logging.INFO,
|
44 |
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
|
48 |
]
|
49 |
)
|
50 |
|
|
|
51 |
def handle_exception(exc_type, exc_value, exc_traceback):
|
52 |
if issubclass(exc_type, KeyboardInterrupt):
|
53 |
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
|
|
153 |
f.write(f"# Resolution for Issue #{issue_number}\n\n{resolution}")
|
154 |
|
155 |
# Clone the forked repo
|
156 |
+
subprocess.run(['git', 'clone', forked_repo, '/tmp/' + forked_repo.split('/')[-1]], check=True)
|
157 |
|
158 |
# Change to the cloned directory
|
159 |
os.chdir('/tmp/' + forked_repo.split('/')[-1])
|
160 |
|
161 |
# Assuming manual intervention now
|
162 |
+
input(" Apply the fix manually and stage the changes (press ENTER)? ")
|
163 |
|
164 |
# Commit and push the modifications
|
165 |
+
subprocess.run(['git', 'add', '.'], check=True)
|
166 |
+
subprocess.run(['git', 'commit', '-m', f"Resolved issue #{issue_number} ({urllib.parse.quote(resolution)})"], check=True)
|
167 |
+
subprocess.run(['git', 'push', 'origin', 'HEAD'], check=True)
|
168 |
|
169 |
# Open Pull Request page
|
170 |
+
webbrowser.open(f'https://github.com/{forked_repo.split("/")[-1]}/compare/master...{username}:{forked_repo.split("/")[-1]}_resolved_issue_{issue_number}')
|
171 |
|
172 |
return f"Resolution saved: {resolution_file}"
|
173 |
|
|
|
406 |
logger.error(f"Error launching application: {str(e)}")
|
407 |
raise
|
408 |
finally:
|
409 |
+
logger.info("Application shutdown")
|