Enhancement: Python client Symbol cannot list a usage's inherited members (parts, ports, bindings), unlike attributes()
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Ambito
- api, developer-experience
Direzione di ricerca
The issue names the Python client, children(), parts(), attributes(), and docs/reference/python-api.md; it also links pull request #1974, which is already open. Start by reviewing the linked pull request and the client API behavior described in the reproduction. Done means the API and docs clearly specify inherited members and address the reported behavior, including redefinitions and standard-library members.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
This issue was written with AI help. The model, the reproduction script and its output are
attached and were run against the version below.This is partly a feature request. The issue form points feature requests to Discussions, but
Discussions are not enabled on this repository, so it is filed as an issue.
What happened, and what you expected instead
A part definition declares a boundary port, a nested part and a named binding between them, and a
part usage in the system is typed by it:
part def Controller {
attribute gain : ScalarValues::Real;
port cmdIn : CmdPort;
part logic : Logic;
binding delegate bind cmdIn = logic.cmdIn;
}
part system {
part controller : Controller;
}
Walking the system structure from Python, model.get("…::system::controller") gives:
| Method | Returns |
|---|---|
attributes() |
['…::Controller::gain']: own and inherited, as its docstring says |
parts() |
[]: the inherited logic is missing |
children() |
[]: the inherited gain, cmdIn, logic and delegate are all missing |
children() lists only the members the element itself declares (its owned members). For a usage
typed by a definition that is usually nothing, so a client that walks the structure through
usages, which is the natural way to walk an instance hierarchy, never sees the definition's ports,
parts or bindings. If one member is redefined (part tuned : Controller { attribute :>> gain = 2.0; }),
children() returns only that member.
Nothing documents this. children() says only "Return all child symbols", and parts() says
"Return child symbols that are part definitions or usages". Meanwhile attributes() on the same
object does include inherited members, so the two methods disagree about what belongs to the
element.
The service already has the inherited members. Through reflection,
last(system::controller.metadata).member starts with gain, cmdIn, logic, delegate, followed
by about 70 standard-library features. model.instantiate("…::system").controller has the
features cmdIn, delegate, gain and logic. The Symbol API is the only place that cannot
list them. The workaround is to fetch the definition (type_facts.resolved_id) and the targets of
specializations, then merge their children with the usage's own, applying redefinitions by
hand, which is the walk attributes() already does internally for attributes.
Requested:
- A way to list a symbol's members own and inherited, as
attributes()does for
attributes. That could bechildren(inherited=True), amembers()method, or inherited ids
onSymbolInfo. It would follow the same rules asattributes(): a redefinition masks what it
redefines, and standard-library members are left out and reported as withheld
(withheld_library_attributesdoes this for attributes today). parts()behaves likeattributes()and includes inherited parts, or both are documented as
different on purpose.- The docstrings of
children()andparts()(anddocs/reference/python-api.md) say whether
inherited members are included.
Related: #1960 (children() also drops unnamed members of the element that declares them).
Reproduction
$ python repro_inherited.py # loads inherited-model.sysml with opensysml.loads() over sysml-grpc
## The definition declares the members
[INFO] InheritedMembers::Controller.children()
observed: [('attributeUsage', 'InheritedMembers::Controller::gain'), ('portUsage', 'InheritedMembers::Controller::cmdIn'), ('partUsage', 'InheritedMembers::Controller::logic'), ('bindingUsage', 'InheritedMembers::Controller::delegate')]
## The usage typed by it
[OK ] InheritedMembers::system::controller is typed by InheritedMembers::Controller
[OK ] InheritedMembers::system::controller.attributes() includes the inherited attribute (documented: own and inherited)
observed: ['InheritedMembers::Controller::gain']
[BUG ] InheritedMembers::system::controller.parts() includes the inherited part 'logic'
observed: []
expected: ['InheritedMembers::Controller::logic']
[BUG ] InheritedMembers::system::controller: some Symbol method lists the inherited binding 'delegate'
observed: []
expected: ['InheritedMembers::Controller::gain', 'InheritedMembers::Controller::cmdIn', 'InheritedMembers::Controller::logic', 'InheritedMembers::Controller::delegate']
## A usage that redefines one member lists only that one
[INFO] InheritedMembers::system::tuned.children()
observed: ['InheritedMembers::system::tuned::gain']
## The service does know the inherited members
[INFO] reflection: ownedMember (empty, as children())
observed: []
[INFO] reflection: member (first four of the list; the rest are standard-library features)
observed: ['gain', 'cmdIn', 'logic', 'delegate']
[INFO] instance: features of system.controller
observed: ['cmdIn', 'delegate', 'gain', 'logic']
inherited-model.sysml:
package InheritedMembers {
port def CmdPort {
in attribute cmd : ScalarValues::Integer;
}
part def Logic {
port cmdIn : CmdPort;
}
part def Controller {
attribute gain : ScalarValues::Real;
port cmdIn : CmdPort; // boundary port
part logic : Logic;
binding delegate bind cmdIn = logic.cmdIn; // boundary-to-child binding, named
}
part system {
part controller : Controller; // usage typed by the definition
part tuned : Controller { // the same, redefining one member
attribute :>> gain = 2.0;
}
}
}
Reproduction files (attached)
| File | Contents |
|---|---|
| model | inline above (no file attached): save it as inherited-model.sysml next to repro_inherited.py |
repro_inherited.py |
loads inherited-model.sysml with opensysml.loads() and compares children(), parts() and attributes() of the definition and the usages, then shows the same members through reflection and an instance. Each check prints OK, BUG or INFO, and the script exits 1 while any BUG reproduces. |
output_inherited.txt |
the full output of the run reported here |
_common.py |
shared helper the script imports: starts the sysml-grpc named by $OPENSYSML_BINARY, prints the server and client versions, and formats the checks |
To run it, put _common.py in the parent directory of the folder holding repro_inherited.py and the model,
install the client (pip install -e client/python from an OpenSysML checkout), and point
OPENSYSML_BINARY at a sysml-grpc build:
$ OPENSYSML_BINARY=/path/to/OpenSysML/bin/sysml-grpc python repro_inherited.py
Without OPENSYSML_BINARY, _common.py assumes an OpenSysML checkout next to the directory
that holds _common.py, with bin/sysml-grpc built by make build-grpc.
Version
sysml-grpc v0.12.0-262-gc86932321 (develop at c86932321), opensysml Python client 0.12.0, Python 3.13.15
Surface
Python client (opensysml)
- Lingua principale
- Go
- Stelle
- 56
- Fork
- 17
- Merge medio
- 12h 31m
- PR unite (30g)
- 909
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Open-MBEE/OpenSysML
-
dependencies
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
Open-MBEE/OpenSysML#1951 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
bug enhancement spec compliance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Open-MBEE/OpenSysML#2009 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug spec compliance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
Open-MBEE/OpenSysML#2008 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Open-MBEE/OpenSysML#2007 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Open-MBEE/OpenSysML
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
adrianbrad/queue#92 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
agent-ready area:skills
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
jmbarzee/temporal-architect#444 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement needs:sonnet ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno