                   vmsg (validate-job exp op (or phase compfile))]
               (if (not-empty vmsg)
                 (send-end-msg ws {:op :validate :payload vmsg})
-                (let [work-item (or phase cmd)
-                      tempnm (str (name exp) "-" work-item "-job-template")
+                (let [tempnm (get-job-name exp op (or phase compfile))
                       template (get-jobinfo tempnm)
                       params (assoc params :template template)]
-                  (user-msg {:op op :params params})))))))
+                  (user-msg {:op op :params params}))))))
+
+        (send-end-msg
+         ws {:op :error :payload (format "No such cmd '%s'" (name op))}))
       (catch Error e
         (errorf "ERROR %s: %s, %s" eid op (or (.getMessage e) e))
         (send-end-msg ws {:op :validate :payload (.getMessage e)}))

                                         (with-out-str (pprint status)))
                                        (format
                                         "Finished:\n%s\nFinal result:\n%s"
                                         (with-out-str (pprint status))
                                         (with-out-str (pprint res))))]
                             (with-out-str
                               (print (format "%s : %s started @ %s\n%s"
                                              eid action timestamp rstg))))
                          result)))]
      (send-end-msg ws {:op :status :payload retmsg}))))


(defmethod user-msg :run [msg]

(defn job-exists? [jobname]
  (@job-configs jobname))

(defn get-job-name [exp cmd work-item]
  (if (= cmd :run)
    (str (name exp) "-" work-item "-job-template")
    (str (name exp) "-" (name cmd)"-job-template")))

(defn validate-job [exp cmd work-item]
  (let [jobname (get-job-name exp cmd work-item)]
    (if (job-exists? jobname)
      ""
      (if (= cmd :run)
        (format "No job for experiment type '%s' with cmd '%s' for phase '%s'"
                (name exp) (name cmd) work-item)
        (format "No job for experiment type '%s' with cmd '%s'"
                (name exp) (name cmd))))))

(defn get-jobinfo [jobname]
  (assert (@job-configs jobname)
