Comments (18)
See the section on AOT in the README https://github.com/yieldbot/flambo#aot
from flambo.
The requiring namespaces are aot'd as per the readme.
This exception shows up when flambo.api
refers in the flambo.function
vars and seems to require flambo.function
to be aot'd.
from flambo.
since flambo.api
requires flambo.function
, AOTing the all namespaces that require flambo.api
should be all that's required. If you've already done this, perhaps you can make me a gist of your project.clj and I might be able to help further.
from flambo.
https://gist.github.com/alilee/565d0097b4c36edcbd26
I'm starting to have issues when compiling/re-constructing serialised functions with closures (referencing let or param bindings inside the f/fn). Could this be related?
Thanks very much for your help.
from flambo.
I think this could be related to some subtleties in how serialised-fn works - there isn't much guidance in the docs. This is what I'm having trouble with:
(let [x {:f identity :g parse/parse-int}]
(-> sc
(f/parallelize [1 2 3 4 5])
(f/map (f/fn [i] x))
(f/take 1)))
If you take :g parse/parse-int
out, then it works fine. When I leave it in it gets clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)
coming back from the worker.
parse
is :aot
.
from flambo.
parse/parse-int must also be a serializable-fn, otherwise it cannot be
serialized by your anonymous serializable-fn.
On Tuesday, December 16, 2014, Alister Lee [email protected] wrote:
I think this could be related to some subtleties in how serialised-fn
works - there isn't much guidance in the docs. This is what I'm having
trouble with:(let [x {:f identity :g parse/parse-int}](-> sc
%28f/parallelize [1 2 3 4 5]%29
%28f/map %28f/fn [i] x%29%29
%28f/take 1%29))If you take :g parse/parse-int out, then it works fine. When I leave it
in it gets clojure.lang.Compiler$CompilerException:
java.lang.RuntimeException: Unable to resolve symbol: x in this context,
compiling:(NO_SOURCE_PATH:0:0) coming back from the worker.parse is :aot.
—
Reply to this email directly or view it on GitHub
#42 (comment).
from flambo.
I get the same issue with this:
(let [x {:f identity :g (f/fn [s] (parse/parse-int s))}]
(-> sc
(f/parallelize [1 2 3 4 5])
(f/map (f/fn [i] x))
(f/take 1)))
Is that what you were suggesting?
from flambo.
Hmmm. And same with this:
(let [x {:f identity :g (f/fn [s] (identity s))}]
(-> sc
(f/parallelize [1 2 3 4 5])
(f/map (f/fn [i] x))
(f/take 1)))
from flambo.
try moving your let
statement directly around the anonymous fn (let [x ...] (f/fn [i] x))
from flambo.
(use 'serializable.fn)
(deserialize
(serialize
(let [x +
c {:f identity :g (f/fn [s] (identity s))}
(fn [a b] (:f c)))))
;; clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: c in this context, compiling:(...)
Is this the issue? (from serializable-fn):
TODO
Recurse into collections with the deep function serialization
from flambo.
No, that is an old TODO. Deep recursion works. I'll try your example when
I'm back at a computer.
On Tuesday, December 16, 2014, Alister Lee [email protected] wrote:
(use 'serializable.fn)
(deserialize
(serialize
(let [x +
c {:f identity :g (f/fn [s](identity s))}
(fn [a b](:f c)))))
;; clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: c in this context, compiling:(...)Is this the issue? (from serializable-fn):
TODO https://github.com/yieldbot/serializable-fn#todo
Recurse into collections with the deep function serialization—
Reply to this email directly or view it on GitHub
#42 (comment).
from flambo.
Thanks a million. I think that is the issue though. Is your version ahead of yieldbot's?
(let [x {:f identity :g (f/fn [s] (identity s))} ;; x would break mapping fi but y works
y (f/fn [s] (parse/parse-int s))
fi (f/fn [i] (y i))]
(-> sc
(f/parallelize ["9" "2" "3" "4" "5"])
(f/map fi)
(f/take 1)))
;; [9]
from flambo.
So-- it seems like there is a bug in the deep recursion where elements of a map are not recursed into for serialization properly. it is the :f identity
key-value pair causing the issue. kryo is trying to serialize an instance of clojure.lang.AFunction
, which is can't do. I'll see if I can fix the bug.
from flambo.
Fantastic - thanks very much again for all your help. I will test!
from flambo.
Ok, so it's not really a bug per se. serializable.fn
uses a library called carbonite
, which is a library for using kryo to serialize clojure data structures. When serializable.fn
serializes an fn and it's bindings, it simply calls kryo's serialize, which is turn checks the class and then in the case of a clojure map, calls carbonite
here:
https://github.com/sritchie/carbonite/blob/master/src/clj/carbonite/serializer.clj#L62-L69
carbonite
doesn't know how to serialize a standard clojure function, so it effectively just fails to do so.
Unfortunately there isn't a great fix, other than not using functions as keys or values in a map if you wish it to be serializable :/
from flambo.
Or just try the stuff from PR #27. I did take it into my fork (https://github.com/chrisbetz/flambo) and it works. I could check for you later today or you give it a try yourself.
Cheers,
Chris
Am 18.12.2014 um 05:22 schrieb Soren Macbeth [email protected]:
Ok, so it's not really a bug per se. serializable.fn uses a library called carbonite, which is a library for using kryo to serialize clojure data structures. When serializable.fn serializes an fn and it's bindings, it simply calls kryo's serialize, which is turn checks the class and then in the case of a clojure map, calls carbonite here:
https://github.com/sritchie/carbonite/blob/master/src/clj/carbonite/serializer.clj#L62-L69
carbonite doesn't know how to serialize a standard clojure function, so it effectively just fails to do so.
Unfortunately there isn't a great fix, other than not using functions as keys or values in a map if you wish it to be serializable :/
—
Reply to this email directly or view it on GitHub.
from flambo.
That works, but not in the repl. You'll have to AOT all your code, losing the ability to do ad-hoc or interactive spark stuff which may or may not matter to you.
@chrisbetz I would be quite curious to see if that works in your fork or not.
from flambo.
Hi,
took me some time. You might want to check commit 99c998c in my fork for the test, which is "green".
Happy holidays,
Chris
from flambo.
Related Issues (20)
- Left Outer Join documentation is inaccurate HOT 4
- key-val-fn return NullPointerException when key is vector HOT 1
- Error using flambo sql HOT 1
- Flambo shell HOT 2
- dataframe via jdbc.write() doesn't save results? HOT 1
- Exception: org.apache.spark.SparkException: Failed to get broadcast_0_piece0 of broadcast_0 HOT 1
- Warning killing my CI HOT 3
- `flambo.sql` shadows `clojure.core/count`
- Wrapper for `.foreachRDD` is missing
- Registering User Defined Functions in SparkSQL HOT 6
- Possible issue with set-if-missing? HOT 2
- Getting error on spark job submission HOT 5
- Not working with clojure 1.9
- support spark 2.3.1 HOT 9
- Getting error while using map and filter functions HOT 1
- Getting error while setting Spark configuration
- No session ns in 0.7
- Update log4j 1.x to 2.x
- Error after submitting job to standalone cluster executor
- Add a tuple->vec function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flambo.