Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model querying, loading local ontology in memory #351

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

ssssarah
Copy link
Contributor

@ssssarah ssssarah commented Oct 24, 2023

DKE-1239

  • Added sparql method to Model archetype.
  • Added get_context_prefix_vocab abstract method to Model archetype: the reason for this is that when rewriting sparql queries, you need to use the context. However, BlueBrainNexus (the store) cannot simply just use a Context object, because it is merging the metadata context's document with the data context's document, and keeping data context's vocab, and the data context's prefixes. As a result, if you want to use the SparqlQueryBuilder (to do sparql queries, which is what we're trying to enable), you need to implement this function that returns prefixes, a context document (as a dict) and prefixes.
  • Moved the transformation of Context into a dict from the ReadOnlyStore to the Context class: formatting the Context is no longer just a ReadOnlyStore's concern, but a Model may need to as well. In any case, it's the manipulation of a Context, so it makes sense for it to live there.
  • get_model and get_store accessors in KnowledgeGraphForge
  • RdfModelService : _build_shapes_map method to implement: it returns the shapes into a Graph, a dictionary indicating the source the shape originates from, and a dictionary that says which class is constrained by which shape. By centralizing it in the same method (which was not the case before), it enables knowing which file contained which schema (for the implementation in RdfModelServiceFromDirectory)
  • RdfModelServiceFromDirectory : formerly named DirectoryService, get_shape_source can now be implemented (formerly named schema_source_id) due to the change in RdfModelService base class
  • specializations.stores.service : bug with the context cache not being used fixed

@ssssarah ssssarah force-pushed the local_rdf_store branch 3 times, most recently from 68d2bfe to 93c99d4 Compare October 24, 2023 14:04
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the parameter ontology, I assume a dummy ontology file would be more appropriate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you could keep just a part of the file, not all of it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the file shorter

@ssssarah ssssarah marked this pull request as ready for review October 24, 2023 15:38
kgforge/core/commons/sparql_query_rewriter.py Outdated Show resolved Hide resolved
kgforge/core/commons/sparql_query_rewriter.py Outdated Show resolved Hide resolved
kgforge/core/commons/sparql_query_rewriter.py Outdated Show resolved Hide resolved
kgforge/specializations/models/demo_model.py Outdated Show resolved Hide resolved
@@ -151,12 +159,16 @@ def _load_shape(self, resource_id):
for dependency in shape.imports:
self._load_shape(self.context.expand(dependency))

def _type_shape(self, iri: URIRef):
def _load_and_get_type_shape(self, iri: URIRef) -> ShapeWrapper:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual return type is Shape.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_shapes_graph is a ShapesGraphWrapper, and the lookup_shape_from_node method is overridden, and the shape is being wrapped in a ShapeWrapper, no?

kgforge/specializations/models/rdf_model.py Outdated Show resolved Hide resolved
tests/data/shacl-model/commons/ontology-1.ttl Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Oct 25, 2023

Codecov Report

Attention: 69 lines in your changes are missing coverage. Please review.

Comparison is base (2e616cd) 74.36% compared to head (e05ca33) 74.45%.

Files Patch % Lines
...zations/models/rdf/rdf_model_service_from_store.py 23.33% 23 Missing ⚠️
kgforge/specializations/stores/nexus/service.py 50.00% 12 Missing ⚠️
...ge/specializations/models/rdf/rdf_model_service.py 72.22% 10 Missing ⚠️
kgforge/core/commons/es_query_builder.py 28.57% 5 Missing ⚠️
kgforge/specializations/stores/bluebrain_nexus.py 63.63% 4 Missing ⚠️
kgforge/specializations/models/rdf_model.py 86.36% 3 Missing ⚠️
kgforge/core/archetypes/model.py 89.47% 2 Missing ⚠️
kgforge/core/archetypes/store.py 71.42% 2 Missing ⚠️
kgforge/core/forge.py 50.00% 2 Missing ⚠️
kgforge/specializations/models/demo_model.py 60.00% 2 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #351      +/-   ##
==========================================
+ Coverage   74.36%   74.45%   +0.08%     
==========================================
  Files         100      101       +1     
  Lines        6315     6376      +61     
==========================================
+ Hits         4696     4747      +51     
- Misses       1619     1629      +10     
Flag Coverage Δ
unittests 74.45% <72.50%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ssssarah ssssarah force-pushed the local_rdf_store branch 3 times, most recently from db7a865 to 651f198 Compare October 30, 2023 16:39
@ssssarah ssssarah changed the title load ontologies Model querying, loading local ontology in memory Nov 28, 2023
@ssssarah
Copy link
Contributor Author

Hasn't been updated in a while, out of sync, to refresh

@ssssarah ssssarah marked this pull request as draft July 19, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants