Update app.py
Browse files
app.py
CHANGED
|
@@ -128,6 +128,39 @@ def extract_full_paper_with_labels(pdf_path, progress=None):
|
|
| 128 |
"content": content
|
| 129 |
}
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
def pdf_to_parquet_and_upload(pdf_files, hf_token, dataset_repo_id, action_choice, progress=gr.Progress()):
|
| 132 |
upload_message = ""
|
| 133 |
|
|
|
|
| 128 |
"content": content
|
| 129 |
}
|
| 130 |
|
| 131 |
+
|
| 132 |
+
def upload_with_progress(file_path, repo_id, token, progress):
|
| 133 |
+
"""
|
| 134 |
+
Upload file to Hugging Face Dataset using upload_file() API method.
|
| 135 |
+
"""
|
| 136 |
+
print(f"π€ Starting upload of Parquet: {file_path}")
|
| 137 |
+
file_size = os.path.getsize(file_path)
|
| 138 |
+
|
| 139 |
+
api = HfApi()
|
| 140 |
+
|
| 141 |
+
try:
|
| 142 |
+
# Use upload_file() method from huggingface_hub
|
| 143 |
+
api.upload_file(
|
| 144 |
+
path_or_fileobj=file_path,
|
| 145 |
+
path_in_repo=os.path.basename(file_path),
|
| 146 |
+
repo_id=repo_id,
|
| 147 |
+
repo_type="dataset",
|
| 148 |
+
token=token
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
if progress is not None:
|
| 152 |
+
progress(1, desc="β
Upload Complete")
|
| 153 |
+
|
| 154 |
+
print(f"β
Successfully uploaded to {repo_id}")
|
| 155 |
+
return f"β
Successfully uploaded to {repo_id}"
|
| 156 |
+
|
| 157 |
+
except HfHubHTTPError as e:
|
| 158 |
+
print(f"β Upload failed: {e}")
|
| 159 |
+
return f"β Upload failed: {str(e)}"
|
| 160 |
+
except Exception as e:
|
| 161 |
+
print(f"β Unexpected error: {e}")
|
| 162 |
+
return f"β Unexpected error: {str(e)}"
|
| 163 |
+
|
| 164 |
def pdf_to_parquet_and_upload(pdf_files, hf_token, dataset_repo_id, action_choice, progress=gr.Progress()):
|
| 165 |
upload_message = ""
|
| 166 |
|