                    (TextIO$Write/to to))))))
   ([to pcoll] (write-text-file to {} pcoll)))
 
+(defn- write-edn-file-transform
+  [to options]
+  (let [safe-opts (dissoc options :name)]
+    (proxy [PTransform] []
+      (apply [^PCollection pcoll]
+        (->> pcoll
+             (to-edn)
+             (write-text-file to options))))))
+
+(defn write-edn-file
+  ([to options ^PCollection pcoll]
+   (let [opts (assoc options :label :write-edn-file)]
+     (-> pcoll
+         (.apply (write-edn-file-transform to opts)))))
+  ([to pcoll] (write-edn-file to {} pcoll)))
+
 (comment
   (compile 'datasplash.core))
 

         (.apply (GroupByKey/create)))))
  ([pcoll] (group-by-key {} pcoll)))

(defn make-pipeline
  [str-args]
  (let [builder (PipelineOptionsFactory/fromArgs

  (let [p (make-pipeline args)
        final (->> p
                   (generate-input [{:key :a :val 10} {:key :b :val 5} {:key :a :val 42}] {:name "gengen"})
                   (dgroup-by :key)
                   (dmap (fn [kv] (vector (.getKey kv) (seq (.getValue kv)))) )
                   (write-edn-file "gs://oscaro-test-dataflow/results/group-by.edn" {:name :output-edn}))]

    (.run p)))
