Fork me on GitHub
#boot
<
2017-06-13
>
mattly16:06:21

I'm using boot watch with my test runner to have it auto-rerun tests after files are saved, but it progressively gets slower with each run, about 1/3rd of a second each time. Is this expected or any kind of known issue?

martinklepsch16:06:33

@mattly there have been some issues with pods not being disposed properly resulting in a memory leak. What test runner are you using? I think @juhoteperi made boot-alt-test or so which does not use pods

mattly16:06:07

ah, I'm using boot-test

juhoteperi16:06:29

Boot-alt-test uses a pod, but doesn't create a new pod each each test run like boot-test

juhoteperi16:06:25

So it is to be expected that boot-test can be slow with larger projects as it has to recompile even unchanged namespaces each time, but there shouldn't be reason why it gets slower each time

chromalchemy19:06:02

I'm trying to do some simple image resizing using this library, https://github.com/josephwilk/image-resizer.

(ns util.resize
  (:require
    [image-resizer.core :as core]
    [image-resizer.format :as format]
    [ :as io])

(defn myresize []
  (format/as-file
    (core/resize
      (io/file "sketch.png")
      100 100)
    "resized-sketch.png"))
sketch.png is in my resources folder, specified like : (set-env! :resource-paths #{"rsc" "src"}) Invoking myresize froma boot.build task:
(deftask resize []
  (r/myresize))
When I run boot resize, I get error:
java.lang.Thread.run

java.util.concurrent.ThreadPoolExecutor$Worker.run

 java.util.concurrent.ThreadPoolExecutor.runWorker

               java.util.concurrent.FutureTask.run

                                               ...

               clojure.core/binding-conveyor-fn/fn                          core.clj: 1938
                                 boot.core/boot/fn                          core.clj: 1030
                                               ...

                         boot.core/construct-tasks                          core.clj:
  992
                                clojure.core/apply                          core.clj:
  646
                                               ...

                             boot.user/eval6228/fn  boot.user4743533291956162745.clj:
   15
                              util.resize/myresize                        resize.clj:
   15
                         image-resizer.core/resize                          core.clj:
   20
                 image-resizer.resize/resize-fn/fn                        resize.clj:
   35
                 image-resizer.util/buffered-image                          util.clj:
   12
                        javax.imageio.ImageIO.read

javax.imageio.IIOException: Can't read input file!
clojure.lang.ExceptionInfo: Can't read input file!
    file: "C:\\Users\\rigalo\\AppData\\Local\\Temp\\boot.user4743533291956162745.clj"

    line: 37
Any hints? Seems like the http://clojure.java.io function does not see the file in my resource folder. Something to do with boot temp file structures? Do I need to explicitly use (target)? Thanks!

dave20:06:29

chromalchemy: if the file is in your resource path, you may need to use io/resource instead of io/file

chromalchemy20:06:11

@U0AHJUHJN That worked! Now I'm able to get though that part of function!

chromalchemy20:06:56

I'm still having trouble saving the resized image with given function:

(ns image-resizer.format
  (:require
   [image-resizer.fs :as fs]
   [image-resizer.core :refer :all])
  (:import
   [ File ByteArrayOutputStream ByteArrayInputStream]
   [java.awt.image BufferedImage]
   [javax.imageio ImageIO ImageWriter]))

(defn as-file [^BufferedImage buffered-file file-with-path & rest]
  (let [flags (into #{} rest)
        new-dimensions (dimensions buffered-file)
        file-name (if (contains? flags :verbatim)
                    file-with-path
                    (fs/new-filename file-with-path new-dimensions))
        file-ext (fs/extension file-name)
        resized-file (File. file-name)]
    (ImageIO/write buffered-file file-ext resized-file)
    (.getAbsolutePath resized-file)))

chromalchemy20:06:21

I noticed it used File internally

chromalchemy20:06:15

Is there a way to specify my boot config to play nice with the io/file function? Or do I need to re-write the function using io/resource to get this working with boot?

dave20:06:52

the thing about boot is that you're working with a temporary "fileset" that lives in an arbitrary directory somewhere

dave20:06:10

so io/file doesn't work because it needs to know the path to the file

dave20:06:22

io/resource works because it knows about anything in your resource path

dave20:06:16

you can still access the paths to files via .getAbsolutePath

dave20:06:43

i would guess that you need to use that earlier on to get the right path to where you're writing the file

chromalchemy20:06:46

Ok, to paraphrase: my resource folder is abstracted into the classpath by boot. io/resource knows what's in there, but io/file is looking for an absolute path. So I need to provide that path by inspecting a given resource file at compile-time.

chromalchemy20:06:19

This sounds a bit convoluted, there must be a way for io/file to see relative to boot folders, or for boot to provide environment variables to create path string as such...? I'll try it out though. Thanks for your help!

chromalchemy15:06:12

just a followup. io/resource is working to read the file. I can use the given library functions to write the files with a path like ./folder/file.png. I just need to figure out how to manage files better in the context of boot middleware so I can pass the fileset to other tasks.

chromalchemy15:06:46

thanks for the help though. I never would have figured that out in short term.

jamesmintram19:06:53

Hey. I have been looking through the boot docs.. but cannot find what I need. It (should) be pretty simple - so I thought I'd ask here. I would like to specify a dependency and give it an alias within my project. My use case, I have forked a library to fix a bug - and until that is merged back I have to stay with my fork. I do not want to update all of my code to "require" to forked version, id rather make my version accessible using the same name as the original.

alandipert19:06:18

@jamesmintram are you talking about the name of the clojure namespace you forked? or the library name? if you forked and have your own library (maven artifact name), there’s nothing to stop you from using the original namespace name

jamesmintram19:06:53

So I forked the repo and published it to clojars under my own account. Then updated the build.boot file to reference the new clojars dependency. So you are saying that should just work?

jamesmintram19:06:04

(Because I haven't made any changes to the code.. yet)

jamesmintram19:06:37

Ok thanks - that makes sense! I think I was confusing the artifact name with the namespaces it exports!

alandipert20:06:10

@jamesmintram np, and yup that’s the idea :thumbsup: