portkey

Portkey: from REPL to Serverless in one call
qqq 2017-10-20T16:56:12.000012Z

I just installed a portkey function via (pk/mount): I get error:

{"errorMessage":"Error loading class portkey.LambdaStub: clojure/lang/IFn","errorType":"java.lang.NoClassDefFoundError"}
my code is:
(defn flatter []
  (str "hello world"))

(pk/mount! flatter "/hello")


Is there a wa I can manually inspect the zip/jar that was uploaded ?

baptiste-from-paris 2017-10-20T16:57:14.000347Z

Yes

baptiste-from-paris 2017-10-20T16:57:34.000318Z

You can download it on the aws interface

baptiste-from-paris 2017-10-20T16:57:50.000705Z

But you won’t learn anything as it’s bytecode

qqq 2017-10-20T16:58:07.000201Z

Weird, on the AWs interface, I see a "clj-hello" (which is some other functikn I manually uploaded), but I don' see the "flatter / hello" function.

qqq 2017-10-20T16:58:25.000435Z

I want to open up the jar/zind see if Clojure/IFN .class is somewhere there.

baptiste-from-paris 2017-10-20T16:58:30.000570Z

You sure you are in the right region ?

qqq 2017-10-20T16:59:06.000492Z

I'm an idiot.

qqq 2017-10-20T16:59:10.000459Z

Was in wrong region.

baptiste-from-paris 2017-10-20T16:59:28.000338Z

Not an idiot, this happen ;-)

baptiste-from-paris 2017-10-20T17:00:00.000019Z

Do you still mount it from boot ?

qqq 2017-10-20T17:00:20.000075Z

Yeah, I have never tried mounting from lein.

qqq 2017-10-20T17:00:32.000637Z

cgrand sent in a patch, so I assumed mounting from boot works ....

baptiste-from-paris 2017-10-20T17:00:39.000509Z

Because lambdastub call the handler that aws is waiting for, it should be present

baptiste-from-paris 2017-10-20T17:00:44.000108Z

Oh

baptiste-from-paris 2017-10-20T17:01:48.000471Z

I had some personnal stuff last week so I won’t be able to work on portkey for an other week but even if there are still bugs, your function is working for me

baptiste-from-paris 2017-10-20T17:01:53.000258Z

100% sure

qqq 2017-10-20T17:02:23.000247Z

Awesome, thanks!

qqq 2017-10-20T17:03:03.000209Z

I will take this opportunity to to build a Cryptic-AWS-Error-Msg -> how-to-fix-it map 🙂

cgrand 2017-10-20T17:03:09.000627Z

I will be back on business on Tuesday

baptiste-from-paris 2017-10-20T17:03:21.000637Z

Back from US ;-)?

baptiste-from-paris 2017-10-20T17:04:39.000262Z

@qqq that’s something that can be upgrade, how to shorten the error-message feedback loop

qqq 2017-10-20T17:21:27.000054Z

I downloaded my package (took a while to figure out the GUI). I run:

find . | grep Lambda
./com/amazonaws/services/lambda/runtime/LambdaLogger.class
./portkey/LambdaStub.class
so it appears that portkey/LambdaStub.class indeed is there.

qqq 2017-10-20T17:22:11.000628Z

find clojure
clojure
clojure/java
clojure/java/api
clojure/java/api/Clojure.class
Hmm, is that supposed to happen ?

qqq 2017-10-20T17:22:21.000493Z

I'm expecting to see clojure/foobar/IFn.class

baptiste-from-paris 2017-10-20T17:22:49.000594Z

Have you try to reboot your repl and re-mount it ?

qqq 2017-10-20T17:23:08.000349Z

I will try that right now.

cgrand 2017-10-20T17:23:40.000433Z

Almost home. Enjoying traffic jams due to the start of fall holidays.

baptiste-from-paris 2017-10-20T17:23:54.000133Z

Hehe

qqq 2017-10-20T17:25:10.000283Z

@baptiste-from-paris: same issue; will now see if I can get mount to work via a lein repl

baptiste-from-paris 2017-10-20T17:25:51.000553Z

Ok, if it doesn’t pastebin your code and I’ll try

qqq 2017-10-20T17:27:56.000425Z

lein repl
nREPL server started on port 40198 on host 127.0.0.1 - <nrepl://127.0.0.1:40198>
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.9.0-beta2
OpenJDK 64-Bit Server VM 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=&gt; (require '[portkey.core :as pk])
WARNING: get-method already refers to: #'clojure.core/get-method in namespace: portkey.aws.apigateway, being replaced by: #'portkey.aws.apigateway/get-method
nil
user=&gt; (defn ltalk [] (str "hello world"))
#'user/ltalk
user=&gt; (pk/mount! ltalk "/hi")

NullPointerException   portkey.ouroboros/bytecode (ouroboros.clj:227)
user=&gt; (ltalk)
"hello world"
user=&gt; (pk/mount! ltalk "/")

NullPointerException   portkey.ouroboros/bytecode (ouroboros.clj:227)

qqq 2017-10-20T17:28:10.000168Z

weirdness; Lein gets an ouroboros NullPointerException ?

qqq 2017-10-20T17:28:50.000343Z

here is my project.clj:

cat project.clj 
(defproject foobar "0.1.0-SNAPSHOT"
 :description "FIXME: write description"
 :url "<http://example.com/FIXME>"
 :license {:name "Eclipse Public License"
 :url "<http://www.eclipse.org/legal/epl-v10.html>"}
 :dependencies [[org.clojure/clojure "1.9.0-beta2"]
 [portkey "0.1.0-SNAPSHOT"] ])

qqq 2017-10-20T17:28:58.000450Z

I'm going to go nuke ~/.m2 and retry all this.

baptiste-from-paris 2017-10-20T17:29:06.000038Z

Ok, let me try (and take a break from my bordeaux wine)

qqq 2017-10-20T17:29:56.000014Z

hmm, I just did a git pull, ouroboros was updated, perhaps I am facing an older bug

qqq 2017-10-20T17:31:24.000775Z

success: from lein repl, I got a clj function to mount 🙂

qqq 2017-10-20T17:31:46.000032Z

I don't knowif this issue is boot vs lein or "old code vs doing a git pull"

qqq 2017-10-20T17:31:54.000153Z

but once ~/.m2 is repopulated, I will test in boot repl

baptiste-from-paris 2017-10-20T17:34:35.000116Z

Oh nice !

qqq 2017-10-20T17:35:47.000563Z

I think the boot repl is tree shaking too much.

qqq 2017-10-20T17:35:56.000098Z

lein repl -- uploaded a 4.5 MB zip

qqq 2017-10-20T17:36:06.000457Z

boot repl -- uploladed a 1.5MB zip (earlier) and a 300k zip (now)

baptiste-from-paris 2017-10-20T17:36:20.000110Z

personnaly I rarely have mounting problem, it’s more error once mounted

qqq 2017-10-20T17:36:31.000032Z

so it's apparently shaking the tree soo hard clojure function classes are being shaken off

baptiste-from-paris 2017-10-20T17:37:15.000046Z

@qqq does not sound satisfying, I think Clojure itself is around 3MB

qqq 2017-10-20T17:38:48.000420Z

find lein | grep -i clojure ; echo "==" ; find boot | grep -i clojure
lein/clojure
lein/clojure/java
lein/clojure/java/api
lein/clojure/java/api/Clojure.class
lein/lib/clojure-1.9.0-beta2.jar
==
boot/clojure
boot/clojure/java
boot/clojure/java/api
boot/clojure/java/api/Clojure.class
I downloaded the lein / boot versions.

qqq 2017-10-20T17:39:02.000101Z

The lein version includes clojure-...-.jar ; the boot version somehow does not.

qqq 2017-10-20T17:39:18.000336Z

I'm half tempted now to add the jar file into the boot version, and manually upload it 🙂

qqq 2017-10-20T17:42:15.000666Z

okay, I got the boot version to work

qqq 2017-10-20T17:42:31.000146Z

by copying over /lein-version/lib to /boot-version/lib , recreating the zip, and uploading it

qqq 2017-10-20T17:42:38.000381Z

I'm filing an issue on github.

baptiste-from-paris 2017-10-20T17:43:26.000621Z

nice !

qqq 2017-10-20T17:47:28.000019Z

@cgrand: ^-- welcome home gift for you 🙂

qqq 2017-10-20T17:48:01.000268Z

@baptiste-from-paris: thanks for the tip on downloading from aws // could not have debugged this without that

baptiste-from-paris 2017-10-20T20:07:50.000003Z

Ah gréât !

baptiste-from-paris 2017-10-20T20:08:22.000002Z

By the way, I can’t verify right now but I am pretty sure that you can download it with the api

qqq 2017-10-20T23:37:32.000003Z

@cgrand @baptiste-from-paris: i realize portkey is open source software with no SLA and the volunterr devs have lives of their own -- is there some hack I can use to get around this in boot? This is on the critical path of my work.

qqq 2017-10-20T23:54:59.000004Z

I just switched from boot to lein; this is no longer blocking me. 🙂