This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-13
Channels
- # beginners (78)
- # boot (27)
- # cider (13)
- # cljs-dev (41)
- # cljsrn (4)
- # clojure (216)
- # clojure-android (1)
- # clojure-conj (6)
- # clojure-greece (1)
- # clojure-italy (11)
- # clojure-russia (127)
- # clojure-spec (63)
- # clojure-uk (34)
- # clojurescript (68)
- # core-async (5)
- # cursive (5)
- # data-science (1)
- # datomic (4)
- # dirac (11)
- # editors (7)
- # events (1)
- # graphql (12)
- # hoplon (39)
- # jobs (1)
- # liberator (3)
- # lumo (101)
- # off-topic (14)
- # om (3)
- # onyx (3)
- # parinfer (14)
- # re-frame (10)
- # reagent (2)
- # remote-jobs (1)
- # ring-swagger (17)
- # sql (21)
- # untangled (38)
- # vim (3)
- # yada (23)
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?
@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
Boot-alt-test uses a pod, but doesn't create a new pod each each test run like boot-test
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
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!chromalchemy: if the file is in your resource path, you may need to use io/resource
instead of io/file
@U0AHJUHJN That worked! Now I'm able to get though that part of function!
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)))
I noticed it used File
internally
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?
the thing about boot is that you're working with a temporary "fileset" that lives in an arbitrary directory somewhere
i would guess that you need to use that earlier on to get the right path to where you're writing the file
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.
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!
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.
thanks for the help though. I never would have figured that out in short term.
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.
@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
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?
(Because I haven't made any changes to the code.. yet)
Ok thanks - that makes sense! I think I was confusing the artifact name with the namespaces it exports!
@jamesmintram np, and yup that’s the idea :thumbsup: