Giter VIP home page Giter VIP logo

Comments (3)

trungdong avatar trungdong commented on August 25, 2024

Hello, could you provide an example where it failed? I'm not sure what issue you are having at the moment.

from prov.

NathanCummings avatar NathanCummings commented on August 25, 2024

I'm filling a ProvDocument programmatically by reading the metadata. In the event that someone hasn't filled a field, I am trying to define a namespace with an empty string. When this happens, I don't get an exception thrown until I come to serialise the document. Now of course, I have encountered the problem and built a check into my code, but in a more complex pipeline, the error I received and the point in the code that it was thrown did not make it clear where the problem was. An earlier check on the call to add_namespace() would have told me which namespace was invalid.

Traceback (most recent call last):
  File "/afs/eufus.eu/g2itmdev/user/g2ncummi/fusionprov/venv/bin/imasprov", line 11, in <module>
    load_entry_point('fusionprov==0.1.4', 'console_scripts', 'imasprov')()
  File "/afs/eufus.eu/g2itmdev/user/g2ncummi/fusionprov/venv/lib/python3.6/site-packages/fusionprov/imasprov.py", line 225, in main
    ids_prov.prov_from_data_ids(graph=args.graph)
  File "/afs/eufus.eu/g2itmdev/user/g2ncummi/fusionprov/venv/lib/python3.6/site-packages/fusionprov/imasprov.py", line 197, in prov_from_data_ids
    self.serialize_provenance(graph=graph)
  File "/afs/eufus.eu/g2itmdev/user/g2ncummi/fusionprov/venv/lib/python3.6/site-packages/fusionprov/imasprov.py", line 139, in serialize_provenance
    self.prov_doc.serialize(xml_path, format="xml")
  File "/afs/eufus.eu/g2itmdev/user/g2ncummi/fusionprov/venv/lib/python3.6/site-packages/prov/model.py", line 2494, in serialize
    serializer.serialize(stream, **args)
  File "/afs/eufus.eu/g2itmdev/user/g2ncummi/fusionprov/venv/lib/python3.6/site-packages/prov/serializers/provxml.py", line 52, in serialize
    xml_root = self.serialize_bundle(bundle=self.document, force_types=force_types)
  File "/afs/eufus.eu/g2itmdev/user/g2ncummi/fusionprov/venv/lib/python3.6/site-packages/prov/serializers/provxml.py", line 110, in serialize_bundle
    xml_bundle_root = etree.Element(_ns_prov("document"), nsmap=nsmap)
  File "src/lxml/etree.pyx", line 3022, in lxml.etree.Element
  File "src/lxml/apihelpers.pxi", line 131, in lxml.etree._makeElement
  File "src/lxml/apihelpers.pxi", line 118, in lxml.etree._makeElement
  File "src/lxml/apihelpers.pxi", line 219, in lxml.etree._setNodeNamespaces
  File "src/lxml/apihelpers.pxi", line 1749, in lxml.etree._prefixValidOrRaise
ValueError: Invalid namespace prefix ''

In a script with multiple namespaces defined, the above traceback does not indicate where the problem occurred, as the error isn't caught until much later.

from prov.

trungdong avatar trungdong commented on August 25, 2024

Thanks for the information, Nathan. I'll pop this test in the code next time.

from prov.

Related Issues (20)

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.