General Autotranslation

The beakerx object synchronizes values between languages, including JavaScript, Python, Groovy, Scala, and SQL. BeakerX's current implementation works with metaprogramming and serializing the objects to JSON, so it's not recommended for more than a few MB of data. Using Arrow and shared memory to remove that limitation is on the agenda, as is support in Java, Clojure, and Kotlin.

Start in Groovy:

In [ ]:
beakerx.foo = "a groovy value"

Translate to JavaScript:

In [ ]:
%%javascript
alert(beakerx.foo);
beakerx.bar = [23, 48, 7, "from JS"];

And back to Groovy:

In [ ]:
beakerx.bar

Or Python:

In [ ]:
%%python
from beakerx.object import beakerx
beakerx.bar

Or Scala:

In [ ]:
%%scala
beakerx.bar
In [ ]:
%%java
return NamespaceClient.getBeakerX().get("bar");
In [ ]:
%%kotlin
beakerx["bar"]

Pandas DataFrames

Pandas DataFrames are supported directly in Python. The resulting data is available in Groovy, however it's wrapped in a Map instead of a TableDisplay, see #7610.

In [ ]:
%%python
import pandas as pd
beakerx.rates = pd.read_csv('../resources/data/interest-rates.csv')
In [ ]:
beakerx.rates.values[0]