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

Declarative modeling: add find by name functionality #232

Closed
vik378 opened this issue Jan 22, 2023 · 4 comments
Closed

Declarative modeling: add find by name functionality #232

vik378 opened this issue Jan 22, 2023 · 4 comments

Comments

@vik378
Copy link
Member

vik378 commented Jan 22, 2023

While using declarative modeling I realized referencing objects by uuid is not very human-friendly. In our non-declarative applications (i.e. doc templates) we frequently refer to things by name. I think same thing here would be very helpful:

parent: !find-by-name brew coffee in SA functions

or something like that.

Maybe we could use some extra keywords for scope reduction (so that it knows that we are searching for an LA component or SA function.

@Wuestengecko
Copy link
Member

What do you think about this proposal?

- parent: !find
    type: SystemFunction
    name: brew coffee
  create: ...

Except for type (which is special cased to look at the class), this approach would be extensible to allow filtering for every attribute that a model object could have. For example, if you were searching for a Requirement and you know that its combination of chapter_name and foreign_id makes it unique, you could use:

- parent: !find
    type: Requirement
    chapter_name: Chapter 3
    foreign_id: 7
  create: ...

@vik378
Copy link
Member Author

vik378 commented Feb 10, 2023

very cool! just to stretch it a bit, would it work if we then also search by human-friendly IDs (property value), like owned_property["DB-ID"]: LFNC-0123 ?

@Wuestengecko
Copy link
Member

This could become a bit difficult. I was planning on simply using the good ol' attrgetter, which would give us things like owner.name: ... for free, but that doesn't have the necessary logic / complexity for fully custom attribute names (especially ones that are not guaranteed to be Python identifiers). I'll think about that for a little and try to come up with something.

@Wuestengecko Wuestengecko linked a pull request Feb 10, 2023 that will close this issue
@Wuestengecko
Copy link
Member

Implemented with #387.

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

Successfully merging a pull request may close this issue.

2 participants