Skip to content

modelspec/base_types.py:to_json_file triggers KeyError: 'id' #1

Open
@robertvi

Description

see test_id_bug.py
andtest_sid_fix.py

In test_id_bug.py I create a fragment of the SBML specification in modelspec, whereby the id field has to be defined as optional as per the spec doc

whenever an object that gets stored in a list is not assigned an id this triggers a KeyError when trying to convert to json using modelspec/base_types.py:to_json_file (presumably because the id is trying to be used as the key for a dictionary where the other attributes of the object are going to be stored)

'''
sbml_doc = SBML(id=sbml_id) #no error if id is None

model = Model(id=model_id) #no error if id is None
sbml_doc.model = model

unitDef = UnitDefinition(id=unitdef_id) #ERROR if id is None
model.listOfUnitDefinitions.append(unitDef)

unit = Unit(id=unit_id)#Error if id is None
unitDef.listOfUnits.append(unit)

#this triggers the error
sbml_doc.to_json_file(f"untracked/test_id_bug.{fname}.json")

'''

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions