Skip to content

Commit

Permalink
Fix for loading remote datasets. Also load the default graph
Browse files Browse the repository at this point in the history
  • Loading branch information
IKCAP committed May 22, 2024
1 parent 86e0cc5 commit 2416b10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pylipd/globals/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
UNITSURL = "http://linked.earth/ontology/units"
VARIABLEURL = "http://linked.earth/ontology/variables"

DEFAULT_GRAPH_URI = "http://www.openrdf.org/schema/sesame#nil"

NAMESPACES = {
"wgs84": "http://www.w3.org/2003/01/geo/wgs84_pos#",
"le_archive": ARCHIVEURL,
Expand Down
7 changes: 5 additions & 2 deletions pylipd/lipd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from doi2bib import crossref
from pybtex.database import BibliographyData, Entry

from .globals.urls import NSURL
from .globals.urls import NSURL, DEFAULT_GRAPH_URI

class LiPD(RDFGraph):
'''The LiPD class describes a `LiPD (Linked Paleo Data) <https://cp.copernicus.org/articles/12/1093/2016/cp-12-1093-2016.html>`_ object. It contains an `RDF <https://www.w3.org/RDF/>`_ Graph which is serialization of the LiPD data into an RDF graph containing terms from the `LiPD Ontology <http://linked.earth/Ontology/release/core/1.2.0/index-en.html>`
Expand Down Expand Up @@ -184,7 +184,7 @@ def convert_lipd_dir_to_rdf(self, lipd_dir, rdf_file, parallel=False, standardiz
print("Written..")


def load_remote_datasets(self, dsnames):
def load_remote_datasets(self, dsnames, load_default_graph=True):
'''Loads remote datasets into cache if a remote endpoint is set
Parameters
Expand Down Expand Up @@ -215,6 +215,9 @@ def load_remote_datasets(self, dsnames):
if dsnames == None or len(dsnames) == 0:
raise Exception("No dataset names to cache")
dsnamestr = (' '.join('<' + NSURL + "/" + dsname + '>' for dsname in dsnames))

if load_default_graph:
dsnamestr += f" <{DEFAULT_GRAPH_URI}>"
print("Caching datasets from remote endpoint..")
qres, qres_df = self.query(f"SELECT ?s ?p ?o ?g WHERE {{ GRAPH ?g {{ ?s ?p ?o }} VALUES ?g {{ {dsnamestr} }} }}", remote=True)

Expand Down

0 comments on commit 2416b10

Please sign in to comment.