Skip to content

Commit

Permalink
Merge pull request #9 from odissei-data/development
Browse files Browse the repository at this point in the history
Changed the env setup to fix the tests.
  • Loading branch information
FjodorvRijsselberg authored Apr 5, 2023
2 parents 2463663 + 2579606 commit 7d9ba1f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dot_env_example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PYTHONPATH: "/root/src/"
# URL'S
KEYWORD_VOCABULARY_URL='https://fuseki.odissei.nl/skosmos/sparql'
VARIABLE_VOCABULARY_URL='https://fuseki.odissei.nl/skosmos/sparql'
GRLC_API_URL='https://grlc.odissei.nl/api-git/odissei-data/grlc/'
ROOT_API_URL='https://grlc.odissei.nl/api-git/odissei-data/grlc/'

# Endpoints
KEYWORD_ENDPOINT='matchElsstTermForKeyword'
Expand Down
6 changes: 2 additions & 4 deletions src/enhancers/MetadataEnhancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

from .utils import _try_for_key

GRLC_API_URL = os.environ['GRLC_API_URL']


class MetadataEnhancer:
""" A super class used for enhancing Dataverse metadata.
Expand Down Expand Up @@ -64,7 +62,7 @@ def get_value_from_metadata(self, metadata_field_name: str,
return metadata_field['value']

def query_matched_terms(self, value_to_match: str) -> dict:
""" Queries a grlc endpoint for terms matching the given value.
""" Queries an endpoint for terms matching the given value.
:param value_to_match: The value to use for finding matches.
"""
Expand All @@ -79,7 +77,7 @@ def query_matched_terms(self, value_to_match: str) -> dict:
'endpoint': self.sparql_endpoint,
}

url = GRLC_API_URL + self.endpoint
url = self.endpoint
response = requests.get(
url,
params=params,
Expand Down
5 changes: 3 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

app = FastAPI()

ROOT_API_URL = os.environ['ROOT_API_URL']
KEYWORD_ENDPOINT = os.environ['KEYWORD_ENDPOINT']
VARIABLE_ENDPOINT = os.environ['VARIABLE_ENDPOINT']
KEYWORD_VOCABULARY_URL = os.environ['KEYWORD_VOCABULARY_URL']
Expand All @@ -26,7 +27,7 @@ async def dataverse_keyword_enhancer(
enhancer_input: EnhancerInput) -> dict:
keyword_enhancer = KeywordEnhancer(
enhancer_input.metadata,
KEYWORD_ENDPOINT,
ROOT_API_URL + KEYWORD_ENDPOINT,
KEYWORD_VOCABULARY_URL
)
keyword_enhancer.enhance_metadata()
Expand All @@ -37,7 +38,7 @@ async def dataverse_keyword_enhancer(
async def dataverse_metadata_enhancer(enhancer_input: EnhancerInput) -> dict:
variable_enhancer = VariableEnhancer(
enhancer_input.metadata,
VARIABLE_ENDPOINT,
ROOT_API_URL + VARIABLE_ENDPOINT,
VARIABLE_VOCABULARY_URL
)
variable_enhancer.enhance_metadata()
Expand Down
4 changes: 2 additions & 2 deletions src/tests/test_enhancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def cbs_variable_output():
def keyword_enhancer(cbs_metadata):
return KeywordEnhancer(
cbs_metadata,
'https://grlc.odissei.nl/api-git/odissei-data/grlc/'
'matchElsstTermForKeyword',
'https://fuseki.odissei.nl/skosmos/sparql'
)
Expand All @@ -38,7 +39,7 @@ def keyword_enhancer(cbs_metadata):
def variable_enhancer(cbs_metadata):
return VariableEnhancer(
cbs_metadata,
'getCbsVarUri',
'https://grlc.odissei.nl/api-git/odissei-data/grlc/getCbsVarUri',
'https://fuseki.odissei.nl/skosmos/sparql'
)

Expand Down Expand Up @@ -84,7 +85,6 @@ def test_query_matched_terms(variable_enhancer):
assert 'bindings' in terms_dict['results']
assert len(terms_dict['results']['bindings']) == 0


# def test_add_terms_to_metadata(variable_enhancer):
# # Test adding terms to a variable metadata field
# terms = [
Expand Down

0 comments on commit 7d9ba1f

Please sign in to comment.