This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-11
Channels
- # announcements (16)
- # aws (4)
- # babashka (30)
- # beginners (58)
- # bristol-clojurians (4)
- # cider (9)
- # clj-kondo (2)
- # clojure (229)
- # clojure-europe (25)
- # clojure-gamedev (1)
- # clojure-italy (4)
- # clojure-nl (13)
- # clojure-sanfrancisco (1)
- # clojure-uk (97)
- # clojured (7)
- # clojurescript (27)
- # code-reviews (2)
- # cursive (30)
- # data-science (39)
- # datomic (14)
- # emacs (12)
- # events (2)
- # fulcro (6)
- # graalvm (8)
- # graphql (14)
- # jackdaw (10)
- # jobs (2)
- # lambdaisland (5)
- # malli (4)
- # off-topic (28)
- # protorepl (13)
- # quil (7)
- # re-frame (2)
- # reagent (1)
- # reitit (3)
- # remote-jobs (5)
- # ring-swagger (1)
- # shadow-cljs (72)
- # sql (4)
- # tools-deps (182)
- # uncomplicate (4)
- # vim (9)
- # xtdb (19)
I've also used https://github.com/owainlewis/yaml Works fine for simple use cases. More complicated yaml files (e.g. with custom tags) are more troublesome if i remember correctly. I've never been able to convert cloudformation yaml to json and edn. I still use online converters for this đ https://github.com/owainlewis/yaml/issues/27#issuecomment-507616380
copied it in the issue
@borkdude What do you think about adding a missing symbol
resolver to Sci? I have a specific use case for this. Now I have a hack:
(let [external-definitions '{a 1 b/x 2 c 5 d 9}
resolver (fn [sym]
(get external-definitions sym))
code "(+ a b/x c d)"
]
(loop [assignments {}]
(let [[state result] (try
[:ok (sci/eval-string code {:bindings assignments})]
(catch clojure.lang.ExceptionInfo e
(if-let [sym (second (re-find #"Could not resolve symbol: (.*) \[" (ex-message e) ))]
(let [missing (symbol sym)]
(if-let [assignment (resolver missing)]
[:retry (assoc assignments missing assignment)]
(throw e)))
(throw e))))]
(case state
:ok result
:retry (recur result)))))
I would like Sci to tell me what I need, but i'll explain
Ok it is a long story, but here it goes. I'm writing a aws lambda function in clojure. I'm testing it locally in my repl. However it needs to run in sci. Sci needs the definition of the code. In my case it is 5 functions I need to paste or somehow get as a string in Sci. If there would be a resolver I could do this a bit less manually (i'm not actually doing it manually, but it's uggly code like above)
Does it make sense?
Otherwise i'll just stick with my hack and show my use case when it is done
I don't get it since your resolver does the same as sci would do when you would pass those as bindings
note that the resolve function might not work well with DCE of graalvm and CLJS advanced, so it's bit of a risk to let users do it in arbitrary ways
I'll show my use case later. I can work around it
Hi! Trying to include Cognitect's aws-api as built-in in bb fails with > AnalysisGraphBuilderPhase: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.ClassLoader.defineClass(String, byte[], int, int) is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class > at parsing clojure.lang.DynamicClassLoader.defineClass(DynamicClassLoader.java:46) > at org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2470) > at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:92) > at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3272) Is there any way to fix that? Thank you!
one other problematic part might be https://github.com/cognitect-labs/aws-api/blob/2f966de5e4308b4f9039f13af8a388d63f5c437a/src/cognitect/aws/dynaload.clj#L6 due to locking, so you would have to patch that as well
I guess this could also be problematic: https://github.com/cognitect-labs/aws-api/blob/master/src/cognitect/aws/http.clj#L76-L87
I think it would make sense to fork this lib and simplify parts around resolve and locking, until it works with graalvm
Thanks a lot for looking into it! So far, GraalVM is dark magic to me so I will likely take the cljs route for now.
Graal compiles make you realize the luxury of living on the "no you don't need to care what version of glibc / zlib / esoteric-thing happens to be installed on your build machine" JVM
@holyjak I've ported cognitect.aws.util
and cognitect.aws.signers
to cljs. I think those namespaces by itself would also compile to GraalVM. This gives you the signing parts of AWS requests. To do a proper request you still need to do some manual work. So if you have other options I would advice against trying to this via GraalVM
If you want to try anyway, i would remove all the http client stuff and see if it compiles. If it does than you just need to use a different http client. E.g. ring-curl works with GraalVM
the ring-curl was chosen because of the SSL issue when you compile it on github actions
I think if you compile it locally clj-http-lite etc would be fine