 (def default-date-parser (time/formatter (default-time-zone)
                                          "YYYY-MM-dd" "YYYY/MM/dd" "YYYYMMdd"))
 
-(defn run-drakefile
+(defn- run-drakefile
   "Run all tasks in a Drakefile."
   [drakefile]
   (log/info "Running Drakefile" drakefile)

          headers (map keyword (first data))]
      (map (partial zipmap headers) (doall (rest data))))))

(defn read-table
  [table definition]
  (let [tdef (get-in definition [:tables (keyword table)])
        dir (:dir definition)

      (write-concept-data concepts)
      (log/info "Loading slices for dataset" dataset)
      (load-slices concepts definition))))

(defn ez-prepare-data
  "Prepare all data you need for a dataset."
  [dataset]
  (let [dataset (name dataset)
        definition (read-definition dataset)
        dir (:dir definition)        
        drakefile (-> (str dir "/Drakefile")
                      (io/resource)
                      (io/as-file))]
    (when (and drakefile (.isFile drakefile))
      (run-drakefile drakefile))))

(defn ez-load-concepts
  "Load just the concepts for a dataset.
  Does not run Drake to process data first."
  [dataset]
  (let [dataset (name dataset)
        definition (read-definition dataset)
        concepts (read-concepts definition)]
    (with-db (get-db dataset)
      (write-concept-data concepts))))

(defn ez-load-slice
  [dataset slice]
  "Load one slice for a dataset.
  Does not run Drake to process data first. Also does not run other
  slices that the slice may depend on, so make sure you have all the
  data you need before running this."
  (let [dataset (name dataset)
        definition (read-definition dataset)
        concepts (read-concepts definition)]
    (with-db (get-db dataset)
      (load-slice slice concepts definition)
      (index-slice slice definition))))
