Skip to content

Commit

Permalink
Merge pull request #10 from dSupertramp/chore/polish_code
Browse files Browse the repository at this point in the history
Polish code. Update .gitignore for backend
  • Loading branch information
ArslanSaleem authored Sep 30, 2024
2 parents 1196895 + 709cf8c commit 11d4af1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
20 changes: 17 additions & 3 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions backend/app/api/v1/user.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion backend/app/processing/file_preprocessing.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/app/repositories/project_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions backend/app/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions backend/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)

0 comments on commit 11d4af1

Please sign in to comment.