Skip to content

[core] Simplify node descriptions#2538

Merged
fabiencastan merged 3 commits into
developfrom
dev/simplifyNodeAPI
Sep 20, 2024
Merged

[core] Simplify node descriptions#2538
fabiencastan merged 3 commits into
developfrom
dev/simplifyNodeAPI

Conversation

@cbentejac

Copy link
Copy Markdown
Contributor

Description

Following #2523 which simplify the arguments to include an attribute in a node's UID computation, this PR simplifies the description of nodes with the following changes:

  • For ChoiceParam attributes, which may be exclusive (only one value among a list of several ones can be selected) or not (several values can be selected at once), the exclusive argument is set to True by default.

    • If it is not specified, the ChoiceParam attribute will be exclusive, and its display in the Node Editor will follow accordingly.
    • If the attribute is not exclusive, it needs to be explicitly stated with exclusive=False (which already was the case prior to this PR).
    • As most ChoiceParam attributes are exclusive, this simplifies writing a node's description. All the existing nodes with exclusive ChoiceParam attributes have been updated to stop including the exclusive=True line in their description.
  • For IntParam and FloatParam, the range that previously needed to be specified for the attribute's description to be valid is now set to None by default.

    • If it is explicitly specified with range=(start, end, step), the range is checked to ensure it is valid (for example, no floating number can be specified in the range if the attribute is an IntParam) and in case it is not, the description of the node will be rejected (as it currently is).
    • If it is not specified (and thus set implicitly as range=None), no check is performed on that argument and the attribute's description will be deemed valid. Instead of displaying a slider in the Node Editor that is parameterized with the provided range, a text field with no slider will be displayed. Invalid values (such as strings, or floating numbers for IntParam attributes) are however still not allowed, and the user will not be able to input them, as is expected.
    • No current node is modified by this PR to remove the range argument of one of its IntParam or FloatParam attributes.

This simplifies the node descriptions. For multi-choice ChoiceParams,
`exlusive=False` still needs to be specified.
`range` is set to `None` by default, making it optional. If it is
specified, correct values are expected (e.g. only floats for `FloatParam`)
 and a slider will be displayed in the Node Editor. However, if it is not
specified, no slider will be displayed and the value will be set at the
discretion of the user.

Having `range=None` will not trigger any "invalid" error in the
description. It is thus not mandatory anymore to specify the valid range
of values for the integer and floating attributes in node descriptions.
@fabiencastan fabiencastan merged commit 9088f0b into develop Sep 20, 2024
@fabiencastan fabiencastan deleted the dev/simplifyNodeAPI branch September 20, 2024 20:57
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.

2 participants