            [com.google.cloud.dataflow.sdk Pipeline]
            [com.google.cloud.dataflow.sdk.io TextIO$Read TextIO$Write]
            [com.google.cloud.dataflow.sdk.transforms
-            DoFn DoFn$Context ParDo DoFnTester Create
+            DoFn DoFn$Context ParDo DoFnTester Create PTransform
             SerializableFunction WithKeys GroupByKey]
            [com.google.cloud.dataflow.sdk.values PCollection]
            [com.google.cloud.dataflow.sdk.coders ByteArrayCoder StringUtf8Coder CustomCoder Coder$Context]

  (let [p (make-pipeline args)
        final (->> p
                   (generate-input [{:key :a :val 10} {:key :b :val 5} {:key :a :val 42}] {:name "gengen"})
                   (with-keys :key {:name :group-by-key})
                   (group-by-key)
                   (dmap (fn [kv] (vector (.getKey kv) (.getValue kv))) )
                   (to-edn {:name "edn"})
                   (write-text-file "tee"))]

    (.run p)))

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

