{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# General Autotranslation\n", "\n", "The `beakerx` object synchronizes values between languages. 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](https://arrow.apache.org/) and shared memory to remove that limitation is on the [agenda](https://github.com/twosigma/beakerx/issues/7577).\n", "\n", "Start in Groovy:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "beakerx.bar = \"a groovy value\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Translate to JavaScript:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%javascript\n", "console.log(beakerx.bar);" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%javascript\n", "beakerx.bar = [23, 48, 7, \"from JS\"];" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And back to Groovy:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "beakerx.bar " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or Python:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%python\n", "from beakerx import beakerx\n", "beakerx.bar" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%python\n", "from beakerx import beakerx\n", "beakerx.bar = [2, 'python', 'value']\n", "beakerx.bar" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or Scala:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%scala\n", "beakerx.bar" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%scala\n", "beakerx.bar = Array(3.14,\"scala\", \"value\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And back to Groovy:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "beakerx.bar" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "beakerx_kernel_parameters": {}, "classpath": [], "imports": [], "kernelspec": { "display_name": "Groovy", "language": "groovy", "name": "groovy" }, "language_info": { "codemirror_mode": "groovy", "file_extension": ".groovy", "mimetype": "", "name": "Groovy", "nbconverter_exporter": "", "version": "2.4.3" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": false, "sideBar": false, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": false, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 1 }