8000 "LinkML class attributes" are lost in gen-python · Issue #1830 · linkml/linkml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
"LinkML class attributes" are lost in gen-python #1830
Open
@kappe-c

Description

@kappe-c

Is your feature request related to a problem? Please describe.

Working with a schema in Python, previously generated with the gen-python tool, I would very much like to have access to the "class attributes" defined in the LinkML schema for my classes, ideally with the Pythonic dot syntax.
With "LinkML class attributes" (in quotes) I mean the attributes a class can have according the meta model. In Python, class attributes would be the actual correct name (analogously to class methods).
Simple example. File schema.yaml:

id: https://example.org/test-schema
name: testschema

imports: https://w3id.org/linkml/types

classes:
  
  MyClass:
    abstract: true
    attributes:
      my_attr:
        range: string

Describe the solution you'd like

Having used gen-python schema.yaml > schema.py I would expect to be able to do something like the following in a Python script.

assert MyClass.abstract == True
# or e.g.
if hasattr(MyClass, 'abstract'):
  print(MyClass.abstract)

Similar for comments, todos, etc.
Honestly, I was very surprised that this expected behavior was not implemented. Did I miss anything? Is this intentional? I would not mind if this were kept in, say, MyClass.class_attributes or whatever, but I would very much like to access the stuff I have defined in my schema.

(This is not a feature request for having actual class attributes in LinkML that can be defined by the user (attributes for which each instance has the same shared value.) Even though I have missed this at times.)

How important is this feature?
• Low to Medium

When will use cases depending on this become relevant?
• Short-term - 2-4 weeks (actually right now already in my project)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0