Fork me on GitHub
#clojure
<
2023-10-12
>
TMac11:10:35

Does anyone know the status of https://github.com/gdeer81/marginalia/? Seems fairly unmaintained, but I'm not aware of any successors except https://github.com/captain-porcelain/sidenotes, which is even less maintained. The idea of generating beautiful HTML files from docstrings is very much still relevant to me

Martín Varela11:10:40

I just used it this week (from a tools.deps project), and it works. It could probably use a bit of a style revamp, though.

Martín Varela11:10:36

:marginalia {:deps{marginalia/marginalia {:mvn/version "0.9.1"}}
               :main-opts ["-m" "marginalia.main" "-d" "doc/commented-code"
                           "-D" "Your project's description"]}

Martín Varela11:10:43

that alias does the trick

andy.fingerhut12:10:43

Sometimes in Clojure "unmaintained" is better described as "stable, working, without the need for further changes". Note that I say "sometimes", not "always".

4
1
TMac12:10:58

I'm specifically running into the bug which this unmerged PR from 2017 fixes https://github.com/gdeer81/marginalia/pull/175 And not wild about the prospect of forking the project for a four-token change

andy.fingerhut12:10:41

You could ask in #CE1A21MPF if someone might be willing to take that project under their maintenance in the clj-commons group of projects.

1
TMac15:10:25

I've forked it, made my small fix, and deployed to Clojars for now. Depending on adoption at work this could either be an abortive effort or it could turn into me actually doing some maintenance on it. If any future searchers of this Slack also need fixes to be deployed, feel free to ping me or open a PR to https://github.com/tsmacdonald/marginalia

Darrick Wiebe17:10:51

I usually check the Network view for projects that haven't seen much recent maintenance. Not sure if you looked, but there is someone who did a bit of work on the project and even apparently released a "1.0" version. I haven't looked in any depth at what is there, but I often find useful contributions worth adopting/merging that have built up on projects like this that aren't too active.

seancorfield17:10:43

@U30H25RT6 Had taken it over from @U050WRF8X and was actively maintaining it for quite a while but when I updated the Generating Documentation page on http://clojure-doc.org last week I noticed it hadn't had any updates for a while... and I don't know how active Gary has been here this year?

seancorfield17:10:49

@UJLF48QJC If you think you might end up doing some maintenance on it but want some support before you make any commitments, we could talk about transferring Marginalia into clj-commons where at least we could rotate through maintainers going forward?

fogus (Clojure Team)19:10:47

I've lost track of it over the years, but if people find it useful still then I would love to see it go into clj-commons or some such

❤️ 2
TMac21:10:43

Hey Sean and Fogus (hello, thanks for a lovely tool!). We're definitely going to use Marginalia at work (Metabase), so I feel good about doing some maintenance on it (no fun working on software you don't use…). I can definitely help with modernizing the tests (and setting up CI), synthesizing the various improved forks and PRs, making it work with deps.edn and not just project.clj, straightforward bugs, fielding new issues/PRs, etc. So, sounds like clj-commons is a good fit for that (and it's definitely appealing that if I run out of gas somebody else could take over and it won't just be Another Random Fork) Should I open a new issue on clj-commons/meta? I'll also open an issue on the main repo to give Gary a chance to weigh in. He hasn't posted on this Slack since 2019 or done anything public on Github this year, but maybe he's still lurking

seancorfield21:10:46

Yes, please open a meta issue. I'll def. vote for it to moved. I'll see if I can find any alternative contact deets for Gary....

👍 1
Black13:10:39

While attempting to test some of my asynchronous code, I encountered an issue when trying to redefine the async/timeout function. Has anyone solved a similar problem?

(defn fixture-timeout [_t]
  (timers/timeout 10)) ;; would like to set fixed amount of time independent of what code will set

(defn fixture-timeouts [f]
  (with-redefs [async/timeout fixture-timeout]
    (f)))

(use-fixtures :each (join-fixtures [fixture-timeouts]))

(deftest simple-test
  ;; this is ok and return a channel
  (fixture-timeout 1000)
  ;; this throws an error
  (async/timeout 1000)
  (is (fn? async/timeout)))

;; Exception is java.lang.ClassCastException
;; my example
class xcardo.queues.consumers.supervisor_test$fixture_timeout cannot be cast to class clojure.lang.IFn$LO (xcardo.queues.consumers.supervisor_test$fixture_timeout is in unnamed module of loader clojure.lang.DynamicClassLoader @3a4aed74; clojure.lang.IFn$LO is in unnamed module of loader 'app')

ghadi13:10:21

a good way to do this is to pass the timeout channels as arguments through the fns in the program

Black15:10:03

Yes, I have done it this way, but found confusing this throws an error.

Joshua Suskalo16:10:35

This looks to me like timeout has some type hints on it that your redef doesn't match.

Joshua Suskalo16:10:14

Try redefining fixture-timeout like so

(defn fixture-timeout [^long _t]
  (timers/timeout 10))

Black16:10:52

Cool I will try that, I would never come up with that! Thanks

Joshua Suskalo16:10:27

I was looking at this, and I see clojure.lang.IFn$LO which sounds like "IFn, for Long->Object" to me. I know that there's explicit overrides for some code which permit taking primitive arguments that get compiled differently, so your deftest is compiled against that specific variant which takes a primitive long and returns an object, so when you redefine it using with-redefs the type no longer lines up with what the code was compiled against.

Joshua Suskalo16:10:45

I believe the code has special variants for doubles and longs for arguments and return types up to 8 arguments?

Joshua Suskalo16:10:57

I could be wrong about how many arguments it goes out to, but I know it only special cases primitives for longs and doubles.

Black18:10:19

You were totaly right, it works now! Next time I will be able to read IFn$LO 😄

👍 1
Joshua Suskalo18:10:33

Glad I could help!

vemv16:10:14

I was reported a #:clojure.error{:phase :print-eval-result} which is a rare sight for me. It's stackoverflowerror, apparently effected by clojure.main/repl/read-eval-print while printing a huge string. Here is the stacktrace, does its pattern look familiar? https://gist.github.com/filipencopav/872acaf16c5b90dc76f398da0bb83504

p-himik16:10:20

Yep, exactly like described here: https://stuartsierra.com/2015/04/26/clojure-donts-concat

☝️ 2
👀 1
dpsutton16:10:30

I suspect the string never exists. This is turning a large collection built with (lazy) concats into a string

vemv16:10:23

We have some concats in the relevant namespace (which yup, I hate). Hopefully that will be it! > I suspect the string never exists. This is turning a large collection built with (lazy) concats into a string I'll check that out as well :thinking_face:

dpsutton16:10:19

Quick check is wrap them in an into [] to drop the function invocation

Joshua Suskalo16:10:19

Not sure about the exact context here, but maybe ropes would be helpful for your usecase? https://github.com/IGJoshua/ropes

Joshua Suskalo16:10:49

The idea behind ropes is constant time concatenation of strings and since they implement the CharSequence interface they can be used for a lot of things strings can be, including regex search targets

Joshua Suskalo16:10:30

But perhaps this wouldn't resolve the particular issue in this case if you've got so many concats as to make stack overflows.

Joshua Suskalo16:10:25

If you want a no-dependency solution to this, you could consider using vector-of with :char and use into instead of concat.

Joshua Suskalo16:10:56

That or cgrand/xforms' string reducing functions.

Pavel Filipenco17:10:58

@U11BV7MTK, the string is the result of an http GET request by clj-http/client, do those never exist? Plus, clojure's print works (instantaneous). Only on inspection it overflows, so it's some cider/emacs issue

dpsutton17:10:13

Something is building up a lazy sequence based on a bunch of concats. If that eventually ends up as a string it doesn’t seem to be making it to that point. Totally possible that it is cider doing this for inspection

👍 1
vemv17:10:55

This is the context https://github.com/clojure-emacs/cider/issues/3511 I'm looking it atm. I cannot reproduce it. (-> (clj-http.client/get "") :body)) is a String and I can inspect it. I can also run a related deftest with low Xmx and it doesn't SO.

dpsutton17:10:25

I don’t believe stack overflow is related to memory in the traditional sense

Pavel Filipenco17:10:40

yeah, because otherwise (if I don't inspect it), it works perfectly as a string

Pavel Filipenco17:10:44

How can I set the cider xmx? I'll try to test it with higher xmx

p-himik17:10:13

I don't think that's what Dan meant. You can get SO with any amount of memory. The two things are hardly related.

vemv17:10:02

You can set e.g. "-XX:MaxJavaStackTraceDepth=1000000" which is what I always do for misc reasons. Those are called JVM system properties

Pavel Filipenco17:10:08

how can I increase cider process' stack size?

dpsutton17:10:09

It’s all the same jvm. Just set your own processes memory constraints. But this is the number of function calls, not the size of stuff. And in fact I suspect you could trigger this on an empty sequence that concats a ton of empty sequences together

vemv17:10:35

...I also always set "-Xss6144k" for a similar reason

p-himik17:10:41

@U45T93RA6 At the risk of stating the obvious, when reproducing this you should use the same exact dependencies that @U060FHA3K28 has. Not just the dev toolchain, but all dependencies. Mentioning only because I don't see e.g. clj-http version in the linked issue.

Pavel Filipenco17:10:25

[clj-http "3.12.3"]

p-himik17:10:54

Can you trigger the issue with only that library on the classpath and nothing else (apart from CLJ and Lein stuff and anything else directly relevant to the issue)?

Pavel Filipenco17:10:21

linked it there. hold on, i'll check with only that library

Pavel Filipenco17:10:47

println in the repl is instantaneous and has no issues with the string, by the way

Pavel Filipenco17:10:37

(loop [i 0
       acc "x"]
    (if (< i 566607)
      (recur (+ 1 i) (concat acc "x"))
      acc))

Pavel Filipenco17:10:11

But this one is in the repl, not only on inspection

Pavel Filipenco17:10:17

Ran the snippet in lein repl:

Error printing return value (StackOverflowError) at clojure.lang.RT/seq (RT.java:535).

Pavel Filipenco17:10:28

if I pass it into println , also SO error

vemv17:10:37

As far as the original issue is concerned, the conversation continues over here https://github.com/clojure-emacs/cider/issues/3511#issuecomment-1760046563 FYI I'll unsubscribe from this thread.

Pavel Filipenco17:10:40

So it's concat's fault. Is cider's source available somewhere within emacs, if I have it installed?