Skip to content

Commit

Permalink
[ENH] Refactored directory and module names (#26)
Browse files Browse the repository at this point in the history
* Refactored directory and module names

* Refactor api_construction to api
  • Loading branch information
Raya679 authored Jul 31, 2024
1 parent 6d2f7cb commit bf714a4
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

- run python file
```
python3 -m app.api.get_apiURL
python3 -m app.api.url_generator
```


10 changes: 5 additions & 5 deletions app/api/get_apiURL.py → app/api/url_generator.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import json
from app.LLM_extractions.extractions import extract_information
from app.api.validations import (
from app.llm_processing.extractions import extract_information
from app.api.validators import (
validate_age_order,
validate_diagnosis_and_control,
)
from app.fetch_termURLs.get_termURLs import (
from app.term_url_processing.term_url_mapper import (
get_diagnosis_termURL,
get_assessment_termURL,
get_sex_termURL,
get_image_modality_termURL,
)


def getApiURL(user_query: str) -> str:
def get_api_url(user_query: str) -> str:
"""
Constructs the API URL using extracted parameters from the user's query.
Expand Down Expand Up @@ -131,6 +131,6 @@ def getApiURL(user_query: str) -> str:
if user_query.lower() == "exit":
break

api_url = getApiURL(user_query)
api_url = get_api_url(user_query)
print("Response:", api_url)
print("")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

sys.path.append(
os.path.dirname(os.path.realpath(__file__))
) # Fixes relative import error.
) # Fixes relative import error.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests
from typing import Optional, Dict, Any
import difflib
from termURL_mappings import (
from term_url_mappings import (
sex_mapping,
diagnosis_url,
assessment_url,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_extractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import warnings
from typing import Dict
from unittest.mock import patch
from app.LLM_extractions.extractions import extract_information, main
from app.llm_processing.extractions import extract_information, main


@pytest.mark.parametrize(
Expand Down
8 changes: 4 additions & 4 deletions tests/test_get_termURLs.py → tests/test_term_url_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from requests.exceptions import RequestException
from unittest.mock import patch
from typing import List, Dict
from app.fetch_termURLs.get_termURLs import (
from app.term_url_processing.term_url_mapper import (
fetch_termURL_mappings,
get_diagnosis_termURL,
get_assessment_termURL,
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_get_diagnosis_termURL(diagnosis: str, expected_termURL: str) -> None:
}

with patch(
"app.fetch_termURLs.get_termURLs.fetch_termURL_mappings",
"app.term_url_processing.term_url_mapper.fetch_termURL_mappings",
return_value=mock_diagnosis_response,
):
diagnosis_termURL = get_diagnosis_termURL(diagnosis)
Expand Down Expand Up @@ -125,7 +125,7 @@ def test_get_assessment_termURL(
}

with patch(
"app.fetch_termURLs.get_termURLs.fetch_termURL_mappings",
"app.term_url_processing.term_url_mapper.fetch_termURL_mappings",
return_value=mock_assessment_response,
):
assessment_termURL = get_assessment_termURL(assessment)
Expand Down Expand Up @@ -176,7 +176,7 @@ def test_get_image_modality_termURL(
]

with patch(
"app.fetch_termURLs.get_termURLs.image_modality_mapping",
"app.term_url_processing.term_url_mapper.image_modality_mapping",
mock_image_modality_response,
):
image_modality_termURL = get_image_modality_termURL(image_modality)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_get_apiURL.py → tests/test_url_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from unittest.mock import patch
from app.api.get_apiURL import getApiURL
from app.api.url_generator import get_api_url

# Define the mock responses for diagnosis and assessment term URLs
mock_diagnosis_mappings = {
Expand Down Expand Up @@ -67,18 +67,18 @@
],
)
@patch(
"app.api.get_apiURL.get_diagnosis_termURL",
"app.api.url_generator.get_diagnosis_termURL",
side_effect=lambda diagnosis: mock_diagnosis_mappings.get(
diagnosis, "None"
),
)
@patch(
"app.api.get_apiURL.get_assessment_termURL",
"app.api.url_generator.get_assessment_termURL",
side_effect=lambda assessment: mock_assessment_mappings.get(
assessment, "None"
),
)
def test_getApiURL(
def test_get_api_url(
mock_get_diagnosis_termURL,
mock_get_assessment_termURL,
user_query,
Expand All @@ -87,12 +87,12 @@ def test_getApiURL(
expected_output,
):
with patch(
"app.api.get_apiURL.extract_information",
"app.api.url_generator.extract_information",
return_value=mock_llm_response,
):
if mock_input_side_effect is not None:
with patch("builtins.input", side_effect=mock_input_side_effect):
result = getApiURL(user_query)
result = get_api_url(user_query)
else:
result = getApiURL(user_query)
result = get_api_url(user_query)
assert result == expected_output
2 changes: 1 addition & 1 deletion tests/test_validations.py → tests/test_validators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from unittest.mock import patch
from app.api.validations import (
from app.api.validators import (
validate_age_order,
validate_diagnosis_and_control,
)
Expand Down

0 comments on commit bf714a4

Please sign in to comment.