Skip to content

Instantly share code, notes, and snippets.

@gareth625
Created October 8, 2014 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gareth625/5d69cd883b3a154f0fa7 to your computer and use it in GitHub Desktop.
Save gareth625/5d69cd883b3a154f0fa7 to your computer and use it in GitHub Desktop.
lemur jobdef demoing the wait-on-step difficulties.
(catch-args
[:step-name
"Set as the name of the step"
"lemur-is-awesome"])
(defcluster the-cluster
:app "AnApp"
:run-id "Unique"
:num-instances 2 ; Includes the master.
:master-instance-type "m1.small"
:slave-instance-type "m1.small"
:bucket "metail-s3-scratch"
:runtime-jar "s3://fake-location"
:keypair "rar"
:endpoint "elasticmapreduce.eu-west-1.amazonaws.com")
(defstep the-step
:main-class "example.main"
:step-name "${step-name}")
(fire! the-cluster the-step)
(println "---------Raw")
(println the-step)
(println (:step-name the-step))
(println "---------Evaluated 1")
;; Not sure how to ask for the step name from this. Attempting to use it like a
;; Clojure map causes an error.
(println (lemur.evaluating-map/evaluating-map the-step))
(println "---------Evaluated 2")
(println (evaluating-step the-cluster the-step))
(println (:step-name (evaluating-step the-cluster the-step)))
(wait-on-step the-step 864000)
; (wait-on-step (lemur.evaluating-map/evaluating-map the-step) 864000)
; (wait-on-step (evaluating-step the-cluster the-step) 864000)
@gareth625
Copy link
Author

Run with: lemur run test_jobdef.clj --step-name everything-is-awesome or lemur run test_jobdef.clj.

@mlimotte
Copy link

mlimotte commented Oct 9, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment