       (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))))

    "number" "number"
    "string"))

(defn save-dataset-definition
  "Save the definition of a dataset into the 'metadata' database."
  [name definition]
  (with-db (get-db "metadata")
    (letfn [(build-types-for-slice [slice definition]
              (let [slice-def (get-in definition [:slices slice])
                    table-name (:table slice-def)
                    table-def (get-in definition [:tables (keyword table-name)])]
                (reduce (fn [definition column]
                          (if (and (:name column)
                                   ((set (slice-columns slice-def)) (:name column)))
                            (assoc-in definition
                                      [:slices slice :types (keyword (:name column))]
                                      (slice-type-for-table-type (:type column)))
                            definition))
                        definition
                        (vals (:columns table-def)))))
            (build-types-for-slices [definition]
              (let [slices (keys (:slices definition))]
                (reduce (fn [definition slice]
                          (build-types-for-slice slice definition))
                        definition
                        slices)))]
      (coll/update "datasets" {:name name}
                   (build-types-for-slices (assoc definition :name name))
                   :upsert true))))

(defmulti cast-value (fn [_ valuedef] (:type valuedef)))


(defmethod cast-value :default [value _]
  value)

(defn- cast-data
  "Given the data from a CSV file and the definition of the data's columns,
transform that data into the form we want."
  [data columns]
