Fork me on GitHub
#clojure
<
2019-01-04
>
vemv07:01:54

Is there something like https://github.com/NoRedInk/rspec-retry for clojure.test?

greywolve07:01:52

To refresh specific tests, or refresh in general?

vemv07:01:59

To re-run a test that is failing, operating under the assumption that the test is flaky

greywolve08:01:39

Ah, none that I'm aware of then

Noah Bogart13:01:39

test-refresh?

vemv13:01:38

have used it in the past. I don't recall that it re-reruns failed tests speculatively

Noah Bogart13:01:04

> Runs previously failing tests first, giving you feedback even quicker.

Noah Bogart13:01:16

oh speculatively, yeah i don't know about that

Audrius10:01:09

how to get a hash of a data structure in Clojure?

chrisblom10:01:54

(hash datastructure)

๐Ÿ‘ 15
๐Ÿ˜‚ 15
genmeblog11:01:21

reminds me my question from yesterday: how to resolve a symbol in a macro? answer: (resolve s)

Aitor14:01:48

Hello! I'm new here, I posted this message in #beginners but I think it's not the best place... here it goes: We are working on a project were Datomic is being used. We want to analyze de data using ML alorightms (we are data analyst). The thing is we don't event know where to start from!! Could someone point me in any direction?

john14:01:29

@aaguirre in addition to the official datomic docs, this might be helpful summary http://tonsky.me/blog/unofficial-guide-to-datomic-internals/

john14:01:14

It's basically a stream of datoms, which you can just use like data however you want

Aitor14:01:30

thx John, I'll check it now ๐Ÿ™‚ I'm sure I'll find interesting things there

john14:01:44

Slice up history using as-of and since https://docs.datomic.com/on-prem/filters.html

john14:01:36

There's more convo about it over in #datomic def ask around in there too

greywolve14:01:19

@aaguirre are you already familiar with datalog?

greywolve14:01:49

(uses Datomic)

Aitor16:01:21

I've seen that there's a way to connect python to datomic with the pydatomic library, which access datomic DBMS via the REST API

greywolve19:01:44

@aaguirre the REST API is legacy now, see https://docs.datomic.com/on-prem/rest.html , it's replaced by the Client API

Aitor11:01:11

I've seen that PyDatomic uses the Rest API

Aitor11:01:28

not the client api

Aitor11:01:54

I think that's the only way to connect Python with datomic

Aitor11:01:57

isn't it?

greywolve14:01:17

Yeah, unfortunately ๐Ÿ˜ hopefully it continues to work well enough

Aitor15:01:57

that's not a bad news

Aitor15:01:08

thx for your help greywolve

๐Ÿ‘ 5
Aitor14:01:16

I've read the documentation about it, but I haven't use it. So I wouldnt say Iam "familiar"

Aitor15:01:28

anyway,my question was more related to arquitecture

Aitor15:01:58

for example, can I somehow connect Spark to Datomic?

isaac16:01:20

defrecord can't catch closure?

(let [x 3] (defrecord Foo [] IFoo (foo [this] x)))

Alex Miller (Clojure team)16:01:28

reify can be used to create instances of an interface that close over state

jaide16:01:28

Is there a way to run a clojure -main from outside the project dir like?

cd ~/Projects
clj --dir ~/Projects/find-git-files -m find-git-files.cmdline ./

alcamech16:01:17

is there a native way to deploy an uberjar with lein ? I am trying to do this using a CI Server with lein installed on it.

jaide16:01:52

I think I figured it out, I can use the -Sdeps flag pointing to the repo to include it in the classpath

jaide17:01:15

clj -Sdeps "{:deps {find-git-remotes {:local/root \"./find-git-remotes\"}}}" -m find-git-remotes
seems to be working but Iโ€™m curious if thereโ€™s a cleaner way to do that.

pesterhazy17:01:22

Struggling with lein's uberjar feature, I'm confused why we're not making this not easier for people

pesterhazy17:01:24

Here's my summary: - most of the time AOT compilation is not desirable - ns-level forms are executed during AOT compilation, which is confusing - the only reason why most people use AOT is to set the entry point for the uberjar so that you can java -jar uberjar.jar instead of the - often superior - java -cp uberjar.jar -m foo.main

pesterhazy17:01:57

The whole situation confuses people: - people don't understand how gen-class works or why it's necessary - leiningen warns and unnecessarily suggests that you should set :aot :all - which doesn't seem like a good default to me - if you specify :aot [foo.main] explicitly, that works but due to a bug in lein it compiles the ns twice if you also set :main foo.main https://github.com/technomancy/leiningen/issues/2521

pesterhazy17:01:52

Really all you want is to generate a class that does the equivalent of these two lines: https://github.com/pesterhazy/lein-aot-example/blob/master/src/foo/main.clj#L7-L8

pesterhazy17:01:53

AIUI most projects will be better off doing that than AOT'ing everything

pesterhazy17:01:18

... given that the Clojure compiler is very fast, it doesn't blur the line between compile time and run time and other issues with AOT'ing

pesterhazy17:01:38

Is there something I'm missing here?

alcamech17:01:46

Can you deploy an uberjar with lein deploy ?

Alex Miller (Clojure team)17:01:07

you shouldnโ€™t, at least not in public repos

lilactown17:01:14

I think there's also a perception that AOT helps with startup time

pesterhazy17:01:23

@lilactown I mean it'll be faster because the compile step isn't needed but is there any advantage to aot'ing other than that?

lilactown17:01:53

ยฏ\(ใƒ„)/ยฏ

ghadi17:01:23

if youโ€™re deploying an application: AOT is fine. library: donโ€™t AOT

ghadi17:01:51

yes, it helps with startup time significantly

ghadi17:01:19

https://clojure.org/reference/compilation is the bible on it, not whatever lein says

pesterhazy18:01:53

@ghadi that distinction between lib and app code is useful, thanks

ghadi18:01:48

lein uberjar generally does both tar and AOT

pesterhazy18:01:34

by default lein uberjar doesn't aot, unless you specify :main or :aot AFAIK

jaide18:01:38

Wrote this tiny cli tool to update git remotes in all of my projects. However, since I need to write to the file Iโ€™m reading I have to read all the lines of each config file into a seq, process them, then write to the file, move to next file. Is there a way to make that more efficient so I donโ€™t need to load an entire config into memory at once like in line #23?

jaide18:01:03

Oops! Too much context. Boiled the question down and asked in beginners channel where it more likely belongs ๐Ÿ™‚

pesterhazy18:01:50

@ghadi also thanks for providing the link to the justification for aot'ing. Part of the problem is that leiningen is undocumented, except for the sample project.clj

pesterhazy18:01:29

a better default for lein, I think, would be to do the moral equivalent of lein run in the uberjar

pesterhazy18:01:11

then users would be able to enable aot'ing as necessary, irrespective of whether they're building an uberjar or not

pesterhazy18:01:33

as it is, lein unnecessarily complects aot'ing and creating uberjars

hiredman18:01:16

that is not true

hiredman18:01:42

it is, that must have changed at some point

hiredman18:01:07

ugh, five years ago

alcamech18:01:05

I figured out how to deploy an uberjar lein do uberjar, deploy [release-repo] [identifer] [version] path/to/uberjar, deploy [release-repo]

noisesmith18:01:36

@alcamech does the last step do anything?

noisesmith18:01:59

is that if you want to deploy both a jar and an uberjar?

alcamech18:01:33

@noisesmith, Yeah I should have specified that. I wanted to deploy both a jar and an uberjar. I knew how to deploy a jar but not an uberjar.

Lennart Buit20:01:51

hmm I noticed that pulling in git dependencies from a deps.edn is not possible when pulling over ssh with an ed25519 keypair. I know thats a limitation of the JGit library (https://bugs.eclipse.org/bugs/show_bug.cgi?id=520927), but shouldnโ€™t that be something that is worth documenting in tools.gitlibโ€™s readme?

Lennart Buit20:01:32

Or is there some workaround I am missing

ghadi20:01:34

itโ€™s annoying but make sure you use an ssh agent @lennart.buit

ghadi20:01:45

export SSH_AUTH_SOCK=โ€ฆpath to your agent socket

ghadi20:01:52

you also may have to modify entries within .ssh/config โ€” specifically remove IdentityFile and let your ssh-agent be smart about it

Lennart Buit20:01:12

Right, but only the ed25519 public key is known to GH right.

Lennart Buit20:01:14

Hmm maybe I have multiple issues at the same time :โ€™), eyeballing https://dev.clojure.org/jira/browse/TDEPS-91

Alex Miller (Clojure team)20:01:23

yes, thatโ€™s a separate issue

Alex Miller (Clojure team)20:01:47

I believe itโ€™s probably something you can get around by editing your ~/.ssh/known_hosts, but certainly not the best

Alex Miller (Clojure team)20:01:21

Iโ€™d like to make the switch to just using git but I need to strategize how to best do that without breaking lots of people

Lennart Buit20:01:03

right, because that would need git to be explicitly installed right

Lennart Buit20:01:48

as in the C binaries + all other git fluff

seancorfield20:01:06

@alexmiller Maybe attempt to shell out to git and fallback to jgit if that fails?

Alex Miller (Clojure team)21:01:25

well Iโ€™m thinking that we would maybe initially ship with support for both and have some way for user to override

Alex Miller (Clojure team)21:01:57

but default logic would probably be git falling back to jgit (as Iโ€™d like to eventually remove jgit entirely)

๐Ÿ‘ 5
phil21:01:51

Hey, all. I'm using deps.edn and building my project on Gitlab. It takes ages because it pulls the clojars deps everytime. How can I find out where on the filesystem those deps end up so that I can cache them?

phil21:01:06

I was expecting it to be ~/.m2, but that seems not to be the case...

hiredman22:01:15

are all your dependencies maven artifacts? those should all end up in m2

hiredman22:01:57

any git dependencies will be in ~/.gitlibs

hiredman22:01:13

but if you are downloading stuff from clojars, then it should end up in /.m2 then I would double check your build environment, you building in a container or something and getting a fresh /.m2 everytime, etc

phil22:01:31

Cheers, will dig more.

borkdude22:01:58

@phil it seems that .m2 is the location they use by default: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Maven.gitlab-ci.yml and caching the dir .m2/repository should work

phil22:01:24

@borkdude Thanks, I've actually seen that before, it didn't seem to work for me.

phil22:01:10

I'll just do a find and bruteforce my way to finding out where they are.

enforser22:01:42

no need to brute force. write the output of find to a file. Then run find again after into a different file. then do: vim -d file1 file2 to see the difference between the two ๐Ÿ™‚

phil22:01:22

Yea, well, that's really what I mean by bruteforce.

arlicle22:01:32

Is this a bug?

hiredman22:01:08

type returns a instance of java.lang.Class

hiredman22:01:10

clojure.lang.Keyword is a symbol (that evaluates to a java.lang.Class object) and case test-constants are not evaluated

enforser22:01:21

case only works with compile time literals. Try condp = instead

arlicle22:01:41

thank you very much:)

borkdude22:01:36

@phil you can also run clojure -Spath

schmidt7323:01:30

When writing websites, is it recommended to stick to standard HTML? Writing with a DSL such as Hiccup seems powerful, but I'm wondering about how I should handle CSS/Javascript then.

devo23:01:54

For css you might try https://github.com/noprompt/garden if you are looking for a DSL similar to hiccup.

devo23:01:00

Additionally because hiccup emits HTML, you can just write plain css or js to accompany it and link those resources as you would normally. Otherwise, #garden and #clojurescript are the likely recommendations you will see if you plan on using hiccup to serve templated HTML.

schmidt7323:01:59

That makes sense.

schmidt7323:01:31

@U1RUG108P is it kosher to have both clojurescript + clojure in same project? I'm using ring + compojure for the backend.

schmidt7323:01:38

Thanks for help btw.

devo23:01:23

It's perfectly alright to have both clojure and clojurescript in the same project. In fact, clojure supports reader conditionals https://clojure.org/guides/reader_conditionals to maximize code sharing between the two. Many fullstack applications have a considerable amount of code written in .cljc files in order to facilitate this.

devo23:01:50

If you are using leiningen you might take a look at https://github.com/emezeske/lein-cljsbuild for getting started.

schmidt7323:01:55

Will lein-cljsbuild work with lein-repl?

schmidt7323:01:13

Currently I run lein repl :headless and then connect with cider in emacs.

schmidt7323:01:31

To reset the state of the webserver I run (mount/start)

sonnyto00:01:52

@UA5LS8DMJ I created CHP because it is better to use hiccup instead of HTML https://bitbucket.org/sonwh98/chp/src/master/

devo15:01:58

@UA5LS8DMJ You have a couple of options. One is to just use the built-in support ala https://github.com/emezeske/lein-cljsbuild/blob/1.1.7/doc/REPL.md. Another is to use middleware and launch a clojurescript repl from your main repl via something like https://github.com/nrepl/piggieback.