OpenCyphal / pydsdl

Cyphal DSDL processing front end implemented in Python
https://opencyphal.org
MIT License
10 stars 9 forks source link

provide a way to prune type trees #99

Open thirtytwobits opened 5 months ago

thirtytwobits commented 5 months ago

Currently pydsdl simply discovers all dsdl types under a given root folder. For large projects this presents a problem where a significant number of types may exist under a root but a given consumer/producer only uses a small subset of them.

This issue is to provide a way to select target types which become leaf-nodes allowing all other branches to be pruned.

For example, adding a target types: Optional[List[str]] argument to pydsdl.read_namespace would provide the right interface to enable this in consumers like Nunavut.

thirtytwobits commented 5 months ago

I did a quick experiment where I filtered the types included in the "sources" array here:

https://github.com/OpenCyphal/pydsdl/blob/master/pydsdl/_namespace.py#L446

but only for the target_dsdl_definitions here:

https://github.com/OpenCyphal/pydsdl/blob/master/pydsdl/_namespace.py#L152

Strangely, this did not return a transitive closure. While the target types were found not all of the types they used were included.