amanpreet7 commited on
Commit
992e8ce
·
verified ·
1 Parent(s): 155f753

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -12
app.py CHANGED
@@ -110,6 +110,36 @@ def download_notebook_from_drive(drive_service, temp_dir):
110
  downloader = MediaFileUpload(notebook_path)
111
  downloader.stream = request.execute()
112
  f.write(downloader.stream)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  return notebook_path
114
  except Exception as e:
115
  st.error(f"Failed to download notebook from Drive: {e}")
@@ -135,6 +165,8 @@ def push_kaggle_kernel(api, temp_dir, notebook_slug):
135
  "enable_gpu": True,
136
  "enable_internet": True,
137
  "is_private": True,
 
 
138
  "competition_sources": [],
139
  "dataset_sources": [],
140
  "kernel_sources": []
@@ -157,18 +189,7 @@ def push_kaggle_kernel(api, temp_dir, notebook_slug):
157
  except Exception as e:
158
  st.error(f"Failed to push kernel: {str(e)}")
159
  raise
160
-
161
- def check_kernel_exists(api, notebook_slug):
162
- try:
163
- kernels = api.kernels_list(mine=True, search=notebook_slug)
164
- for kernel in kernels:
165
- if kernel.ref == notebook_slug:
166
- return True
167
- return False
168
- except Exception as e:
169
- st.error(f"Kernel check failed: {e}")
170
- return False
171
-
172
  def process_video(api, drive_service, video_file):
173
  video_file_id = None
174
  bvh_file_id = None
 
110
  downloader = MediaFileUpload(notebook_path)
111
  downloader.stream = request.execute()
112
  f.write(downloader.stream)
113
+
114
+ # Add kernel specification to notebook
115
+ with open(notebook_path, 'r') as f:
116
+ notebook_content = json.load(f)
117
+
118
+ # Add proper kernel specification
119
+ notebook_content['metadata']['kernelspec'] = {
120
+ "display_name": "Python 3",
121
+ "language": "python",
122
+ "name": "python3"
123
+ }
124
+
125
+ # Ensure language_info is complete
126
+ notebook_content['metadata']['language_info'] = {
127
+ "name": "python",
128
+ "version": "3.10.12",
129
+ "mimetype": "text/x-python",
130
+ "codemirror_mode": {
131
+ "name": "ipython",
132
+ "version": 3
133
+ },
134
+ "pygments_lexer": "ipython3",
135
+ "nbconvert_exporter": "python",
136
+ "file_extension": ".py"
137
+ }
138
+
139
+ # Write back the modified notebook
140
+ with open(notebook_path, 'w') as f:
141
+ json.dump(notebook_content, f)
142
+
143
  return notebook_path
144
  except Exception as e:
145
  st.error(f"Failed to download notebook from Drive: {e}")
 
165
  "enable_gpu": True,
166
  "enable_internet": True,
167
  "is_private": True,
168
+ "accelerator": "gpu", # Explicitly specify GPU
169
+ "gpu_product": "T4x2", # Specify T4x2 GPU
170
  "competition_sources": [],
171
  "dataset_sources": [],
172
  "kernel_sources": []
 
189
  except Exception as e:
190
  st.error(f"Failed to push kernel: {str(e)}")
191
  raise
192
+
 
 
 
 
 
 
 
 
 
 
 
193
  def process_video(api, drive_service, video_file):
194
  video_file_id = None
195
  bvh_file_id = None