Skip to content

Commit

Permalink
fix(utils): wrap component in a LEMS model
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Oct 2, 2024
1 parent 91f588a commit 30aae2b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyneuroml/utils/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Optional

from lems.model.component import Component
from lems.model.model import Model
from neuroml import IncludeType, NeuroMLDocument

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -54,18 +55,17 @@ def add_new_component(
:returns: the Component Object
:rtype: Component
"""
newmodel = Model()
newcomp = Component(id_=component_id, type_=component_type, **kwargs)

xml_str = newcomp.toxml()
newmodel.add_component(newcomp)

if component_filename is None:
component_filename = f"component_{component_id}.xml"

logger.info(
f"Saving component with id '{component_id}' and type '{component_type}' to {component_filename}"
)
with open(component_filename, "w") as f:
print(xml_str, file=f)
newmodel.export_to_file(component_filename)

logger.info(
"Component file included in NeuroML document. Note that new components will not validate against the NeuroML schema."
Expand Down

0 comments on commit 30aae2b

Please sign in to comment.