trungdong / prov

A Python library for W3C Provenance Data Model (PROV)
http://prov.readthedocs.io/
MIT License
120 stars 44 forks source link

fix: association with agent #117

Closed satra closed 6 years ago

satra commented 6 years ago

fixes association with agent for the following scenario

@dbkeator - this PR should fix the issue you saw.

import prov.model as pm                                                                      
doc = pm.ProvDocument()                                                                      
doc.add_namespace('foo', 'http://example.org/')                                              
doc.activity('foo:a1')                                                                       
doc.agent('foo:ag1')                                                                         
doc.agent('foo:ag2')                                                                         
doc.association('foo:a1', 'foo:ag1', other_attributes={pm.PROV_ROLE: 'foo:r1'})              
doc.association('foo:a1', 'foo:ag2', other_attributes={pm.PROV_ROLE: 'foo:r2'})              
print(doc.get_provn())                                                                       
print(doc.serialize(format='rdf'))

now generates:

@prefix foo: <http://example.org/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

{
    foo:a1 a prov:Activity ;
        prov:qualifiedAssociation [ a prov:Association ;
                prov:agent foo:ag2 ;
                prov:hadRole "foo:r2"^^xsd:string ],
            [ a prov:Association ;
                prov:agent foo:ag1 ;
                prov:hadRole "foo:r1"^^xsd:string ] .

    foo:ag1 a prov:Agent .

    foo:ag2 a prov:Agent .
}
coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 90.387% when pulling bb124a443d24e9bc12d0ffdfdc0204980d76e7b0 on satra:fix/association-agent into 310a8f6d123b6baccfb03c53afcbb5133e7e7ed9 on trungdong:master.

satra commented 6 years ago

@trungdong - quick ping for a check. let me know if you plan to release a minor update soon.

trungdong commented 6 years ago

Many thanks, @satra. I will make a minor release shortly. Dong.