ecmwf / ecflow

ECMWF's workflow manager
Apache License 2.0
41 stars 15 forks source link

Improve error message for invalid nodes #27

Closed kinow closed 1 year ago

kinow commented 1 year ago

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 https://github.com/ecmwf/ecflow/blob/08fcc175fcc3cea5e480afc858f209a26ead724b/ACore/src/Str.cpp#L379-L386

I think

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

kinow commented 1 year ago

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
shahramn commented 1 year ago

Thank you for highlighting this. I will fix it in the next release

marcosbento commented 1 year ago

Implemented in b1786d2f, included in release 5.10.0.