-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
There was a problem hiding this 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.
haystack/nodes/_json_schema.py
Outdated
@@ -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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 😁
haystack/nodes/_json_schema.py
Outdated
@@ -232,7 +233,7 @@ def get_json_schema( | |||
|
|||
# Build the definitions and refs for the nodes | |||
for _, node in possible_nodes: |
There was a problem hiding this comment.
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.
test/test_pipeline_yaml.py
Outdated
@@ -1,14 +1,14 @@ | |||
from abc import abstractmethod | |||
from lib2to3.pytree import Base |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VSCode's autoimport 🤦
Problem:
See #2310. Even though the issue was trivial, the error message is actually misleading.
Solution:
Notes:
This PR actually fixes a bug in
_json_schema.py
, which was interpreting a node instance as a node class and therefore failing theisabstract()
check even on abstract classes. As a consequence, the check "node name must not start with Base" can be also safely removed.