wait-on-step does not wait when step name is defined using a $ variable

29 views
Skip to first unread message

Gareth Rogers

unread,
Oct 8, 2014, 6:37:15 AM10/8/14
to lemur...@googlegroups.com
Hi

I'm having a problem where if the step name is defined using a $ variable e.g. ${query} then the wait-on-step does not wait, however if the step name is a string e.g. my-beautiful-step then wait-on-step works as expected.

As far as I can tell the problem is that in wait-on-step then line to get the step name "(step :step-name)" returns the for with the $ variable present i.e. ${query} in this example rather than the evaluated form which is what the step is actually called.

I managed to get some debugging out where you can see the problem:
Steps for j-32BHIN28K7K99, looking for ${query}-query in #<ArrayList [..., {StepConfig: {Name: dynamic-step-name-query, ...}]>

vs correct behaviour:
Steps for  j-DHGS9KQ45GE , looking for hardcoded-step-name-query  in  #<ArrayList [{..., {StepConfig: {Name: hardcoded-step-name-query, ...}]>

I've started looking through the code but it isn't obvious (yet as I've found lemur.evaluating-map which looks like it's the start of the solution) how to fix it.

Do you have any suggestions?

Thanks
Gareth

Marc Limotte

unread,
Oct 8, 2014, 9:14:12 AM10/8/14
to lemur...@googlegroups.com
Gareth,

Can you share the code where you call wait-on-step?  And maybe the code where you define your step, as well.

Probably you are defining your step with defstep, which returns a plain map.  Not an evaluating-map.  This works in other contexts, because this map is wrapped in another map which is an evaluating-map.  

I haven't tried this, but I think if you wrap your step in (lemur.evaluating-map/evaluating-map gareths-step) before passing to wait-on-step, then it should work.

Possibly Lemur should be patched to have defstep return an evaluating map instead of a plain map.  Haven't totally thought through the implications, but if you do that and the tests pass, then should be ok. 

marc



--
You received this message because you are subscribed to the Google Groups "Lemur User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lemur-user+...@googlegroups.com.
To post to this group, send email to lemur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lemur-user/bb698ae4-f3a1-4780-998e-0ebc230748bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gareth Rogers

unread,
Oct 8, 2014, 11:42:17 AM10/8/14
to lemur...@googlegroups.com
Thanks for the quick response. Here's an example jobdef: https://gist.github.com/gareth625/5d69cd883b3a154f0fa7 which you should be able to run and see the problem.

A present it doesn't wait however if you uncomment the last line it will wait.

You might want to change the endpoint otherwise the job will be created in the EU and of course the job will fail but it was good enough for this purpose.

Gareth

Marc Limotte

unread,
Oct 8, 2014, 12:17:01 PM10/8/14
to lemur...@googlegroups.com
Hi Gareth,
Can you try the workaround I suggested and confirm if that works or not?

Gareth Rogers

unread,
Oct 8, 2014, 12:52:57 PM10/8/14
to lemur...@googlegroups.com
Sorry, I wasn't clear. The work around appears to be: (wait-on-step (evaluating-step the-cluster the-step) 864000).

Thanks

Marc Limotte

unread,
Oct 8, 2014, 1:21:53 PM10/8/14
to lemur...@googlegroups.com
That's worth trying, but I was also suggesting:

(wait-on-step (lemur.evaluating-map/evaluating-map the-cluster the-step) 864000)



Gareth Rogers

unread,
Oct 9, 2014, 6:12:46 AM10/9/14
to lemur...@googlegroups.com
I did try that but the object I got back didn't have the $ variables replaced. I know my gist doesn't show that (it doesn't have the-cluster) so:

(wait-on-step (lemur.evaluating-map/evaluating-map the-step) 864000)

but I tried the variation with the-cluster to:

(wait-on-step (lemur.evaluating-map/evaluating-map the-cluster the-step) 864000)

neither had the $ replaced.

I couldn't extract the step-name from the object returned from lemur.evaluating-map/evaluating-map as:

(:step-name (evaluating-step the-cluster the-step)) and ((evaluating-step the-cluster the-step) :step-name)

both triggered an exception (hence the lack of step-name print out in the gist). The few lines of my printout are:

---------Raw {:main-class example.main, :args-order (), :step-name ${step-name}} ${step-name} ---------Evaluated 1 {:main-class example.main, :args-order (), :step-name ${step-name}} lemur.evaluating_map$evaluating_map$reify__894 Exception in thread "main" java.lang.StackOverflowError at java.util.regex.Pattern$GroupTail.match(Pattern.java:4606) at java.util.regex.Pattern$Curly.match0(Pattern.java:4170) at java.util.regex.Pattern$Curly.match(Pattern.java:4132) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556) at java.util.regex.Pattern$Slice.match(Pattern.java:3870) at java.util.regex.Pattern$Start.match(Pattern.java:3408) at java.util.regex.Matcher.search(Matcher.java:1199) at java.util.regex.Matcher.find(Matcher.java:592) at clojure.string$replace_by.invoke(string.clj:63) at clojure.string$replace.invoke(string.clj:106) at lemur.evaluating_map$str_interpolate.invoke(evaluating_map.clj:42) at lemur.evaluating_map$evaluate.invoke(evaluating_map.clj:75) at lemur.evaluating_map$evaluating_map$reify__894.invoke(evaluating_map.clj:112) at lemur.evaluating_map$str_interpolate$fn__878.invoke(evaluating_map.clj:43)

Hopefully the change of fonts isn't too confusing I can't seem to get the groups composition window to make everything consistent after copying and pasting out of shells etc.

Thanks

Marc Limotte

unread,
Oct 9, 2014, 10:15:38 AM10/9/14
to lemur...@googlegroups.com

Hi Gareth,

I see your trouble, after looking more closely at the gist.

Problem 1: Running this produces a stack-overflow (an endless recursive call). That's because your defstep has a recursive definition:

{... :step-name "${step-name}"}

Asking the step for :step-name returns "${step-name}", which is then evaluated and says to ask the map for :step-name, which returns "${step-name}"... this continues indefinitely. To resolve, change the name of the command line arg to asomething else, e.g. :run-step.

Problem 2: This is what we discussed in email, defstep returns a regular map, you need an evaluating-map. Also, because you want a value from catch-args (which is part of "the-cluster"), you need to use evaluating-step as you suspected, not just evaluating-map.

I posted a corrected, annotated gist at https://gist.github.com/mlimotte/2693120f98adccbec655
Also, you can run it with lemur dry-run test_jobdef.clj. This won't test the wait-on-step, but will let you verify the step that will be run.


marc



Gareth Rogers

unread,
Oct 13, 2014, 8:09:39 AM10/13/14
to lemur...@googlegroups.com
Sorry for the slow reply, got distracted with another project. Clearly distracted enough last week not to notice the silly obvious cause of the stack overflow!

That all makes sense and it all works :)

Marc Limotte

unread,
Oct 13, 2014, 8:45:14 AM10/13/14
to lemur...@googlegroups.com
Glad that worked for you.

Reply all
Reply to author
Forward
0 new messages