Skip to content

[CWL Executor] use cwl_utils to print the workflow #108

Description

@ryuwd

Here was a comment, which I think was not addressed in the previous PR:

Out of curiosity, have you noticed that cwltool was providing a command to print a dot representation of the workflow?
I wonder whether printing and displaying this dot file using a python library would simplify the function.

Originally posted by @aldbr in #94 (comment)

Context

The executor CLI has a --print-workflow flag that prints a human-readable summary
of the workflow into the job log before execution (steps in order, each step's
inputs with their sources, its outputs, plus workflow-level inputs/outputs). This is
mainly for job-log forensics: understanding what ran without opening the CWL file.

Problem

print_workflow_visualization() in src/dirac_cwl/job/executor/__main__.py builds
this view by yaml.safe_load-ing the raw CWL file and hand-parsing it. It has to
handle both authoring styles (mapping vs list) for inputs/steps/outputs manually,
and it silently mis-renders anything it doesn't know: packed $graph documents,
subworkflows, scatter. It duplicates CWL document normalization that cwltool
already does correctly.

Note: the originally suggested cwltool --print-dot is not a drop-in fix. Its
DOT output only contains step-to-step edges, with no port names, types, or labels,
i.e. less information than the current view. Use cwltool's loader instead.

Proposed approach

Keep the rich rendering; replace the parsing. Load the workflow through cwltool and
walk the normalized document (after loading, inputs/steps/outputs are always lists
of dicts with absolute IDs, all the dict/list branches can be deleted):

Definition of done

  • print_workflow_visualization no longer parses the CWL YAML itself; the
    structure comes from cwltool's loader.
  • The rendered output still shows: cwlVersion + doc, workflow inputs
    (name, type, label), steps in order with per-step inputs (name ← source)
    and outputs, and workflow outputs (name, type, outputSource).
    Complex types (arrays, records) are rendered best-effort.
  • Renders correctly for: mapping-style CWL, list-style CWL, and a workflow with
    inline run: tools. A CommandLineTool (no steps) gets a graceful
    inputs/outputs-only view instead of an error.
  • A unit test exercises the function on at least one workflow fixture and
    asserts on the rendered content.
  • No new dependencies.

Out of scope

  • ASCII 2-D graph layout or any interactive TUI (no viable pure-Python library?)
  • Generating SVG/PNG. Users who want a picture can run cwltool --print-dot workflow.cwl | dot -Tsvg > wf.svg — at most, mention this in the docs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions