Skip to content

Automatically create a Part for new Components#237

Merged
Wuestengecko merged 1 commit into
masterfrom
automatic-part-creation
Sep 9, 2025
Merged

Automatically create a Part for new Components#237
Wuestengecko merged 1 commit into
masterfrom
automatic-part-creation

Conversation

@ewuerger

Copy link
Copy Markdown
Collaborator

This PR implements the cs.Part creation of at least one part when creating a new Component. The name of the Part is now correctly inferred from its type.

@Wuestengecko

Copy link
Copy Markdown
Member

Can you rebase on top of latest master (c2e00d4)? That should fix the CI.

@ewuerger
ewuerger force-pushed the automatic-part-creation branch 3 times, most recently from b01ca57 to 4f86413 Compare January 31, 2023 12:15
Comment thread capellambse/model/common/element.py Outdated
f"Cannot instantiate {type(self).__name__} directly"
)
try:
self._xmltag = kw.pop("_xmltag")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This smells. _xmltag is set as class variable (more like "class constant") in subclasses. We should stay consistent in treating it like that.

Besides, we don't even need it outside of __init__ anyway, and even if, it would be saved implicitly as _element.tag.

Comment thread capellambse/model/common/element.py Outdated
Comment thread capellambse/model/common/accessors.py Outdated
Comment thread capellambse/model/common/accessors.py Outdated
Comment thread capellambse/model/common/accessors.py Outdated
Comment thread tests/test_xlayer_cs.py Outdated
Comment thread tests/test_xlayer_cs.py Outdated
Comment thread tests/test_xlayer_cs.py Outdated
Comment thread capellambse/model/common/element.py Outdated
Comment thread tests/test_xlayer_cs.py Outdated
@ewuerger
ewuerger force-pushed the automatic-part-creation branch from 6e4c327 to b4db0f2 Compare February 20, 2023 10:04
@Wuestengecko
Wuestengecko marked this pull request as draft May 26, 2025 15:30
@Wuestengecko
Wuestengecko force-pushed the automatic-part-creation branch from b4db0f2 to 6c1ffe3 Compare May 27, 2025 09:09
@Wuestengecko Wuestengecko changed the title Automatic part creation when creating a Component Automatically create a Part for new Components May 27, 2025
@Wuestengecko
Wuestengecko force-pushed the automatic-part-creation branch 2 times, most recently from 6d9be35 to 570d983 Compare May 30, 2025 09:38
@Wuestengecko
Wuestengecko force-pushed the automatic-part-creation branch 2 times, most recently from 01d8dbe to c0d77e9 Compare June 18, 2025 09:04
@Wuestengecko
Wuestengecko force-pushed the automatic-part-creation branch 4 times, most recently from 9fcf706 to 466f00d Compare July 15, 2025 17:20
@Wuestengecko
Wuestengecko force-pushed the automatic-part-creation branch 3 times, most recently from c2f4bbe to f6aa61c Compare July 22, 2025 15:58
@Wuestengecko
Wuestengecko force-pushed the automatic-part-creation branch from f6aa61c to 8b9b4c1 Compare September 8, 2025 17:26
@ewuerger
ewuerger marked this pull request as ready for review September 9, 2025 08:58

@ewuerger ewuerger left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested also with declarative modelling. Works like a charm. Good test too! After this one minor thing: LGTM.

Comment thread src/capellambse/metamodel/cs.py Outdated
if isinstance(self.parent, Component | ComponentPkg):
self.parent.owned_parts.create(name=self.name, type=self)
else:
self.owned_parts.create(type=self)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.owned_parts.create(type=self)
self.owned_parts.create(name=self.name, type=self)

@Wuestengecko
Wuestengecko force-pushed the automatic-part-creation branch from 8b9b4c1 to c4eb6e9 Compare September 9, 2025 09:07
@Wuestengecko
Wuestengecko merged commit af32a48 into master Sep 9, 2025
19 checks passed
@Wuestengecko
Wuestengecko deleted the automatic-part-creation branch September 9, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Declarative modelling : Problems when declaring new functions / components

2 participants