Git Product home page Git Product logo

surfrdf's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

surfrdf's Issues

use BNode with surf

here is the code snippet from the federation.py example

Movie = session.get_class(surf.ns.SURF['Movie'], store = 'local')
m1 = Movie('http://baseuri/m1')
m1.surf_title = "Movie 1"

trying to create a blank node with rdf.BNode but couldn't figure out how. any pointer would be appreciated!

Python 3 compatibility

ciao, i'm currently evaluating rdf-related libraries for Python. surf is feature- and documentation-wise my favorite atm. unfortunately it lacks Python 3 support.

if i'd give it a shot and refactored the code to support Python 2 and 3, would that be accepted by the maintainers? if so, would using six be okay?

Missing default_graph in sparql_protocol writer

When writing to Openlink Virtuoso (07.20.3217) with the current sparql_protocol writer, a 400 bad request is returned with the following error:

Virtuoso 37000 Error SP031: SPARQL compiler: No plain default graph specified in the preamble, but it is needed for triple constructor in DELETE {...} without GRAPH {...}

Examples of the sparql_protocol feature a default_graph attribute:

store = surf.Store(reader = 'sparql_protocol',
                   endpoint = 'http://dbpedia.org/sparql',
                   default_graph = 'http://dbpedia.org')

However, in the code there seems no sign of usage of this attribute, which is needed for triple stores like Virtuoso.

I will create a pull request for the fix.

rdflib plugin: 'ReaderPlugin' object has no attribute 'log'

The code below throws AttributeError: 'ReaderPlugin' object has no attribute 'log'

import surf
from surf.log import setup_logger, set_logger_level
import logging

setup_logger()
set_logger_level(logging.DEBUG)

store = surf.Store(reader="rdflib",
                   writer="rdflib",
                   rdflib_store="IOMemory")

session = surf.Session(store)

print "Load RDF data"
store.load_triples(source="http://www.w3.org/People/Berners-Lee/card.rdf")
print len(store)

Person = session.get_class(surf.ns.FOAF["Person"])

all_persons = Person.all()

print "Found %d persons in Tim Berners-Lee's FOAF document" % (len(all_persons))
for person in all_persons:
    print person.foaf_name.first
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-fffd51a6eb68> in <module>()
     20 all_persons = Person.all()
     21 
---> 22 print "Found %d persons in Tim Berners-Lee's FOAF document" % (len(all_persons))
     23 for person in all_persons:
     24     print person.foaf_name.first

/usr/local/lib/python2.7/dist-packages/surf/resource/result_proxy.pyc in __len__(self)
    233         """ Return count of resources in this collection. """
    234 
--> 235         _, get_by_response = self.__execute_get_by()
    236         return len(get_by_response)
    237 

/usr/local/lib/python2.7/dist-packages/surf/resource/result_proxy.pyc in __execute_get_by(self)
    214 
    215             store = self._params['store']
--> 216             self._get_by_response = store.get_by(self.__get_by_args)
    217 
    218         return self.__get_by_args, self._get_by_response

/usr/local/lib/python2.7/dist-packages/surf/store.pyc in get_by(self, params)
    148     def get_by(self, params):
    149         params["context"] = self.__add_default_context(params.get("context"))
--> 150         return self.reader.get_by(params)
    151 
    152     def execute(self, query):

/usr/local/lib/python2.7/dist-packages/surf/plugin/reader.pyc in get_by(self, params)
    165 
    166     def get_by(self, params):
--> 167         return self._get_by(params)
    168 
    169 

/usr/local/lib/python2.7/dist-packages/surf/plugin/query_reader.pyc in _get_by(self, params)
    249 
    250         # Load just subjects and their types
--> 251         table = self._to_table(self._execute(query))
    252 
    253         # Create response structure, preserve order, don't include

/usr/local/lib/python2.7/dist-packages/surf.rdflib-1.0.0_r338-py2.7.egg/surf_rdflib/reader.pyc in _execute(self, query)
     78     def _execute(self, query):
     79         q_string = unicode(query)
---> 80         self.log.debug(q_string)
     81         return self.__graph.query(q_string)
     82 

AttributeError: 'ReaderPlugin' object has no attribute 'log'

pip install fails - can not find SuRF distribution

pip install fails - unable to find a suitable SuRF package on PyPi:

pip install --upgrade SuRF
Collecting SuRF
  Could not find a version that satisfies the requirement SuRF (from versions: )
No matching distribution found for SuRF

environment: Python 2.7 on Mac OS X 10.9.5 (the error does not seem to be Mac-specific though).

Library license?

It is not clear to me which licensing is used in this library. Could you please clarify?

Thank you!

serializer to use predefined namespace prefixes

graph = store.reader.graph
print graph.serialize(format='n3')

yields something like

@prefix ns2: <http://xmlns.com/foaf/0.1/> .

where ns2 is used instead of the predefined namespace prefix foaf:. tried different serialization formats with no luck.

is it possible to ask surf to use the predefined namespace prefixes in serialization? thanks!

calling .save() or is_present() methods of Resource raise exception

Background: I'm developing a python library that depends on surf, called hucitlib. I use surf to read and modify resources from a SPARQL endpoint.

Problem: the tests for hucitlib work fine with surf==1.1.9, but many of them fail if I upgrade to 1.2.0.

For example I have a bit that looks like the following:

id = Identifier(id_uri)
id.rdfs_label = Literal(urn)
id.ecrm_P2_has_type = Type(BASE_URI_TYPES % "CTS_URN")
id.save()
return True

and it fails now with this exception

E           ValueError: Statement of type [list, tuple] does not
E                                            have all the (s,p,o) members (the length of the
E                                            supplied arguemnt must be at least 3)

The bug seems to be related to surf.plugin.sparql_protocol.writer and surf.plugin.sparql_protocol.writer. It is raised whenever (in my tests) the method save() or is_present() are called. From what I understand it seems related to some of the underlying SPARQL statements being invalid.

JSON serialization of the query result fails

in plugins/surf.rdflib/surf_rdflib/reader.py there is an issue related to the JSON serialization of the query result -- I believe this is due to changes in RDFLib 4.x as opposed to 3.x.

Example of Object to RDF mappings?

As far as I can see in the documentation, SuRF is more focused on retrieving RDF resources and map them into Python objects, right @cosminbasca?

I guess the opposite use case is also somehow supported: serialize Python object to RDF. I wonder if there is any documentation or source example covering that aspect. What do the Python classes need to provide?

For instance, for my tries I know they need to provide some kind of logic in the find() method. I could continue with a fail-and-error approach, but I guess is not very productive...

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.