Skip to content

Commit

Permalink
Updated to load model from a given library location (optionally)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvsoest committed Aug 7, 2023
1 parent 114be06 commit 5b77dba
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/ModelEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ class ModelEngine:
"""
Base class to fetch model specifications, and select the execution type of the model.
"""
def __init__(self, modelUri, sparqlEndpoint=None):
def __init__(self, modelUri, sparqlEndpoint=None, libraryLocation=None):
self.__graph = rdflib.Graph()
self.__libraryLocation = libraryLocation
self.__modelUri = modelUri
if sparqlEndpoint is None:
self.__graph.parse(modelUri, format=rdflib.util.guess_format(modelUri))
Expand All @@ -259,7 +260,11 @@ def __getFromEndpoint(self, modelUri, sparqlEndpoint):
return results.serialize(format='xml')
def __getSparqlQueryFromFile(self, queryName, mappings=None):
query = ""
with open(os.path.join("queries", queryName + ".sparql")) as f:
if self.__libraryLocation is not None:
pathForQuery = os.path.join(self.__libraryLocation, "queries", queryName + ".sparql")
else:
pathForQuery = os.path.join("queries", queryName + ".sparql")
with open(pathForQuery) as f:
query = f.read()
if mappings is not None:
temp_obj = Template(query)
Expand Down

0 comments on commit 5b77dba

Please sign in to comment.