Skip to content

Hitting lxml max attribute size for very large model #3744

@lewisgross1296

Description

@lewisgross1296

Bug Description

I'm modeling a TRISO microreactor core with 469,931,320 TRISO sphere cell instances. They are spread across 6680 isntances of one openmc.RecLlattice object generated by the opennc.model.create_triso_lattice() function filled into a cylinder.

I made a model object from the XML and assigned temperatures from a properties.h5 file produced by a Cardinal multiphysics simulation via openmc.model.import_properties(). I'm able to create the model object and export it to XML; however, when I try to load this model (which ends up being around 2.4 GB), I get a complaint from lxml about an AttValue that is too long.

Did a little digging and it appears that (according to this stackoverflow article) the max attribute size is 10,000,000.

Steps to Reproduce

Would need my model.xml or a model with some attribute that is similarly as large and to do the below:

>>> import openmc
>>> model = openmc.model.Model.from_model_xml()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lgross/openmc/openmc/model/model.py", line 323, in from_model_xml
    tree = ET.parse(path, parser=parser)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/lxml/etree.pyx", line 3589, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1958, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1984, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1887, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1200, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 633, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 743, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 672, in lxml.etree._raiseParseError
  File "model.xml", line 3699
lxml.etree.XMLSyntaxError: AttValue length too long, line 3699, column 1000000029

Environment

I have OpenMC installed from source on Ubuntu 24.04

         Version | 0.15.3-dev200
     Commit Hash | 84a413b130d97a6bc6f3770fc7374617f701cede

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions