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

Custom props #37

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Custom props #37

merged 2 commits into from
Oct 16, 2024

Conversation

dsehnal
Copy link
Member

@dsehnal dsehnal commented Oct 14, 2024

No description provided.

Comment on lines +62 to +63
if "ref" in params:
data["ref"] = params.pop("ref")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JonStargaryen @midlik Added support for refs as well which will be required to make the primitives works when showing lines/etc between different structures.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you wanted to say "Please add" instead of "Added"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, partially added it myself :)

@dsehnal dsehnal requested review from sbittrich and midlik October 14, 2024 08:59
Copy link
Collaborator

@midlik midlik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it looks nice.

I still think including "custom" and "ref" directly in "params" would make things simpler - see the specific comment.

Comment on lines +62 to +63
if "ref" in params:
data["ref"] = params.pop("ref")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you wanted to say "Please add" instead of "Added"

Comment on lines +54 to +55
custom: CustomT = Field(description="Custom data to store attached to this node.")
ref: RefT = Field(description="Optional reference that can be used to access this node.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be simpler to just include "custom" and "ref" as one of the node params? It would be defined in a params base class that all param classes would extend.

Instead of for example:

class ComponentInlineParams(BaseModel):
    selector: Union[ComponentSelectorT, ComponentExpression, list[ComponentExpression]] = Field(...)

We would have:

class BaseParams(BaseModel):
    custom: ...
    ref: ...
class ComponentInlineParams(BaseParams):
    selector: Union[ComponentSelectorT, ComponentExpression, list[ComponentExpression]] = Field(...)

I believe this will simplify code in Node.__init__ and make_params as they won't need to treat "custom" and "ref" in any special way.

Copy link
Member Author

@dsehnal dsehnal Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the benefit of this other than simpler params?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, you are right, this would also allow to not have ref/custom on all nodes for example if we ever don't want to support it everywhere.

@dsehnal
Copy link
Member Author

dsehnal commented Oct 16, 2024

Gonna merge this so I can test this in the primitives PR. Let's do other tweaks (like adding it to the builder everywhere in a separate pass)

@dsehnal dsehnal merged commit 1fdfce6 into master Oct 16, 2024
@sbittrich sbittrich deleted the custom branch November 7, 2024 00:17
@sbittrich sbittrich restored the custom branch November 7, 2024 00:17
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 this pull request may close these issues.

3 participants