External triggers not working with workflow_state function

Using the exact example found here

With the “upstream” workflow being:

[scheduler]
    cycle point format = %Y
[scheduling]
    initial cycle point = 2005
    final cycle point = 2015
   [[graph]]
      P1Y = "foo => bar"
[runtime]
   [[bar]]
      script = sleep 10
   [[foo]]
      script = sleep 5; cylc message "data ready"
      [[[outputs]]]
          x = "data ready"

And the “downstream” workflow being:

[scheduler]
    cycle point format = %Y
[scheduling]
    initial cycle point = 2010
    [[xtriggers]]
        upstream = workflow_state("up//%(point)s/foo:x"):PT10S
        clock_0 = wall_clock(offset=PT0H)
   [[graph]]
        P1Y = """
            foo
            @clock_0 & @upstream => FAM:succeed-all => blam
        """
[runtime]
    [[root]]
        script = sleep 5
    [[foo, blam]]
    [[FAM]]
    [[f1,f2,f3]]
        inherit = FAM

Tasks in the downstream workflow never seem to trigger despite the upstream workflow’s foo jobs finishing. Is this functionality just simply broken in the current version of Cylc 8? I haven’t been able to figure out what if anything i’m doing wrong.

1 Like

Hi @alice

The workflow_state xtrigger works fine, but it seems we forgot to update the documented example with a recent change to the function arguments - sorry!

$ diff flow.cylc flow.cylc.orig
6c6
<          upstream = workflow_state("up//%(point)s/foo:x", is_trigger=True):PT10S
---
>          upstream = workflow_state("up//%(point)s/foo:x"):PT10S

(The is_trigger flag is (now) required to avoid a possible ambiguity between task statuses and task messages. The documentation you’ve linked to mentions the argument but doesn’t use it in the example).

Note also that the name up should be replaced with whatever name you’ve used to run the upstream workflow.

(I’ve posted a correction to the cylc-doc repository).

1 Like

P.s. without the is_trigger argument, the “downstream” example actually fails validation with a reasonably informative error message:

$ cylc val .
XtriggerConfigError: [@upstream] workflow_state(up//%(point)s/foo:x)
No such task state "x"

… and it won’t run, for the same reason - so I’m not sure how you were able to run it?

Yeah for some reason adding the is_trigger=True
Argument didn’t fix the issue

Can you see anything relevant in the scheduler log when you run the downstream workflow with the --verbose option?

Nothing relevant that i see indicating an error of any sort.

Actually it looks like i did dnd up getting an error
TypeError: workflow_state() got an unexpected keyword argument ‘is_trigger’

Figured out how to make the function work. I had to explicitly set each keyword the function expects.
workflow_state(message=“succeeded”, point=%(point)s, task=“foo”, workflow=“up”)

Figured out how to make the function work. I had to explicitly set each keyword the function expects.

workflow_state(message=“succeeded”, point=%(point)s, task=“foo”, workflow=“up”)

You shouldn’t need to do that.

I suspect you’re not running the Cylc version that you think you are.

You linked to 8.4.1 documentation and mentioned “current version of Cylc 8” so I assumed 8.4.1.

But I actually ran the examples as quoted above, yesterday, and they worked fine with the additional function argument.

What does cylc version say?

Looks like we are using version 8.2.4

A-ha, that would explain it!

If you can’t upgrade Cylc, note that you can choose older versions of the online documentation via the bottom of the left side-panel. Here’s a direct link to 8.2.5 docs on the workflow_state xtrigger: