Skip to content

Commit

Permalink
try again
Browse files Browse the repository at this point in the history
  • Loading branch information
AditiR-42 committed Dec 12, 2024
1 parent 5889d6a commit 3bc3b51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/api_service/api/routers/recommend.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,5 +354,4 @@ def recommend_app(request: QueryRequest):
print(e)
traceback.print_exc()
raise HTTPException(status_code=500, detail=str(e))



10 changes: 0 additions & 10 deletions src/api_service/api/routers/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ async def process_pdf(
Process a PDF file to extract and analyze privacy issues.
"""
try:
logging.info("Received PDF for processing.")

# Validate uploaded file
if not pdf_file.filename.endswith(".pdf"):
raise HTTPException(status_code=400, detail="A valid PDF file is required.")
Expand All @@ -36,8 +34,6 @@ async def process_pdf(
with open(pdf_path, "wb") as pdf_out:
pdf_out.write(await pdf_file.read())

logging.info("PDF saved to temporary storage. Starting processing.")

# Process the PDF to extract privacy issues
found_issues = process_pdf_privacy_issues(
pdf_path, project_id, location_id, endpoint_id
Expand All @@ -46,8 +42,6 @@ async def process_pdf(
# Store extracted issues in memory
parsed_issues_storage["issues"] = found_issues

# logging.info(f"Processing completed. Found issues: {found_issues}")

return {
"message": "Processing completed successfully.",
"found_issues": found_issues,
Expand All @@ -64,8 +58,6 @@ async def get_grade():
Grade the parsed privacy issues.
"""
try:
logging.info("Grading issues...")

# Check if issues have been extracted
if not parsed_issues_storage["issues"]:
raise HTTPException(
Expand All @@ -85,8 +77,6 @@ async def get_grade():
# Grade the issues
report = grader.grade_privacy_issues(parsed_issues_storage["issues"])

# logging.info(f"Grading completed. Report: {report}")

return {
"overall_grade": report.overall_grade,
"overall_score": report.overall_score,
Expand Down
26 changes: 13 additions & 13 deletions src/models/tests/integration/test_api_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,71 +539,71 @@ def mock_model():
return mock

def test_filter_by_genre(sample_df, mock_model):
with patch('your_module.df', sample_df), \
patch('your_module.model', mock_model):
with patch('recommend.df', sample_df), \
patch('recommend.model', mock_model):
criteria = {'Genre': 'Social Media'}
result = filter_dataframe(criteria)
assert len(result) == 1
assert result.iloc[0]['Service'] == 'App1'

def test_filter_by_privacy_rating(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'privacy_rating': 'B'}
result = filter_dataframe(criteria)
assert len(result) == 2
assert set(result['Service']) == {'App1', 'App2'}

def test_filter_by_content_rating(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'Content Rating': 'Teen'}
result = filter_dataframe(criteria)
assert len(result) == 1
assert result.iloc[0]['Service'] == 'App2'

def test_filter_by_app_score(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'app_score': 4.0}
result = filter_dataframe(criteria)
assert len(result) == 2
assert set(result['Service']) == {'App1', 'App2'}

def test_filter_by_installs(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'Installs': 500000}
result = filter_dataframe(criteria)
assert len(result) == 2
assert set(result['Service']) == {'App1', 'App2'}

def test_filter_by_num_ratings(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'num_ratings': 5000}
result = filter_dataframe(criteria)
assert len(result) == 2
assert set(result['Service']) == {'App1', 'App2'}

def test_filter_by_num_reviews(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'num_reviews': 2500}
result = filter_dataframe(criteria)
assert len(result) == 2
assert set(result['Service']) == {'App1', 'App2'}

def test_filter_by_free(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'Free': 'True'}
result = filter_dataframe(criteria)
assert len(result) == 2
assert set(result['Service']) == {'App1', 'App3'}

def test_filter_by_contains_ads(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'Contains Ads': 'False'}
result = filter_dataframe(criteria)
assert len(result) == 1
assert result.iloc[0]['Service'] == 'App2'

def test_multiple_criteria(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {
'privacy_rating': 'B',
'Free': 'False',
Expand All @@ -614,13 +614,13 @@ def test_multiple_criteria(sample_df):
assert result.iloc[0]['Service'] == 'App2'

def test_no_matching_results(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'privacy_rating': 'D'}
result = filter_dataframe(criteria)
assert len(result) == 0

def test_service_criterion_updates_genre_and_privacy_rating(sample_df):
with patch('your_module.df', sample_df):
with patch('recommend.df', sample_df):
criteria = {'Service': 'App2'}
result = filter_dataframe(criteria)
assert len(result) == 1
Expand Down

0 comments on commit 3bc3b51

Please sign in to comment.