Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ssssarah committed Nov 22, 2023
1 parent f784861 commit 13422bd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions kgforge/core/archetypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
from .read_only_store import ReadOnlyStore
from .model import Model
from .resolver import Resolver
from .dataset_store import DatasetStore
3 changes: 2 additions & 1 deletion kgforge/core/commons/sparql_query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def build_resource_from_response(
) -> List[Resource]:
_, q_comp = Query.parseString(query)
bindings = response["results"]["bindings"]

# FIXME workaround to parse a CONSTRUCT query, this fix depends on
# https://github.com/BlueBrain/nexus/issues/1155
if q_comp.name == "ConstructQuery":
return SPARQLQueryBuilder.build_resource_from_construct_query(bindings, context)

Expand Down
3 changes: 1 addition & 2 deletions kgforge/specializations/stores/bluebrain_nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,7 @@ def _sparql(self, query: str) -> List[Resource]:
BlueBrainNexus._catch_http_error(response, QueryingError)

data = response.json()
# FIXME workaround to parse a CONSTRUCT query, this fix depends on
# https://github.com/BlueBrain/nexus/issues/1155

context = self.model_context or self.context
return SPARQLQueryBuilder.build_resource_from_response(query, data, context)

Expand Down
34 changes: 17 additions & 17 deletions kgforge/specializations/stores/sparql_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Blue Brain Nexus Forge. If not, see <https://choosealicense.com/licenses/lgpl-3.0/>.

import json
from typing import Dict, List, Optional, Union, Any, Type
from rdflib.plugins.sparql.parser import Query
from SPARQLWrapper import SPARQLWrapper, JSON

from kgforge.core import Resource
from kgforge.core.archetypes import Mapper
from kgforge.core.archetypes.resolver import Resolver
from kgforge.core.archetypes.model import Model
from kgforge.specializations.mappers import DictionaryMapper
from kgforge.core.archetypes.dataset_store import DatasetStore
from kgforge.core.wrappings.dict import DictWrapper
from kgforge.specializations.mappers import DictionaryMapper
from kgforge.specializations.stores.sparql.sparql_service import SPARQLService
from kgforge.core.wrappings.paths import create_filters_from_dict
from kgforge.core.wrappings.dict import DictWrapper
from kgforge.core.commons.exceptions import QueryingError
from kgforge.core.commons.execution import not_supported
from kgforge.core.commons.sparql_query_builder import SPARQLQueryBuilder
Expand Down Expand Up @@ -60,7 +58,7 @@ def _download_one(
cross_bucket: bool,
) -> None:
# path: FilePath.
# TODO define dowloading method
# TODO define downloading method
# POLICY Should notify of failures with exception DownloadingError including a message.
not_supported()

Expand All @@ -75,8 +73,9 @@ def _retrieve_filename(self, id: str) -> str:
def get_metadata_context(self):
return self.service.context

def search(self, resolvers: Optional[List["Resolver"]] = None, *filters, **params
) -> List[Resource]:
def search(
self, resolvers: Optional[List["Resolver"]] = None, *filters, **params
) -> List[Resource]:
# Positional arguments in 'filters' are instances of type Filter from wrappings/paths.py
# A dictionary can be provided for filters:
# - {'key1': 'val', 'key2': {'key3': 'val'}} will be translated to
Expand Down Expand Up @@ -145,9 +144,8 @@ def _sparql(self, query: str) -> Optional[Union[Resource, List[Resource]]]:
raise QueryingError(e) from e

data = response.convert()
# FIXME workaround to parse a CONSTRUCT query, this fix depends on
# https://github.com/BlueBrain/nexus/issues/1155
context = self.model_context or self.context

context = self.model_context or self.context # TODO self.context?
return SPARQLQueryBuilder.build_resource_from_response(query, data, context)

def _search(self):
Expand All @@ -173,10 +171,12 @@ def _initialize_service(
store_context = store_config.pop('store_context', None)

except Exception as ve:
raise ValueError(f"Store configuration error: {ve}")
else:
return SPARQLService(endpoint=endpoint, model_context=self.model_context,
store_context=store_context, max_connection=max_connection,
searchendpoints=searchendpoints,
content_type=content_type,
accept=accept, **params)
raise ValueError(f"Store configuration error: {ve}") from ve

return SPARQLService(
endpoint=endpoint, model_context=self.model_context,
store_context=store_context, max_connection=max_connection,
searchendpoints=searchendpoints,
content_type=content_type,
accept=accept, **params
)

0 comments on commit 13422bd

Please sign in to comment.