Skip to main content
Solved

Pygen shorter attribute names


Olav Alstad
Committed

We have a RDF-model based on CIM that we have imported to CDF Data Model via Neat. We are experimenting with Pygen. We are happy about both NEAT and Pygen and looking forward to explore further. 

 

The names of the attributes of the dataclasses becomemes long with pygen and the CIM-naming convension. 

 

 

Example 1: 

  • Model: cim:IdentifiedObject.name
  • pygen: identified_object_name
  • proposed pygen short: name

 

Example 2: 

  • Model: nek:NEKACLineSegment.wireSegmentKind
  • pygen: nekac_line_segment_wire_segment_kind
  • proposed pygen short: wire_segment_kind

 

Generic: 

  • Model. namespace:ClassName.attrName
  • pygen: class_name_attr_name
  • proposed pygen short: attr_name

 

Is it possible to add an option in pygen to genreate short attributes? The rule would be to only the string followed by the . (dot )

 

I’m also interested in discussing other solutions with you. One options is ofc to change the names in the model, but then we are not conforming to CIM…

 

Thanks!

 

Regards, 

Olav

 

 

Best answer by Anders Albert

I am in general skeptical about this type of functionality as it seems very custom. It also seems to promote poor property naming. Does cim really expect you to repeat the class in every property? This seems to be cumbersome to have in the data model in the first place. 

View original
Did this topic help you find an answer to your question?

3 replies

Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img

@Olav Alstad The engineers from the related team will get back to you with an update. 


Anders  Albert
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 96 replies
  • Answer
  • March 11, 2025

I am in general skeptical about this type of functionality as it seems very custom. It also seems to promote poor property naming. Does cim really expect you to repeat the class in every property? This seems to be cumbersome to have in the data model in the first place. 


Olav Alstad
Committed
  • Author
  • Committed
  • 4 replies
  • March 12, 2025

Thanks for reply Anders. I see what you mean and understand that you are skeptical. You can keep note of it, in case some other ask for the same. No problem for us that it will not be implemented, we are still in discovvering phase. 

 

Yes, naming convension in CIM is like that. CIM use inheritance. An ACLineSegment do have many properties, but here are three of them: 

  • cim:IdentifiedObject.name
  • cim:Conductor.length
  • cim:ACLineSegment.r

As you can see, the class name in the property show which class the attribute is inherited from. This is actually nice to have, but I think the attribute name in the pygen generated dataclass is a bit long. I can live with that, or consider to change name of the properties in the Data Model. 

 

Thanks

Olav


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings