                    {})
           cycle-step-ms (or cycle-step-ms (:cycle-step-ms config))
           _ (when-not cycle-step-ms
-              (throw (ex-info "Must configure cycle-step-ms on command line or config file")))
+              (throw (ex-info "Must configure cycle-step-ms on command line or config file" {})))
           task-ents (simulate hosts
                               (cheshire/parse-stream (clojure.java.io/reader trace-file) true)
                               cycle-step-ms
-                              config)]
+                              config
+                              (str out-trace-file ".temp-" (System/nanoTime)))]
       (println "tasks run: " (count task-ents))
       (dump-jobs-to-csv task-ents out-trace-file)
       (println "Done writing trace")


(defn dump-jobs-to-csv
  "Given a mesos db, dump a csv with a row per task"
  [task-ents file]
  ;; Use snake case to make it easier for downstream tools to consume
  (let [headers [:job_id :instance_id :group_id :submit_time_ms :mesos_start_time_ms :start_time_ms
                 :end_time_ms :hostname :slave_id :status :reason :user :mem :cpus :job_name
                 :requested_run_time :expected_run_time :requested_status]
        tasks (map generate-task-trace-map task-ents)]
    (with-open [out-file (io/writer file)]
      (csv/write-csv out-file
                     (concat [(mapv name headers)]
                             (map (apply juxt headers) tasks))))))

(defn pull-all-task-ents

        config {:shares [{:cpus (/ host-cpus 10) :gpus 1.0 :mem (/ host-mem 10) :user "default"}]
                :scheduler-config {:rebalancer-config {:max-preemption 1.0}
                                   :fenzo-config {:fenzo-max-jobs-considered 200}}}
        out-trace-a (simulate hosts jobs cycle-step-ms config nil)
        out-trace-b (simulate hosts jobs cycle-step-ms config nil)]
    (is (> (count out-trace-a) 0))
    (is (> (count out-trace-b) 0))
    (is (traces-equivalent? out-trace-a out-trace-b)
