Improve error message for invalid nodes
Closed this issue · 3 comments
Hi!
I was using PyFlow today, created a suite Suite('a000')
, and tried to create a family Family('/a000/f1')
. When I called s.check_definition
in PyFlow, it raised an error with the following message "RuntimeError: Invalid node name : Valid names can only consist of alphanumeric characters ,underscores and dots. The first character cannot be a dot: /a/f".
I searched the PyFlow code for that string, but with the debugger it appeared to come from the Python ecFlow module, maybe from this part of the code
Lines 379 to 386 in 08fcc17
I think
- the comma space could be fixed and
- the message could simply say that the first character must be a letter or a digit, or something similar, instead of saying a dot is invalid while other chars are also invalid
I got confused when I saw that it couldn't start with a dot, then I realized I probably couldn't access nodes directly by their full ID in PyFlow (at least not the way I was trying).
Thanks!
Bruno
To reproduce the error message, on develop
branch in PyFlow, and using ecFlow from Conda Forge, use the following code:
>>> from pyflow import *
>>> s = Suite('a')
>>> f = Family('/a/f')
>>> s.add_node(f)
Family(/a//a/f)
>>> s.check_definition()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/kinow/Development/python/workspace/pyflow/pyflow/nodes.py", line 574, in check_definition
ret = self.ecflow_definition().check()
File "/home/kinow/Development/python/workspace/pyflow/pyflow/nodes.py", line 586, in ecflow_definition
d.add_suite(self.suite.generate_node())
File "/home/kinow/Development/python/workspace/pyflow/pyflow/nodes.py", line 213, in generate_node
n._build(o)
File "/home/kinow/Development/python/workspace/pyflow/pyflow/nodes.py", line 850, in _build
ecflow_parent.add_family(self.generate_node())
File "/home/kinow/Development/python/workspace/pyflow/pyflow/nodes.py", line 207, in generate_node
o = self.ecflow_object()
File "/home/kinow/Development/python/workspace/pyflow/pyflow/nodes.py", line 836, in ecflow_object
return ecflow.Family(str(self._name))
RuntimeError: Invalid node name : Valid names can only consist of alphanumeric characters ,underscores and dots. The first character cannot be a dot: /a/f
Thank you for highlighting this. I will fix it in the next release
Implemented in b1786d2, included in release 5.10.0.