Skip to content

Commit

Permalink
Merge pull request #241 from CLARIAH/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
c-martinez authored Jan 6, 2020
2 parents ddd9d06 + 1f48d4a commit d038756
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 149 deletions.
10 changes: 10 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 1

update_configs:
- package_manager: "python"
directory: "/python/helpers"
update_schedule: "monthly"
target_branch: "dev"
default_reviewers:
- "albertmeronyo"
- "c-martinez"
3 changes: 0 additions & 3 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,5 @@ if [[ $TRAVIS_BUILD_STAGE_NAME == 'Deploy' ]]; then
fi

pip install --upgrade pip

# Horrible hack -- but we should remove pythonql functionality soon anyway...
pip install pythonql3
pip install .
pip install -r requirements-test.txt
8 changes: 0 additions & 8 deletions src/fileLoaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ def getTextForName(self, query_name):
# No query found...
return '', None

def getProjectionForQueryName(self, query_name):
""" TODO: DOCUMENT !!
Returns None if no such projection exists
"""
projectionFileName = query_name + '.pyql'
projectionText = self._getText(projectionFileName)
return projectionText

def getLicenceURL(self):
for f in self.fetchFiles():
if f['name'].lower() == 'license' or f['name'].lower() == 'licence':
Expand Down
34 changes: 0 additions & 34 deletions src/projection.py

This file was deleted.

19 changes: 5 additions & 14 deletions src/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def get_path_for_item(item):

description = item['description']
description += '\n\n```{}```'.format(query)
description += '\n\nSPARQL projection:\n```pythonql\n{}```'.format(
item['projection']) if 'projection' in item else ''
description += '\n\nSPARQL transformation:\n```json\n{}```'.format(
item['transform']) if 'transform' in item else ''

item_path = {
item['method']: {
Expand Down Expand Up @@ -98,8 +98,6 @@ def get_path_for_item(item):
}
}
}
if 'projection' in item:
item_path['projection'] = item['projection']
return item_path


Expand Down Expand Up @@ -207,9 +205,6 @@ def process_sparql_query_text(query_text, loader, call_name, extraMetadata):

endpoint_in_url = query_metadata['endpoint_in_url'] if 'endpoint_in_url' in query_metadata else True

projection = loader.getProjectionForQueryName(call_name)
glogger.debug('Projection: '.format(projection))

# Processing of the parameters
params = []

Expand Down Expand Up @@ -294,28 +289,24 @@ def process_sparql_query_text(query_text, loader, call_name, extraMetadata):
glogger.warning("Query of type {} is currently unsupported! Skipping".format(query_metadata['type']))

# Finally: main structure of the callname spec
item = packItem('/' + call_name, method, tags, summary, description, params, query_metadata, extraMetadata,
projection)
item = packItem('/' + call_name, method, tags, summary, description, params, query_metadata, extraMetadata)

return item


def packItem(call_name, method, tags, summary, description, params, query_metadata, extraMetadata, projection=None):
def packItem(call_name, method, tags, summary, description, params, query_metadata, extraMetadata):
item = {
'call_name': call_name,
'method': method,
'tags': tags,
'summary': summary,
'description': description,
'params': params,
'item_properties': None, # From projection variables, only SelectQuery
'item_properties': None,
'query': query_metadata['query'],
'original_query': query_metadata.get('original_query', query_metadata['query'])
}

if projection:
item['projection'] = projection # SPARQL projection PyQL file is available

for extraField in extraMetadata:
if extraField in query_metadata:
item[extraField] = query_metadata[extraField]
Expand Down
8 changes: 2 additions & 6 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from grlc.prov import grlcPROV
from grlc.fileLoaders import GithubLoader, LocalLoader, ParamLoader
from grlc.queryTypes import qType
from grlc.projection import project
from grlc import __version__ as grlc_version

import re
Expand Down Expand Up @@ -90,11 +89,8 @@ def dispatch_query(user, repo, query_name, subdir=None, sha=None, content=None,
requestUrl)

if acceptHeader == 'application/json':
projection = loader.getProjectionForQueryName(query_name)
if projection:
dataIn = json.loads(resp)
dataOut = project(dataIn, projection)
resp = json.dumps(dataOut)
# TODO: transform JSOn result if suitable
pass

return resp, status, headers
# Call name implemented with TPF query
Expand Down
47 changes: 0 additions & 47 deletions tests/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,3 @@ def mock_requestsGithub(uri, headers={}, params={}):
]
}
}

mock_sparqlResponse = {
"head": {
"link": [],
"vars": [ "country_name", "capital_name", "population" ]
},
"results": {
"distinct": "false",
"ordered": "true",
"bindings": [
{
"country_name": {
"type": "literal",
"xml:lang": "en",
"value": "Albania"
},
"capital_name": {
"type": "literal",
"xml:lang": "en",
"value": "Tirana"
},
"population": {
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
"value": "2886026"
}
},
{
"country_name": {
"type": "literal",
"xml:lang": "en",
"value": "Algeria"
},
"capital_name": {
"type": "literal",
"xml:lang": "en",
"value": "Algiers"
},
"population": {
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
"value": "40400000"
}
}
]
}
}
36 changes: 0 additions & 36 deletions tests/test_projection.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def setMockGetResponse(self):


@patch('requests.get')
def test_projection(self, mock_get):
def test_dispatch_SPARQL_query(self, mock_get):
mock_get.return_value = self.setMockGetResponse()

rq, _ = self.loader.getTextForName('test-projection')
Expand Down

0 comments on commit d038756

Please sign in to comment.