Hi everyone,
While working with DAGNode pretty‑printing, I noticed that the string representation was dropping dictionary keys and not handling nested containers very well. I also saw a couple of TODOs in python/ray/dag/format_utils.py about missing keys, indentation being off, and nested containers not being handled.
To address this, I opened a PR here: [DAG] Fix DAGNode string formatting to support nested dicts and lists by AyushKashyapII · Pull Request #63641 · ray-project/ray · GitHub
In short, the PR does the following:
Adds a recursive _format_value helper that:
Preserves dict keys and formats them as key: value, with nested contents correctly indented.
Handles lists/tuples/sets recursively, including nested DAGNode instances.
Falls back to standard string representations for primitives and other types.
Refactors _get_args_lines / _get_kwargs_lines to rely on _format_value so that nested DAG structures render in a more readable, multi‑line form.
Adds unit tests in python/ray/dag/tests/test_formatting.py to cover nested dicts, lists, and nested DAGNode arguments.
Behavior‑wise, the goal is to keep the existing top‑level structure the same, but make nested containers and DAGNodes render more faithfully and readably.
I had a couple of questions:
Is this the kind of change you’d like to see for the DAG pretty‑printer, or is there a preferred direction / design for formatting DAGs that I should align with?
Are there any edge cases or internal uses of get_dag_node_str / str where a more conservative change would be better?
I’d really appreciate any feedback from the maintainers or folks familiar with the DAG internals, and I’m happy to adjust the implementation or tests based on guidance.
Thanks!