diff --git a/backend/.gitignore b/backend/.gitignore index daee955..5124e14 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1,10 +1,24 @@ +# credentials .env -__pycache__/ .venv + +# virtualenv venv +VENV +ENV + +# database +*.db + +# logs +pandaetl.log + +# pycache +__pycache__/ + + +# dirs /instance/* !/instance/ uploads/ processed/ -pandaetl.log -*.db \ No newline at end of file diff --git a/backend/app/api/v1/user.py b/backend/app/api/v1/user.py index 4652142..87303dc 100644 --- a/backend/app/api/v1/user.py +++ b/backend/app/api/v1/user.py @@ -1,7 +1,5 @@ -import traceback from fastapi import APIRouter, Depends, HTTPException from requests import Session - from app.database import get_db from app.schemas.user import APIKeyRequest, UpdateAPIKeyRequest, UserUpdateRequest from app.repositories import user_repository diff --git a/backend/app/processing/file_preprocessing.py b/backend/app/processing/file_preprocessing.py index fce19a0..90957e0 100644 --- a/backend/app/processing/file_preprocessing.py +++ b/backend/app/processing/file_preprocessing.py @@ -1,5 +1,4 @@ from concurrent.futures import ThreadPoolExecutor -import traceback from sqlalchemy.orm.exc import ObjectDeletedError from app.models.asset_content import AssetProcessingStatus from app.database import SessionLocal diff --git a/backend/app/repositories/project_repository.py b/backend/app/repositories/project_repository.py index f2c9bd4..b90d787 100644 --- a/backend/app/repositories/project_repository.py +++ b/backend/app/repositories/project_repository.py @@ -26,7 +26,7 @@ def get_projects(db: Session, page: int = 1, page_size: int = 20): models.Project, func.count(models.Asset.id).label("asset_count"), # Count the assets ) - .filter(models.Project.deleted_at == None) + .filter(models.Project.deleted_at is None) .outerjoin(models.Asset, models.Project.id == models.Asset.project_id) .group_by(models.Project.id) .offset((page - 1) * page_size) diff --git a/backend/app/requests.py b/backend/app/requests.py index bf3e204..a0f4236 100644 --- a/backend/app/requests.py +++ b/backend/app/requests.py @@ -20,7 +20,7 @@ def request_api_key(email: str): logger.error( f"Failed to request API key. It returned {response.status_code} code: {response.text}" ) - raise Exception(f"Failed to request API key") + raise Exception("Failed to request API key") try: data = response.json() @@ -225,7 +225,7 @@ def highlight_sentences_in_pdf(api_token, sentences, file_path, output_path): logger.error( f"Unable to process file ${file_path} during highlight sentences in pdf. It returned {response.status_code} code: {response.text}" ) - raise Exception(f"Unable to process file!") + raise Exception("Unable to process file!") def extract_file_segmentation(api_token, file_path=None, pdf_content=None): @@ -301,7 +301,7 @@ def get_user_usage_data(api_token: str): logger.error( f"Failed to fetch usage data. It returned {response.status_code} code: {response.text}" ) - raise Exception(f"Failed to fetch usage data") + raise Exception("Failed to fetch usage data") try: return response.json() diff --git a/backend/app/utils.py b/backend/app/utils.py index 68f6058..28cab24 100644 --- a/backend/app/utils.py +++ b/backend/app/utils.py @@ -9,7 +9,6 @@ def generate_unique_filename(url, extension=".html"): url_hash = hashlib.sha256(url.encode("utf-8")).hexdigest() unique_id = uuid.uuid4().hex filename = f"{url_hash}_{unique_id}{extension}" - return filename @@ -43,9 +42,7 @@ def fetch_html_and_save(url, file_path): } response = requests.get(url, headers=headers) - response.raise_for_status() - # Get the content of the response with open(file_path, "wb") as file: file.write(response.content)