sparna-git / Sparnatural

Sparnatural : visual knowledge graph explorer with SPARQL, in the browser, configurable with SHACL
http://sparnatural.eu
GNU Lesser General Public License v3.0
225 stars 43 forks source link

Query for List Widget Items changes drastically with 10.1.0? #678

Closed ch-sander closed 1 day ago

ch-sander commented 4 days ago

With the new release the List Widget gets a query such as

SELECT DISTINCT ?institution_1 ?institution_1_label WHERE {
  ?institution_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.graceful17.org/shacl/sparnatural-config/institution>.
  ?institution_1 <http://www.graceful17.org/shacl/sparnatural-config/called> ?institution_1_label.
  ?institution_1 <http://www.graceful17.org/shacl/sparnatural-config/has_main_type> ?type_2.
  ?type_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.graceful17.org/shacl/sparnatural-config/type>.
}

with the previous version it did not use the URIs of the SHACL config (NodeShape/PropertyShape) but of the actual T-Box, i.e. sh:class and sh:path. This worked well, the new query does not return labels:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
SELECT DISTINCT ?uri ?label
WHERE {
    ?domain <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.graceful17.org/ontology/institution> .
    ?domain <http://www.graceful17.org/ontology/has_main_type> ?uri .
    ?uri <http://www.graceful17.org/ontology/called> ?label .
    FILTER(lang(?label) = "" || lang(?label) = 'en')
    FILTER(isIRI(?uri))
}
ORDER BY UCASE(?label)
LIMIT 500

The actual query being generated is fine (including #620):

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX grace: <http://www.graceful17.org/ontology/>
SELECT DISTINCT ?institution_1 ?institution_1_label WHERE {
  ?institution_1 rdf:type grace:institution;
    grace:called ?institution_1_label;
    grace:has_main_type ?type_2.
  ?type_2 rdf:type grace:type.
}
LIMIT 10000

Am I missing something?

my SHACL: http://dataria.org/static/sparnatural/config.ttl. Example:

@prefix dash: <http://datashapes.org/dash#> .
@prefix g17sn: <http://www.graceful17.org/shacl/sparnatural-config/> .
@prefix geosparql: <http://www.opengis.net/ont/geosparql#> .
@prefix grace: <http://www.graceful17.org/ontology/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix sparnatural: <http://data.sparna.fr/ontologies/sparnatural-config-core#> .
@prefix sparnatural_datasource: <http://data.sparna.fr/ontologies/sparnatural-config-datasources#> .
@prefix volipi: <http://data.sparna.fr/ontologies/volipi#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

g17sn:called a sh:PropertyShape ;
    rdfs:label "called"@en ;
    sparnatural:enableOptional false ;
    volipi:message "A primary name of a resource" ;
    dash:propertyRole dash:LabelRole ;
    dash:searchWidget sparnatural:SearchProperty ;
    sh:description "A primary name of a resource" ;
    sh:name "called" ;
    sh:or ( [ sh:datatype xsd:string ;
                sh:nodeKind sh:Literal ] [ sh:datatype g17sn:name ;
                sh:node g17sn:name ;
                sh:nodeKind sh:Literal ] ) ;
    sh:order 1.0 ;
    sh:path grace:called .
tfrancart commented 4 days ago

Try to remove the "prefixes" attribute from the spar-natural element. I am pretty sure this is a bad side-effect of using prefixes. The search/replace cannot happen properly on datasources query

tfrancart commented 4 days ago

I cannot reproduce the issue. I tested with your config file on the same query. The SPARQL query sent by the datasource looks correct:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX grace: <http://www.graceful17.org/ontology/>
SELECT DISTINCT ?uri ?label WHERE {
  ?domain rdf:type grace:institution;
    grace:has_main_type ?uri.
  ?uri grace:called ?label.
  FILTER(((LANG(?label)) = "") || ((LANG(?label)) = "fr"))
  FILTER(ISIRI(?uri))
}
ORDER BY (UCASE(?label))
LIMIT 500
ch-sander commented 4 days ago

Try to remove the "prefixes" attribute from the spar-natural element. I am pretty sure this is a bad side-effect of using prefixes. The search/replace cannot happen properly on datasources query

I deleted the prefixes key in the config -- same odd result.

ch-sander commented 4 days ago

I tested with your config file on the same query.

You had been using your own instance of sparnatural or dataria.org/ask? I had returned to v10.0.0.

I tried back and forth and it works with .0 and not with .1

However the query starting with SELECT DISTINCT ?institution_1 ?institution_1_label WHERE above is NOT the problem, apologies.

The actual query is just not being generated (and not a faulty one).

Logs

10.0.0

Initial entity list http://www.graceful17.org/shacl/sparnatural-config/event,http://www.graceful17.org/shacl/sparnatural-config/object,http://www.graceful17.org/shacl/sparnatural-config/type,http://www.graceful17.org/shacl/sparnatural-config/place,http://www.graceful17.org/shacl/sparnatural-config/institution,http://www.graceful17.org/shacl/sparnatural-config/date,http://www.graceful17.org/shacl/sparnatural-config/person,http://www.graceful17.org/shacl/sparnatural-config/archive,http://www.graceful17.org/shacl/sparnatural-config/source,http://www.graceful17.org/shacl/sparnatural-config/entry,http://www.graceful17.org/shacl/sparnatural-config/monetary_value,http://www.graceful17.org/shacl/sparnatural-config/dedication,http://www.graceful17.org/shacl/sparnatural-config/anything SHACLSpecificationProvider.ts:407:12
rootNodes ClassTypeId.ts:293:12
Array [ {…} ]
ClassTypeId.ts:294:12
Array [ {…} ]
HierarchicalClassSelectBuilder.ts:526:14
Object { value: "http://www.graceful17.org/shacl/sparnatural-config/institution", path: "$http://www.graceful17.org/shacl/sparnatural-config/anything", icon: "fa-solid fa-university" }
ClassTypeId.ts:142:16
*** Sparnatural JSON Query *** GenerateQuery.ts:42:16
Object { distinct: true, variables: (1) […], order: null, branches: (1) […] }
GenerateQuery.ts:43:16
*** Sparnatural SPARQL Query *** GenerateQuery.ts:61:16
Object { queryType: "SELECT", distinct: true, variables: (2) […], type: "query", where: (2) […], prefixes: {…}, limit: 10000, group: undefined }
GenerateQuery.ts:62:16
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?institution_1 ?institution_1_label WHERE {
  ?institution_1 rdf:type <http://www.graceful17.org/ontology/institution>.
  ?institution_1 <http://www.graceful17.org/ontology/called> ?institution_1_label.
}
LIMIT 10000 SHACLSpecificationProvider.ts:337:12
Sparnatural JSON query structure: main.js:54:10
Object { distinct: true, variables: (1) […], order: null, branches: (1) […] }
main.js:55:10
Query : 
Object { distinct: true, variables: (1) […], order: null, branches: (1) […] }
sparnatural-yasgui-plugins.js:2:551856
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?institution_1 ?institution_1_label WHERE {
  ?institution_1 rdf:type <http://www.graceful17.org/ontology/institution>.
  ?institution_1 <http://www.graceful17.org/ontology/called> ?institution_1_label.
}
LIMIT 10000 SHACLSpecificationProvider.ts:337:12
id:http://www.graceful17.org/shacl/sparnatural-config/anything
  id:http://www.graceful17.org/shacl/sparnatural-config/event
    id:http://www.graceful17.org/shacl/sparnatural-config/papal_grace
      id:http://www.graceful17.org/shacl/sparnatural-config/apostolic_dispensation
      id:http://www.graceful17.org/shacl/sparnatural-config/apostolic_provision
  id:http://www.graceful17.org/shacl/sparnatural-config/object
    id:http://www.graceful17.org/shacl/sparnatural-config/immaterial_object
      id:http://www.graceful17.org/shacl/sparnatural-config/absolution
      id:http://www.graceful17.org/shacl/sparnatural-config/benefice
      id:http://www.graceful17.org/shacl/sparnatural-config/coadjutary
      id:http://www.graceful17.org/shacl/sparnatural-config/commenda
      id:http://www.graceful17.org/shacl/sparnatural-config/dispensation
      id:http://www.graceful17.org/shacl/sparnatural-config/indult
      id:http://www.graceful17.org/shacl/sparnatural-config/pension
  id:http://www.graceful17.org/shacl/sparnatural-config/type
  id:http://www.graceful17.org/shacl/sparnatural-config/place
    id:http://www.graceful17.org/shacl/sparnatural-config/continent
    id:http://www.graceful17.org/shacl/sparnatural-config/locality
    id:http://www.graceful17.org/shacl/sparnatural-config/location
    id:http://www.graceful17.org/shacl/sparnatural-config/region
    id:http://www.graceful17.org/shacl/sparnatural-config/subregion
  id:http://www.graceful17.org/shacl/sparnatural-config/institution
    id:http://www.graceful17.org/shacl/sparnatural-config/archdeanery
    id:http://www.graceful17.org/shacl/sparnatural-config/deanery
    id:http://www.graceful17.org/shacl/sparnatural-config/diocese
      id:http://www.graceful17.org/shacl/sparnatural-config/archdiocese
      id:http://www.graceful17.org/shacl/sparnatural-config/suffragan_diocese
    id:http://www.graceful17.org/shacl/sparnatural-config/ecclesiastical_province
    id:http://www.graceful17.org/shacl/sparnatural-config/parish
    id:http://www.graceful17.org/shacl/sparnatural-config/seat_of_worship
    id:http://www.graceful17.org/shacl/sparnatural-config/supreme_body_of_government
    id:http://www.graceful17.org/shacl/sparnatural-config/vicariate
  id:http://www.graceful17.org/shacl/sparnatural-config/date
  id:http://www.graceful17.org/shacl/sparnatural-config/person
    id:http://www.graceful17.org/shacl/sparnatural-config/natural_person
  id:http://www.graceful17.org/shacl/sparnatural-config/archive
    id:http://www.graceful17.org/shacl/sparnatural-config/physical_archive
  id:http://www.graceful17.org/shacl/sparnatural-config/source
    id:http://www.graceful17.org/shacl/sparnatural-config/physical_source
      id:http://www.graceful17.org/shacl/sparnatural-config/textual_source
        id:http://www.graceful17.org/shacl/sparnatural-config/serial_source
  id:http://www.graceful17.org/shacl/sparnatural-config/entry
    id:http://www.graceful17.org/shacl/sparnatural-config/narrative
    id:http://www.graceful17.org/shacl/sparnatural-config/record
  id:http://www.graceful17.org/shacl/sparnatural-config/monetary_value
  id:http://www.graceful17.org/shacl/sparnatural-config/dedication
    id:http://www.graceful17.org/shacl/sparnatural-config/mystery_of_faith
    id:http://www.graceful17.org/shacl/sparnatural-config/saint
  id:http://www.graceful17.org/shacl/sparnatural-config/appellation
id:http://www.graceful17.org/shacl/sparnatural-config/map
id:http://www.graceful17.org/shacl/sparnatural-config/name
id:http://www.graceful17.org/shacl/sparnatural-config/number
id:http://special/ZZ_Other
SHACLSpecificationEntity.ts:212:16
rootNodes ClassTypeId.ts:293:12
Array(5) [ {…}, {…}, {…}, {…}, {…} ]
ClassTypeId.ts:294:12
Array(5) [ {…}, {…}, {…}, {…}, {…} ]
HierarchicalClassSelectBuilder.ts:526:14
Object { value: "http://www.graceful17.org/shacl/sparnatural-config/type", path: "$http://www.graceful17.org/shacl/sparnatural-config/anything", icon: "fa-solid fa-tags" }
ClassTypeId.ts:142:16
rootNodes ObjectPropertyTypeId.ts:189:12
Array(5) [ {…}, {…}, {…}, {…}, {…} ]
ObjectPropertyTypeId.ts:190:12
Array(5) [ {…}, {…}, {…}, {…}, {…} ]
HierarchicalClassSelectBuilder.ts:526:14
Object { value: "http://www.graceful17.org/shacl/sparnatural-config/has_main_type", path: "", icon: null }
ObjectPropertyTypeId.ts:128:16
widget component already there, rendering widget component WidgetWrapper.ts:70:14
rendering message 'searching...' LoadingSpinner.ts:21:16

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
SELECT DISTINCT ?uri ?label
WHERE {
    ?domain <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.graceful17.org/ontology/institution> .
    ?domain <http://www.graceful17.org/ontology/has_main_type> ?uri .
    ?uri <http://www.graceful17.org/ontology/called> ?label .
    FILTER(lang(?label) = "" || lang(?label) = 'en')
    FILTER(isIRI(?uri))
}
ORDER BY UCASE(?label)
LIMIT 500
SHACLSpecificationProvider.ts:337:12
rendering message '' LoadingSpinner.ts:21:16

10.1.0

Object { value: "http://www.graceful17.org/shacl/sparnatural-config/institution", path: "$http://www.graceful17.org/shacl/sparnatural-config/anything", icon: "fa-solid fa-university" }
ClassTypeId.ts:142:16
settings 
Object { src: "/static/sparnatural/config.ttl", language: "en", defaultLanguage: "en", typePredicate: "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>", maxDepth: 4, maxOr: 3, debug: true, addDistinct: true, limit: 10000, endpoints: (1) […], … }
GenerateQuery.ts:30:12
*** Sparnatural JSON Query *** GenerateQuery.ts:41:16
Object { distinct: true, variables: (1) […], order: null, branches: (1) […] }
GenerateQuery.ts:42:16
The requested property null is unknown in the configuration. We cannot find any triple with this URI as subject. SHACLSpecificationProvider.ts:386:14
*** Sparnatural SPARQL Query OLD *** GenerateQuery.ts:61:16
Object { queryType: "SELECT", distinct: true, variables: (2) […], type: "query", where: (2) […], prefixes: {…}, limit: 10000, group: undefined }
GenerateQuery.ts:62:16
The requested property null is unknown in the configuration. We cannot find any triple with this URI as subject. SHACLSpecificationProvider.ts:386:14
SpraqlQuery variables 
Array [ {…} ]
JsonSparqlTranslator.ts:218:12
*** Sparnatural SPARQL Query NEW *** GenerateQuery.ts:77:16
Object { queryType: "SELECT", distinct: true, variables: (2) […], type: "query", where: (2) […], prefixes: {}, limit: undefined, group: undefined }
GenerateQuery.ts:78:16
*** Sparnatural SPARQL Query from JSON *** GenerateQuery.ts:84:16
SELECT DISTINCT ?institution_1 ?institution_1_label WHERE {
  ?institution_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.graceful17.org/shacl/sparnatural-config/institution>.
  ?institution_1 <http://www.graceful17.org/shacl/sparnatural-config/called> ?institution_1_label.
} GenerateQuery.ts:85:16
Sparnatural JSON query structure: main.js:54:10
Object { distinct: true, variables: (1) […], order: null, branches: (1) […] }
main.js:55:10
Query : 
Object { distinct: true, variables: (1) […], order: null, branches: (1) […] }
sparnatural-yasgui-plugins.js:2:551856
id:http://www.graceful17.org/shacl/sparnatural-config/anything
  id:http://www.graceful17.org/shacl/sparnatural-config/event
    id:http://www.graceful17.org/shacl/sparnatural-config/papal_grace
      id:http://www.graceful17.org/shacl/sparnatural-config/apostolic_dispensation
      id:http://www.graceful17.org/shacl/sparnatural-config/apostolic_provision
  id:http://www.graceful17.org/shacl/sparnatural-config/object
    id:http://www.graceful17.org/shacl/sparnatural-config/immaterial_object
      id:http://www.graceful17.org/shacl/sparnatural-config/absolution
      id:http://www.graceful17.org/shacl/sparnatural-config/benefice
      id:http://www.graceful17.org/shacl/sparnatural-config/coadjutary
      id:http://www.graceful17.org/shacl/sparnatural-config/commenda
      id:http://www.graceful17.org/shacl/sparnatural-config/dispensation
      id:http://www.graceful17.org/shacl/sparnatural-config/indult
      id:http://www.graceful17.org/shacl/sparnatural-config/pension
  id:http://www.graceful17.org/shacl/sparnatural-config/type
  id:http://www.graceful17.org/shacl/sparnatural-config/place
    id:http://www.graceful17.org/shacl/sparnatural-config/continent
    id:http://www.graceful17.org/shacl/sparnatural-config/locality
    id:http://www.graceful17.org/shacl/sparnatural-config/location
    id:http://www.graceful17.org/shacl/sparnatural-config/region
    id:http://www.graceful17.org/shacl/sparnatural-config/subregion
  id:http://www.graceful17.org/shacl/sparnatural-config/institution
    id:http://www.graceful17.org/shacl/sparnatural-config/archdeanery
    id:http://www.graceful17.org/shacl/sparnatural-config/deanery
    id:http://www.graceful17.org/shacl/sparnatural-config/diocese
      id:http://www.graceful17.org/shacl/sparnatural-config/archdiocese
      id:http://www.graceful17.org/shacl/sparnatural-config/suffragan_diocese
    id:http://www.graceful17.org/shacl/sparnatural-config/ecclesiastical_province
    id:http://www.graceful17.org/shacl/sparnatural-config/parish
    id:http://www.graceful17.org/shacl/sparnatural-config/seat_of_worship
    id:http://www.graceful17.org/shacl/sparnatural-config/supreme_body_of_government
    id:http://www.graceful17.org/shacl/sparnatural-config/vicariate
  id:http://www.graceful17.org/shacl/sparnatural-config/date
  id:http://www.graceful17.org/shacl/sparnatural-config/person
    id:http://www.graceful17.org/shacl/sparnatural-config/natural_person
  id:http://www.graceful17.org/shacl/sparnatural-config/archive
    id:http://www.graceful17.org/shacl/sparnatural-config/physical_archive
  id:http://www.graceful17.org/shacl/sparnatural-config/source
    id:http://www.graceful17.org/shacl/sparnatural-config/physical_source
      id:http://www.graceful17.org/shacl/sparnatural-config/textual_source
        id:http://www.graceful17.org/shacl/sparnatural-config/serial_source
  id:http://www.graceful17.org/shacl/sparnatural-config/entry
    id:http://www.graceful17.org/shacl/sparnatural-config/narrative
    id:http://www.graceful17.org/shacl/sparnatural-config/record
  id:http://www.graceful17.org/shacl/sparnatural-config/monetary_value
  id:http://www.graceful17.org/shacl/sparnatural-config/dedication
    id:http://www.graceful17.org/shacl/sparnatural-config/mystery_of_faith
    id:http://www.graceful17.org/shacl/sparnatural-config/saint
  id:http://www.graceful17.org/shacl/sparnatural-config/appellation
id:http://www.graceful17.org/shacl/sparnatural-config/map
id:http://www.graceful17.org/shacl/sparnatural-config/name
id:http://www.graceful17.org/shacl/sparnatural-config/number
id:http://special/ZZ_Other
SHACLSpecificationEntity.ts:212:16
rootNodes ClassTypeId.ts:293:12
Array(5) [ {…}, {…}, {…}, {…}, {…} ]
ClassTypeId.ts:294:12
Array(5) [ {…}, {…}, {…}, {…}, {…} ]
HierarchicalClassSelectBuilder.ts:526:14
Source-Map-Fehler: Error: request failed with status 404
Ressourcen-Adresse: https://dataria.org/static/sparnatural/sparnatural-yasgui-plugins.js
Source-Map-Adresse: sparnatural-yasgui-plugins.js.map
Object { value: "http://www.graceful17.org/shacl/sparnatural-config/type", path: "$http://www.graceful17.org/shacl/sparnatural-config/anything", icon: "fa-solid fa-tags" }
ClassTypeId.ts:142:16
rootNodes ObjectPropertyTypeId.ts:189:12
Array(5) [ {…}, {…}, {…}, {…}, {…} ]
ObjectPropertyTypeId.ts:190:12
Array(5) [ {…}, {…}, {…}, {…}, {…} ]
HierarchicalClassSelectBuilder.ts:526:14
Object { value: "http://www.graceful17.org/shacl/sparnatural-config/has_main_type", path: "", icon: null }
ObjectPropertyTypeId.ts:128:16
widget component already there, rendering widget component WidgetWrapper.ts:57:14
rendering message 'searching...' LoadingSpinner.ts:21:16
rendering message '' LoadingSpinner.ts:21:16

I don't change my config.ttl, obviously.

The issue might be:

The requested property null is unknown in the configuration. We cannot find any triple with this URI as subject. SHACLSpecificationProvider.ts:386:14

There's also an issue with binding sparnatural-yasgui-plugins.js -- maybe unrelated.

ch-sander commented 4 days ago

Issue maybe in https://dataria.org/static/sparnatural/main.js ?

ch-sander commented 4 days ago

https://github.com/sparna-git/Sparnatural/blob/22adb82adc2356d7ce93e56411019571667a56c3/src/sparnatural/spec-providers/shacl/SHACLSpecificationProvider.ts#L384-L396

tfrancart commented 4 days ago

10.1.0 is buggy, apologies. I would like to help but I don't understand the issue. What is the symptom you observe ? please don't try to find the solution, simply describe the symptom with a reproductible test case based on your config. If the symptom is "the list widget dropdown lists are not populated anymore", it has nothing to do with the query, or the config reading, it was something else.

ch-sander commented 4 days ago

Sure!

The symptom is as simple as that grafik The dropdown won't load any items.

I started from scratch, forked, put the 10.1.0 release files in https://github.com/ch-sander/Sparnatural/tree/master/hello-sparnatural and tried again, same behavior.

https://github.com/ch-sander/Sparnatural/blob/09caa1ced1ac4be63f8c9c2356d4001bf47a0182/hello-sparnatural/index.html#L68-L76

So, while in 10.0.0 webpack://sparnatural/src/sparnatural/spec-providers/shacl/SHACLSpecificationProvider.ts logs a query (for ?uri and ?label) for the datasource in the log, 10.1.0 doesn't in all my attempts to replicate.

ch-sander commented 2 days ago

NB: My endpoint is under dev currently, might impact the possibility to reproduce the error.

tfrancart commented 2 days ago

Can you test with 10.1.1 and report back ? Thanks

ch-sander commented 2 days ago

Can you test with 10.1.1 and report back ? Thanks

I have to thank you! Will do asap!

ch-sander commented 1 day ago

@tfrancart I think it's working now. Thank you so much!