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

Improve error message for nodes failing validation #2313

Merged
merged 13 commits into from
Mar 21, 2022

Conversation

ZanSara
Copy link
Contributor

@ZanSara ZanSara commented Mar 15, 2022

Problem:
See #2310. Even though the issue was trivial, the error message is actually misleading.

Solution:

  • Added an explicit test case for a node referencing another one
  • Improve the error message in case of unprocessable nodes.

Notes:
This PR actually fixes a bug in _json_schema.py, which was interpreting a node instance as a node class and therefore failing the isabstract() check even on abstract classes. As a consequence, the check "node name must not start with Base" can be also safely removed.

@ZanSara ZanSara requested a review from tstadel March 16, 2022 16:09
@ZanSara ZanSara added type:feature New feature or request topic:pipeline labels Mar 16, 2022
@ZanSara ZanSara changed the title Fix nodes referencing each other in YAML pipeline config files Improve error message for nodes failing validation Mar 16, 2022
@ZanSara ZanSara marked this pull request as ready for review March 17, 2022 15:48
Copy link
Member

@tstadel tstadel left a comment

Choose a reason for hiding this comment

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

LGTM! Left some minor comments.

@@ -113,7 +113,11 @@ class Config(BaseConfig):
extra = "forbid" # type: ignore


def find_subclasses_in_modules(importable_modules: List[str], include_base_classes: bool = False):
def is_valid_component_class(clazz):
Copy link
Member

Choose a reason for hiding this comment

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

Although the naming doesn't stem from you, according to PEP8 names conflicting with python keywords should be rather named with one trailing underscore. Any advantages of clazz here instead of class_ other than it looks a lot cooler? :-D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None! I simply didn't know how to call it 😂 I didn't know about this rule btw, I won't have this naming problem again 😁

@@ -232,7 +233,7 @@ def get_json_schema(

# Build the definitions and refs for the nodes
for _, node in possible_nodes:
Copy link
Member

Choose a reason for hiding this comment

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

We could also rename this to possible_node_classes and node_class for sake of consistency.

@@ -1,14 +1,14 @@
from abc import abstractmethod
from lib2to3.pytree import Base
Copy link
Member

Choose a reason for hiding this comment

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

What do we need that for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

VSCode's autoimport 🤦

@ZanSara ZanSara merged commit 7261377 into master Mar 21, 2022
@ZanSara ZanSara deleted the fix_accessory_class_loading branch March 21, 2022 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:pipeline type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants