Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ import pdfplumber
|
|
15 |
from pdf2image import convert_from_path, convert_from_bytes
|
16 |
import pytesseract
|
17 |
from PIL import Image
|
18 |
-
from huggingface_hub import HfApi, create_repo
|
19 |
|
20 |
# --- Flask App Initialization ---
|
21 |
app = Flask(__name__)
|
@@ -58,12 +58,7 @@ def ensure_hf_dataset():
|
|
58 |
repo_id_obj = create_repo(repo_id=HF_DATASET_REPO_NAME, token=HF_TOKEN, repo_type="dataset", exist_ok=True)
|
59 |
logger.info(f"Dataset repo ensured: {repo_id_obj.repo_id}")
|
60 |
return repo_id_obj.repo_id
|
61 |
-
|
62 |
-
if e.response.status_code == 409: # Conflict, repo already exists
|
63 |
-
logger.info(f"Dataset repo '{HF_DATASET_REPO_NAME}' already exists.")
|
64 |
-
return f"{hf_api.whoami(token=HF_TOKEN)['name']}/{HF_DATASET_REPO_NAME}" # Construct repo_id
|
65 |
-
logger.error(f"Hugging Face dataset error (HTTP {e.response.status_code}): {str(e)}")
|
66 |
-
return f"Error: Failed to access or create dataset '{HF_DATASET_REPO_NAME}': {str(e)}"
|
67 |
except Exception as e:
|
68 |
logger.error(f"Hugging Face dataset error: {str(e)}", exc_info=True)
|
69 |
return f"Error: Failed to access or create dataset '{HF_DATASET_REPO_NAME}': {str(e)}"
|
|
|
15 |
from pdf2image import convert_from_path, convert_from_bytes
|
16 |
import pytesseract
|
17 |
from PIL import Image
|
18 |
+
from huggingface_hub import HfApi, create_repo
|
19 |
|
20 |
# --- Flask App Initialization ---
|
21 |
app = Flask(__name__)
|
|
|
58 |
repo_id_obj = create_repo(repo_id=HF_DATASET_REPO_NAME, token=HF_TOKEN, repo_type="dataset", exist_ok=True)
|
59 |
logger.info(f"Dataset repo ensured: {repo_id_obj.repo_id}")
|
60 |
return repo_id_obj.repo_id
|
61 |
+
|
|
|
|
|
|
|
|
|
|
|
62 |
except Exception as e:
|
63 |
logger.error(f"Hugging Face dataset error: {str(e)}", exc_info=True)
|
64 |
return f"Error: Failed to access or create dataset '{HF_DATASET_REPO_NAME}': {str(e)}"
|