當前位置: 首頁>>代碼示例>>Python>>正文


Python model.ProvDocument類代碼示例

本文整理匯總了Python中prov.model.ProvDocument的典型用法代碼示例。如果您正苦於以下問題:Python ProvDocument類的具體用法?Python ProvDocument怎麽用?Python ProvDocument使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ProvDocument類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: deriveDependency

    def deriveDependency(self, aDO, aRO, derivedList):

        d1 = ProvDocument()  # d1 is now an empty provenance document
        d1.add_namespace("dt", "http://cs.ncl.ac.uk/dtsim/")
        e1 = d1.entity(DTns + aRO.id)  # deriving
        ag1 = d1.agent(DTns + str(aDO.id))
        for der in derivedList:
            # create provlet
            e2 = d1.entity(DTns + der.id)  # derived
            d1.wasAttributedTo(e2, ag1)
            d1.wasDerivedFrom(e2, e1)

            # update upstream pointer
            der.upstream = [(aRO, None)]  # aRO is upstream from aRO with no activity

            # update downstream
            aRO.downstream.append((der, None))  # aR1 is downstream from aR1 with no activity

        # update global graph
        e1 = pGlobal.entity(DTns + aRO.id)  # deriving
        ag1 = pGlobal.agent(DTns + str(aDO.id))
        pGlobal.wasAttributedTo(e2, ag1)
        for der in derivedList:
            e2 = pGlobal.entity(DTns + der.id)  # derived
            pGlobal.wasDerivedFrom(e2, e1)

        # trigger credit recomputation
        for der in derivedList:
            # aRO needs its credit updated with aRO1.credit
            aCreditManager.addDerivationCredit(aRO, der.currentTotalCredit)

        # 		self.notify(d1)
        return d1
開發者ID:PaoloMissier,項目名稱:DRS,代碼行數:33,代碼來源:DT-sim.py

示例2: get_provdoc

def get_provdoc(format,infile):
    if format == "json":
       return ProvDocument.deserialize(infile)
    elif format == "xml":
       return ProvDocument.deserialize(infile,format='xml')
    else:
       print "Error: unsupported format (xml and json are supported"
開發者ID:stephank16,項目名稱:enes_graph_use_case,代碼行數:7,代碼來源:provio.py

示例3: test_default_namespace_inheritance

 def test_default_namespace_inheritance(self):
     prov_doc = ProvDocument()
     prov_doc.set_default_namespace('http://www.example.org/')
     bundle = prov_doc.bundle('bundle')
     e1 = bundle.entity('e1')
     self.assertIsNotNone(e1.identifier, "e1's identifier is None!")
     self.assertRoundTripEquivalence(prov_doc)
開發者ID:krischer,項目名稱:prov,代碼行數:7,代碼來源:qnames.py

示例4: test_namespace_inheritance

 def test_namespace_inheritance(self):
     prov_doc = ProvDocument()
     prov_doc.add_namespace('ex', 'http://www.example.org/')
     bundle = prov_doc.bundle('ex:bundle')
     e1 = bundle.entity('ex:e1')
     self.assertIsNotNone(e1.identifier, "e1's identifier is None!")
     self.do_tests(prov_doc)
開發者ID:KNMI,項目名稱:wps_prov,代碼行數:7,代碼來源:qnames.py

示例5: primer

def primer():
        a  = ProvDocument()
        script_path = os.path.dirname(os.path.abspath( __file__ )) #
        with open(str(script_path) + "/output.json") as json_file:
                line = json_file.readline()
                a =  a.deserialize(content=line)
        return a
開發者ID:gedare,項目名稱:raspberry_prov,代碼行數:7,代碼來源:tester.py

示例6: read

def read(source, format=None):
    """
    Convenience function returning a ProvDocument instance.

    It does a lazy format detection by simply using try/except for all known
    formats. The deserializers should fail fairly early when data of the
    wrong type is passed to them thus the try/except is likely cheap. One
    could of course also do some more advanced format auto-detection but I am
    not sure that is necessary.

    The downside is that no proper error messages will be produced, use the
    format parameter to get the actual traceback.
    """
    # Lazy imports to not globber the namespace.
    from prov.model import ProvDocument

    from prov.serializers import Registry
    Registry.load_serializers()
    serializers = Registry.serializers.keys()

    if format:
        return ProvDocument.deserialize(source=source, format=format.lower())

    for format in serializers:
        try:
            return ProvDocument.deserialize(source=source, format=format)
        except:
            pass
    else:
        raise TypeError("Could not read from the source. To get a proper "
                        "error message, specify the format with the 'format' "
                        "parameter.")
開發者ID:kellyhennigan,項目名稱:cueexp_scripts,代碼行數:32,代碼來源:__init__.py

示例7: collections

def collections():
    g = ProvDocument()
    ex = Namespace('ex', 'http://example.org/')

    c1 = g.collection(ex['c1'])
    e1 = g.entity('ex:e1')
    g.hadMember(c1, e1)

    return g
開發者ID:KNMI,項目名稱:wps_prov,代碼行數:9,代碼來源:examples.py

示例8: test_xsd_qnames

    def test_xsd_qnames(self):
        prov_doc = ProvDocument()
        ex = Namespace('ex', 'http://www.example.org')
        prov_doc.add_namespace(ex)

        an_xsd_qname = XSDQName(ex['a_value'])
        prov_doc.entity('ex:e1', {'prov:value': an_xsd_qname})

        self.assertPROVJSONRoundTripEquivalence(prov_doc)
開發者ID:HumanBrainProject,項目名稱:prov,代碼行數:9,代碼來源:testModel.py

示例9: document_with_n_bundles_having_default_namespace

def document_with_n_bundles_having_default_namespace(n):
    prov_doc = ProvDocument()
    prov_doc.add_namespace('ex', 'http://www.example.org/')
    for i in range(n):
        x = str(i + 1)
        bundle = prov_doc.bundle('ex:bundle/' + x)
        bundle.set_default_namespace('http://www.example.org/default/' + x)
        bundle.entity('e')
    return prov_doc
開發者ID:krischer,項目名稱:prov,代碼行數:9,代碼來源:qnames.py

示例10: long_literals

def long_literals():
    g = ProvDocument()

    long_uri = "http://Lorem.ipsum/dolor/sit/amet/consectetur/adipiscing/elit/Quisque/vel/sollicitudin/felis/nec/venenatis/massa/Aenean/lectus/arcu/sagittis/sit/amet/nisl/nec/varius/eleifend/sem/In/hac/habitasse/platea/dictumst/Aliquam/eget/fermentum/enim/Curabitur/auctor/elit/non/ipsum/interdum/at/orci/aliquam/"
    ex = Namespace('ex', long_uri)
    g.add_namespace(ex)

    g.entity('ex:e1', {'prov:label': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pellentesque luctus nulla vel ullamcorper. Donec sit amet ligula sit amet lorem pretium rhoncus vel vel lorem. Sed at consequat metus, eget eleifend massa. Fusce a facilisis turpis. Lorem volutpat.'})

    return g
開發者ID:HumanBrainProject,項目名稱:prov,代碼行數:10,代碼來源:examples.py

示例11: setUp

 def setUp(self):
     self.json_path = os.path.dirname(os.path.abspath(__file__)) + '/json/'
     filenames = os.listdir(self.json_path)
     self.fails = []
     for filename in filenames:
         if filename.endswith('.json'):
             with open(self.json_path + filename) as json_file:
                 try:
                     g1 = ProvDocument.deserialize(json_file)
                     json_str = g1.serialize(indent=4)
                     g2 = ProvDocument.deserialize(content=json_str)
                     self.assertEqual(g1, g2, 'Round-trip JSON encoding/decoding failed:  %s.' % filename)
                 except:
                     self.fails.append(filename)
開發者ID:HumanBrainProject,項目名稱:prov,代碼行數:14,代碼來源:testModel.py

示例12: test_xsd_qnames

    def test_xsd_qnames(self):
        prov_doc = ProvDocument()
        ex = Namespace('ex', 'http://www.example.org/')
        prov_doc.add_namespace(ex)
        ex1 = Namespace('ex1', 'http://www.example1.org/')  # ex1 is not added to the document

        an_xsd_qname = XSDQName(ex['a_value'])
        another_xsd_qname = XSDQName(ex1['another_value'])

        e1 = prov_doc.entity('ex:e1', {'prov:value': an_xsd_qname, 'prov:type': another_xsd_qname})
        for _, attr_value in e1.attributes:
            self.assertIsInstance(attr_value, XSDQName)

        self.assertRoundTripEquivalence(prov_doc)
開發者ID:krischer,項目名稱:prov,代碼行數:14,代碼來源:qnames.py

示例13: test_loading_all_json

    def test_loading_all_json(self):
        # self.assertFalse(fails, 'Failed to load/round-trip %d JSON files (%s)' % (len(fails), ', '.join(fails)))

        # Code for debugging the failed tests
        for filename in self.fails:
            # Reload the failed files
            filepath = self.json_path + filename
#             os.rename(json_path + filename, json_path + filename + '-fail')
            with open(filepath) as json_file:
                logger.info("Loading %s...", filepath)
                g1 = ProvDocument.deserialize(json_file)
                json_str = g1.serialize(indent=4)
                g2 = ProvDocument.deserialize(content=json_str)
                self.assertEqual(g1, g2, 'Round-trip JSON encoding/decoding failed:  %s.' % filename)
開發者ID:krischer,項目名稱:prov,代碼行數:14,代碼來源:test_model.py

示例14: __init__

class ProjectProvenance:
    def __init__(self, database_helper, full_provenance=False):
        """
        Initializes the provenance for the mjclawar_rarshad project

        Parameters
        ----------
        database_helper: DatabaseHelper
        full_provenance: bool

        Returns
        -------
        """
        assert isinstance(database_helper, DatabaseHelper)

        self.database_helper = database_helper
        if full_provenance:
            self.prov_doc = ProvDocument.deserialize(dir_info.plan_json)
        else:
            self.prov_doc = ProvDocument()
        self.prov_doc.add_namespace(mcras.BDP_NAMESPACE.name, mcras.BDP_NAMESPACE.link)
        self.prov_doc.add_namespace(mcras.ALG_NAMESPACE.name, mcras.ALG_NAMESPACE.link)
        self.prov_doc.add_namespace(mcras.DAT_NAMESPACE.name, mcras.DAT_NAMESPACE.link)
        self.prov_doc.add_namespace(mcras.LOG_NAMESPACE.name, mcras.LOG_NAMESPACE.link)
        self.prov_doc.add_namespace(mcras.ONT_NAMESPACE.name, mcras.ONT_NAMESPACE.link)

    def write_provenance_json(self):
        self.prov_doc.serialize(dir_info.plan_json)
開發者ID:B1ueSky,項目名稱:course-2016-spr-proj-two,代碼行數:28,代碼來源:provenance.py

示例15: test_bundle_update_simple

    def test_bundle_update_simple(self):
        doc = ProvDocument()
        doc.set_default_namespace(EX_URI)

        b1 = doc.bundle('b1')
        b1.entity('e')

        b2 = doc.bundle('b2')
        b2.entity('e')

        self.assertRaises(ProvException, lambda: b1.update(1))
        self.assertRaises(ProvException, lambda: b1.update(doc))

        b1.update(b2)
        self.assertEqual(len(b1.get_records()), 2)
開發者ID:cmaumet,項目名稱:prov,代碼行數:15,代碼來源:test_model.py


注:本文中的prov.model.ProvDocument類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。