Roobick commited on
Commit
d4313f1
·
1 Parent(s): bd4c7ae

Remove upload functionality for Kaggle kernels and associated Gradio interface from app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -36
app.py CHANGED
@@ -76,23 +76,6 @@ def download_kernel_notebook(kernel_ref: str) -> str:
76
  )
77
  return zip_path
78
 
79
- def upload_kernel_notebook(kernel_zip: str) -> Dict:
80
- tmp_dir = tempfile.mkdtemp()
81
- shutil.unpack_archive(kernel_zip, tmp_dir)
82
- stdout_buf, stderr_buf = io.StringIO(), io.StringIO()
83
- try:
84
- with redirect_stderr(stdout_buf), redirect_stderr(stderr_buf):
85
- api.kernels_push(folder=tmp_dir)
86
- result_text = stdout_buf.getvalue().strip() or "kernel pushed"
87
- except Exception as exc:
88
- return{
89
- "status": "error",
90
- "detail": f"{exc}",
91
- "stderr": stderr_buf.getvalue().strip(),
92
- }
93
- finally:
94
- shutil.rmtree(tmp_dir, ignore_errors=True)
95
-
96
  search_iface = gr.Interface(
97
  fn=search_datasets,
98
  inputs=[
@@ -145,27 +128,9 @@ search_kernels_iface = gr.Interface(
145
  description="Find notebook or script kernels by keyword."
146
  )
147
 
148
- upload_kernel_iface = gr.Interface(
149
- fn = upload_kernel_notebook,
150
- inputs=gr.File(
151
- label="Kernel ZIP",
152
- file_types=[".zip"],
153
- type="filepath",
154
- show_label=True,
155
- ),
156
- outputs=gr.JSON(label="kaggle response"),
157
- title="Push kaggle kernel",
158
- description=(
159
- "Upload a kernel folder to kaggle\n"
160
- "Prepare a ZIP that contains **kernel-metadata.json** and the notebook "
161
- "or script files.\n"
162
- ),
163
- )
164
-
165
-
166
  demo = gr.TabbedInterface(
167
  [search_iface, list_files_iface, download_dataset_iface,
168
- search_kernels_iface, download_kernel_iface, upload_kernel_iface],
169
  tab_names=["Search Datasets", "Files", "Download dataset",
170
  "Search Kernels", "Download kernels", "Upload kernel zip"],
171
  )
 
76
  )
77
  return zip_path
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  search_iface = gr.Interface(
80
  fn=search_datasets,
81
  inputs=[
 
128
  description="Find notebook or script kernels by keyword."
129
  )
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  demo = gr.TabbedInterface(
132
  [search_iface, list_files_iface, download_dataset_iface,
133
+ search_kernels_iface, download_kernel_iface],
134
  tab_names=["Search Datasets", "Files", "Download dataset",
135
  "Search Kernels", "Download kernels", "Upload kernel zip"],
136
  )