Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find classes by their class_name #478

Closed
wdduncan opened this issue Sep 13, 2021 · 6 comments
Closed

find classes by their class_name #478

wdduncan opened this issue Sep 13, 2021 · 6 comments
Assignees

Comments

@wdduncan
Copy link
Contributor

It is useful to be able to find the name of the class according to how it named in the code.

For example, in the nmdc-schema python class , there is a class named BiosampleProcessing. But, if you run list(view.all_class()), you can only get back biosample processing.

cc @cmungall

@wdduncan
Copy link
Contributor Author

Not sure if this bit of code helps, but here is how I can build a dict with python name as a key and the linkml name as a value:

import inspect
from nmdc_schema import nmdc

python_name_dict = {}
for name, member in inspect.getmembers(nmdc):
    if inspect.isclass(member) and hasattr(member, 'class_name'):
        python_name_dict[name] = member.class_name

print(list(python_name_dict.items())[0:5])
>> [('Activity', 'activity'), ('Agent', 'agent'), ('AttributeValue', 'attribute value'), ('Biosample', 'biosample'), ('BiosampleProcessing', 'biosample processing')]

@cmungall cmungall self-assigned this Nov 22, 2021
@cmungall cmungall pinned this issue Nov 22, 2021
@cmungall cmungall transferred this issue from linkml/linkml-runtime Nov 22, 2021
@cmungall
Copy link
Member

cmungall commented Dec 3, 2021

I think this is fixed by linkml/linkml-runtime#77 can you confirm @wdduncan

@cmungall cmungall assigned wdduncan and unassigned cmungall Dec 3, 2021
@cmungall
Copy link
Member

cmungall commented Dec 3, 2021

can you also edit the title of the issue to reflect what the ask is?

@wdduncan wdduncan changed the title run the name of the class as named in the code find classes by their class_name Jul 28, 2022
@wdduncan
Copy link
Contributor Author

@cmungall renamed the title, but this issue looks to be stale. Perhaps best to close.

@sierra-moxon
Copy link
Member

we also have the "uncamelcase" method in the runtime too, so we can go back and forth between class name representations in downstream code. was the ask here that these methods be abstracted away and all versions of the names returned as a tuple? If so, we don't have that. I can close for now with the notion that code is available for downstream applications to go back and forth between naming conventions before/after calling the all_classes method?

@wdduncan
Copy link
Contributor Author

@sierra-moxon Thanks for closing. I opened the ticket quite a while ago, and I don't remember the specific use case :(

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

No branches or pull requests

3 participants