CINXE.COM

Apache Zeppelin 0.10.0 Documentation: Writing a New Interpreter

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Apache Zeppelin 0.10.0 Documentation: Writing a New Interpreter</title> <meta name="description" content="Apache Zeppelin Interpreter is a language backend. Every Interpreters belongs to an InterpreterGroup. Interpreters in the same InterpreterGroup can reference each other."> <meta name="author" content="The Apache Software Foundation"> <!-- Enable responsive viewport --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Le HTML5 shim, for IE6-8 support of HTML elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> <!-- Le styles --> <link href="/docs/0.10.0/assets/themes/zeppelin/bootstrap/css/bootstrap.css" rel="stylesheet"> <link href="/docs/0.10.0/assets/themes/zeppelin/css/style.css?body=1" rel="stylesheet" type="text/css"> <link href="/docs/0.10.0/assets/themes/zeppelin/css/syntax.css" rel="stylesheet" type="text/css" media="screen" /> <!-- Le fav and touch icons --> <!-- Update these with your own images <link rel="shortcut icon" href="images/favicon.ico"> <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png"> <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png"> --> <!-- Js --> <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="/docs/0.10.0/assets/themes/zeppelin/bootstrap/js/bootstrap.min.js"></script> <script src="/docs/0.10.0/assets/themes/zeppelin/js/docs.js"></script> <script src="/docs/0.10.0/assets/themes/zeppelin/js/anchor.min.js"></script> <script src="/docs/0.10.0/assets/themes/zeppelin/js/toc.js"></script> <script src="/docs/0.10.0/assets/themes/zeppelin/js/lunr.min.js"></script> <script src="/docs/0.10.0/assets/themes/zeppelin/js/search.js"></script> <!-- atom & rss feed --> <link href="/docs/0.10.0/atom.xml" type="application/atom+xml" rel="alternate" title="Sitewide ATOM Feed"> <link href="/docs/0.10.0/rss.xml" type="application/rss+xml" rel="alternate" title="Sitewide RSS Feed"> </head> <body> <div id="menu" class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container navbar-container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <div class="navbar-brand"> <a class="navbar-brand-main" href="http://zeppelin.apache.org"> <img src="/docs/0.10.0/assets/themes/zeppelin/img/zeppelin_logo.png" width="50" style="margin-top: -2px;" alt="I'm zeppelin"> <span style="margin-left: 5px; font-size: 27px;">Zeppelin</span> <a class="navbar-brand-version" href="/docs/0.10.0" style="font-size: 15px; color: white;"> 0.10.0 </a> </a> </div> </div> <nav class="navbar-collapse collapse" role="navigation"> <ul class="nav navbar-nav"> <li> <a href="#" data-toggle="dropdown" class="dropdown-toggle">Quick Start <b class="caret"></b></a> <ul class="dropdown-menu"> <li class="title"><span>Getting Started</span></li> <li><a href="/docs/0.10.0/quickstart/install.html">Install</a></li> <li><a href="/docs/0.10.0/quickstart/explore_ui.html">Explore UI</a></li> <li><a href="/docs/0.10.0/quickstart/tutorial.html">Tutorial</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Run Mode</span></li> <li><a href="/docs/0.10.0/quickstart/kubernetes.html">Kubernetes</a></li> <li><a href="/docs/0.10.0/quickstart/docker.html">Docker</a></li> <li><a href="/docs/0.10.0/quickstart/yarn.html">Yarn</a></li> <li role="separator" class="divider"></li> <li><a href="/docs/0.10.0/quickstart/spark_with_zeppelin.html">Spark with Zeppelin</a></li> <li><a href="/docs/0.10.0/quickstart/flink_with_zeppelin.html">Flink with Zeppelin</a></li> <li><a href="/docs/0.10.0/quickstart/sql_with_zeppelin.html">SQL with Zeppelin</a></li> <li><a href="/docs/0.10.0/quickstart/python_with_zeppelin.html">Python with Zeppelin</a></li> <li><a href="/docs/0.10.0/quickstart/r_with_zeppelin.html">R with Zeppelin</a></li> </ul> </li> <li> <a href="#" data-toggle="dropdown" class="dropdown-toggle">Usage<b class="caret"></b></a> <ul class="dropdown-menu scrollable-menu"> <li class="title"><span>Dynamic Form</span></li> <li><a href="/docs/0.10.0/usage/dynamic_form/intro.html">What is Dynamic Form?</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Display System</span></li> <li><a href="/docs/0.10.0/usage/display_system/basic.html#text">Text Display</a></li> <li><a href="/docs/0.10.0/usage/display_system/basic.html#html">HTML Display</a></li> <li><a href="/docs/0.10.0/usage/display_system/basic.html#table">Table Display</a></li> <li><a href="/docs/0.10.0/usage/display_system/basic.html#network">Network Display</a></li> <li><a href="/docs/0.10.0/usage/display_system/angular_backend.html">Angular Display using Backend API</a></li> <li><a href="/docs/0.10.0/usage/display_system/angular_frontend.html">Angular Display using Frontend API</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Interpreter</span></li> <li><a href="/docs/0.10.0/usage/interpreter/overview.html">Overview</a></li> <li><a href="/docs/0.10.0/usage/interpreter/interpreter_binding_mode.html">Interpreter Binding Mode</a></li> <li><a href="/docs/0.10.0/usage/interpreter/user_impersonation.html">User Impersonation</a></li> <li><a href="/docs/0.10.0/usage/interpreter/dependency_management.html">Dependency Management</a></li> <li><a href="/docs/0.10.0/usage/interpreter/installation.html">Installing Interpreters</a></li> <!--<li><a href="/docs/0.10.0/usage/interpreter/dynamic_loading.html">Dynamic Interpreter Loading (Experimental)</a></li>--> <li><a href="/docs/0.10.0/usage/interpreter/execution_hooks.html">Execution Hooks (Experimental)</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Other Features</span></li> <li><a href="/docs/0.10.0/usage/other_features/publishing_paragraphs.html">Publishing Paragraphs</a></li> <li><a href="/docs/0.10.0/usage/other_features/personalized_mode.html">Personalized Mode</a></li> <li><a href="/docs/0.10.0/usage/other_features/customizing_homepage.html">Customizing Zeppelin Homepage</a></li> <li><a href="/docs/0.10.0/usage/other_features/notebook_actions.html">Notebook Actions</a></li> <li><a href="/docs/0.10.0/usage/other_features/cron_scheduler.html">Cron Scheduler</a></li> <li><a href="/docs/0.10.0/usage/other_features/zeppelin_context.html">Zeppelin Context</a></li> <li role="separator" class="divider"></li> <li class="title"><span>REST API</span></li> <li><a href="/docs/0.10.0/usage/rest_api/interpreter.html">Interpreter API</a></li> <li><a href="/docs/0.10.0/usage/rest_api/zeppelin_server.html">Zeppelin Server API</a></li> <li><a href="/docs/0.10.0/usage/rest_api/notebook.html">Notebook API</a></li> <li><a href="/docs/0.10.0/usage/rest_api/notebook_repository.html">Notebook Repository API</a></li> <li><a href="/docs/0.10.0/usage/rest_api/configuration.html">Configuration API</a></li> <li><a href="/docs/0.10.0/usage/rest_api/credential.html">Credential API</a></li> <li><a href="/docs/0.10.0/usage/rest_api/helium.html">Helium API</a></li> <li class="title"><span>Zeppelin SDK</span></li> <li><a href="/docs/0.10.0/usage/zeppelin_sdk/client_api.html">Client API</a></li> <li><a href="/docs/0.10.0/usage/zeppelin_sdk/session_api.html">Session API</a></li> </ul> </li> <li> <a href="#" data-toggle="dropdown" class="dropdown-toggle">Setup<b class="caret"></b></a> <ul class="dropdown-menu scrollable-menu"> <li class="title"><span>Basics</span></li> <li><a href="/docs/0.10.0/setup/basics/how_to_build.html">How to Build Zeppelin</a></li> <li><a href="/docs/0.10.0/setup/basics/hadoop_integration.html">Hadoop Integration</a></li> <li><a href="/docs/0.10.0/setup/basics/multi_user_support.html">Multi-user Support</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Deployment</span></li> <!--<li><a href="/docs/0.10.0/setup/deployment/docker.html">Docker Image for Zeppelin</a></li>--> <li><a href="/docs/0.10.0/setup/deployment/spark_cluster_mode.html#spark-standalone-mode">Spark Cluster Mode: Standalone</a></li> <li><a href="/docs/0.10.0/setup/deployment/spark_cluster_mode.html#spark-on-yarn-mode">Spark Cluster Mode: YARN</a></li> <li><a href="/docs/0.10.0/setup/deployment/spark_cluster_mode.html#spark-on-mesos-mode">Spark Cluster Mode: Mesos</a></li> <li><a href="/docs/0.10.0/setup/deployment/flink_and_spark_cluster.html">Zeppelin with Flink, Spark Cluster</a></li> <li><a href="/docs/0.10.0/setup/deployment/cdh.html">Zeppelin on CDH</a></li> <li><a href="/docs/0.10.0/setup/deployment/virtual_machine.html">Zeppelin on VM: Vagrant</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Security</span></li> <li><a href="/docs/0.10.0/setup/security/authentication_nginx.html">HTTP Basic Auth using NGINX</a></li> <li><a href="/docs/0.10.0/setup/security/shiro_authentication.html">Shiro Authentication</a></li> <li><a href="/docs/0.10.0/setup/security/notebook_authorization.html">Notebook Authorization</a></li> <li><a href="/docs/0.10.0/setup/security/datasource_authorization.html">Data Source Authorization</a></li> <li><a href="/docs/0.10.0/setup/security/http_security_headers.html">HTTP Security Headers</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Notebook Storage</span></li> <li><a href="/docs/0.10.0/setup/storage/storage.html#notebook-storage-in-local-git-repository">Git Storage</a></li> <li><a href="/docs/0.10.0/setup/storage/storage.html#notebook-storage-in-s3">S3 Storage</a></li> <li><a href="/docs/0.10.0/setup/storage/storage.html#notebook-storage-in-azure">Azure Storage</a></li> <li><a href="/docs/0.10.0/setup/storage/storage.html#notebook-storage-in-oss">OSS Storage</a></li> <li><a href="/docs/0.10.0/setup/storage/storage.html#notebook-storage-in-zeppelinhub">ZeppelinHub Storage</a></li> <li><a href="/docs/0.10.0/setup/storage/storage.html#notebook-storage-in-mongodb">MongoDB Storage</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Operation</span></li> <li><a href="/docs/0.10.0/setup/operation/configuration.html">Configuration</a></li> <li><a href="/docs/0.10.0/setup/operation/proxy_setting.html">Proxy Setting</a></li> <li><a href="/docs/0.10.0/setup/operation/upgrading.html">Upgrading</a></li> <li><a href="/docs/0.10.0/setup/operation/trouble_shooting.html">Trouble Shooting</a></li> </ul> </li> <li> <a href="#" data-toggle="dropdown" class="dropdown-toggle">Interpreter <b class="caret"></b></a> <ul class="dropdown-menu scrollable-menu"> <li class="title"><span>Interpreters</span></li> <li><a href="/docs/0.10.0/usage/interpreter/overview.html">Overview</a></li> <li role="separator" class="divider"></li> <li><a href="/docs/0.10.0/interpreter/spark.html">Spark</a></li> <li><a href="/docs/0.10.0/interpreter/flink.html">Flink</a></li> <li><a href="/docs/0.10.0/interpreter/jdbc.html">JDBC</a></li> <li><a href="/docs/0.10.0/interpreter/python.html">Python</a></li> <li><a href="/docs/0.10.0/interpreter/r.html">R</a></li> <li role="separator" class="divider"></li> <li><a href="/docs/0.10.0/interpreter/alluxio.html">Alluxio</a></li> <li><a href="/docs/0.10.0/interpreter/beam.html">Beam</a></li> <li><a href="/docs/0.10.0/interpreter/bigquery.html">BigQuery</a></li> <li><a href="/docs/0.10.0/interpreter/cassandra.html">Cassandra</a></li> <li><a href="/docs/0.10.0/interpreter/elasticsearch.html">Elasticsearch</a></li> <li><a href="/docs/0.10.0/interpreter/geode.html">Geode</a></li> <li><a href="/docs/0.10.0/interpreter/groovy.html">Groovy</a></li> <li><a href="/docs/0.10.0/interpreter/hazelcastjet.html">Hazelcast Jet</a></li> <li><a href="/docs/0.10.0/interpreter/hbase.html">HBase</a></li> <li><a href="/docs/0.10.0/interpreter/hdfs.html">HDFS</a></li> <li><a href="/docs/0.10.0/interpreter/hive.html">Hive</a></li> <li><a href="/docs/0.10.0/interpreter/ignite.html">Ignite</a></li> <li><a href="/docs/0.10.0/interpreter/influxdb.html">influxDB</a></li> <li><a href="/docs/0.10.0/interpreter/java.html">Java</a></li> <li><a href="/docs/0.10.0/interpreter/jupyter.html">Jupyter</a></li> <li><a href="/docs/0.10.0/interpreter/kotlin.html">Kotlin</a></li> <li><a href="/docs/0.10.0/interpreter/ksql.html">KSQL</a></li> <li><a href="/docs/0.10.0/interpreter/kylin.html">Kylin</a></li> <li><a href="/docs/0.10.0/interpreter/lens.html">Lens</a></li> <li><a href="/docs/0.10.0/interpreter/livy.html">Livy</a></li> <li><a href="/docs/0.10.0/interpreter/mahout.html">Mahout</a></li> <li><a href="/docs/0.10.0/interpreter/markdown.html">Markdown</a></li> <li><a href="/docs/0.10.0/interpreter/mongodb.html">MongoDB</a></li> <li><a href="/docs/0.10.0/interpreter/neo4j.html">Neo4j</a></li> <li><a href="/docs/0.10.0/interpreter/pig.html">Pig</a></li> <li><a href="/docs/0.10.0/interpreter/postgresql.html">Postgresql, HAWQ</a></li> <li><a href="/docs/0.10.0/interpreter/sap.html">SAP</a></li> <li><a href="/docs/0.10.0/interpreter/scalding.html">Scalding</a></li> <li><a href="/docs/0.10.0/interpreter/scio.html">Scio</a></li> <li><a href="/docs/0.10.0/interpreter/shell.html">Shell</a></li> <li><a href="/docs/0.10.0/interpreter/sparql.html">Sparql</a></li> <li><a href="/docs/0.10.0/interpreter/submarine.html">Submarine</a></li> </ul> </li> <li> <a href="#" data-toggle="dropdown" class="dropdown-toggle">More<b class="caret"></b></a> <ul class="dropdown-menu scrollable-menu" style="right: 0; left: auto;"> <li class="title"><span>Extending Zeppelin</span></li> <li><a href="/docs/0.10.0/development/writing_zeppelin_interpreter.html">Writing Zeppelin Interpreter</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Helium (Experimental)</span></li> <li><a href="/docs/0.10.0/development/helium/overview.html">Overview</a></li> <li><a href="/docs/0.10.0/development/helium/writing_application.html">Writing Helium Application</a></li> <li><a href="/docs/0.10.0/development/helium/writing_spell.html">Writing Helium Spell</a></li> <li><a href="/docs/0.10.0/development/helium/writing_visualization_basic.html">Writing Helium Visualization: Basics</a></li> <li><a href="/docs/0.10.0/development/helium/writing_visualization_transformation.html">Writing Helium Visualization: Transformation</a></li> <li role="separator" class="divider"></li> <li class="title"><span>Contributing to Zeppelin</span></li> <li><a href="/docs/0.10.0/setup/basics/how_to_build.html">How to Build Zeppelin</a></li> <li><a href="/docs/0.10.0/development/contribution/useful_developer_tools.html">Useful Developer Tools</a></li> <li><a href="/docs/0.10.0/development/contribution/how_to_contribute_code.html">How to Contribute (code)</a></li> <li><a href="/docs/0.10.0/development/contribution/how_to_contribute_website.html">How to Contribute (website)</a></li> <li role="separator" class="divider"></li> <li class="title"><span>External Resources</span></li> <li><a target="_blank" href="https://zeppelin.apache.org/community.html">Mailing List</a></li> <li><a target="_blank" href="https://cwiki.apache.org/confluence/display/ZEPPELIN/Zeppelin+Home">Apache Zeppelin Wiki</a></li> <li><a target="_blank" href="http://stackoverflow.com/questions/tagged/apache-zeppelin">Stackoverflow Questions about Zeppelin</a></li> </ul> </li> <li> <a href="/docs/0.10.0/search.html" class="nav-search-link"> <span class="fa fa-search nav-search-icon"></span> </a> </li> </ul> </nav><!--/.navbar-collapse --> </div> </div> <div class="content"> <!--<div class="hero-unit Writing a New Interpreter"> <h1></h1> </div> --> <div class="row"> <div class="col-md-12"> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <h1>Writing a New Interpreter</h1> <div id="toc"></div> <h2>What is Apache Zeppelin Interpreter</h2> <p>Apache Zeppelin Interpreter is a language backend. For example to use scala code in Zeppelin, you need a scala interpreter. Every Interpreters belongs to an <strong>InterpreterGroup</strong>. Interpreters in the same InterpreterGroup can reference each other. For example, SparkSqlInterpreter can reference SparkInterpreter to get SparkContext from it while they&#39;re in the same group.</p> <p><img class="img-responsive" style="width:50%; border: 1px solid #ecf0f1;" height="auto" src="/docs/0.10.0/assets/themes/zeppelin/img/interpreter.png" /></p> <p><a href="https://github.com/apache/zeppelin/blob/master/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java">InterpreterSetting</a> is configuration of a given <a href="https://github.com/apache/zeppelin/blob/master/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterGroup.java">InterpreterGroup</a> and a unit of start/stop interpreter. All Interpreters in the same InterpreterSetting are launched in a single, separate JVM process. The Interpreter communicates with Zeppelin engine via <strong><a href="https://github.com/apache/zeppelin/blob/master/zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift">Thrift</a></strong>.</p> <p>In &#39;Separate Interpreter(scoped / isolated) for each note&#39; mode which you can see at the <strong>Interpreter Setting</strong> menu when you create a new interpreter, new interpreter instance will be created per note. But it still runs on the same JVM while they&#39;re in the same InterpreterSettings.</p> <h2>Make your own Interpreter</h2> <p>Creating a new interpreter is quite simple. Just extend <a href="https://github.com/apache/zeppelin/blob/master/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java">org.apache.zeppelin.interpreter</a> abstract class and implement some methods. For your interpreter project, you need to make <code>interpreter-parent</code> as your parent project and use plugin <code>maven-enforcer-plugin</code>, <code>maven-dependency-plugin</code> and <code>maven-resources-plugin</code>. Here&#39;s one sample pom.xml </p> <div class="highlight"><pre><code class="xml language-xml" data-lang="xml"><span class="nt">&lt;project</span> <span class="na">xmlns=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span class="na">xmlns:xsi=</span><span class="s">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span class="na">xsi:schemaLocation=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span class="nt">&gt;</span> <span class="nt">&lt;modelVersion&gt;</span>4.0.0<span class="nt">&lt;/modelVersion&gt;</span> <span class="nt">&lt;parent&gt;</span> <span class="nt">&lt;artifactId&gt;</span>interpreter-parent<span class="nt">&lt;/artifactId&gt;</span> <span class="nt">&lt;groupId&gt;</span>org.apache.zeppelin<span class="nt">&lt;/groupId&gt;</span> <span class="nt">&lt;version&gt;</span>0.9.0-SNAPSHOT<span class="nt">&lt;/version&gt;</span> <span class="nt">&lt;relativePath&gt;</span>../interpreter-parent<span class="nt">&lt;/relativePath&gt;</span> <span class="nt">&lt;/parent&gt;</span> ... <span class="nt">&lt;dependencies&gt;</span> <span class="nt">&lt;dependency&gt;</span> <span class="nt">&lt;groupId&gt;</span>org.apache.zeppelin<span class="nt">&lt;/groupId&gt;</span> <span class="nt">&lt;artifactId&gt;</span>zeppelin-interpreter<span class="nt">&lt;/artifactId&gt;</span> <span class="nt">&lt;version&gt;</span>${project.version}<span class="nt">&lt;/version&gt;</span> <span class="nt">&lt;scope&gt;</span>provided<span class="nt">&lt;/scope&gt;</span> <span class="nt">&lt;/dependency&gt;</span> <span class="nt">&lt;/dependencies&gt;</span> <span class="nt">&lt;build&gt;</span> <span class="nt">&lt;plugins&gt;</span> <span class="nt">&lt;plugin&gt;</span> <span class="nt">&lt;artifactId&gt;</span>maven-enforcer-plugin<span class="nt">&lt;/artifactId&gt;</span> <span class="nt">&lt;/plugin&gt;</span> <span class="nt">&lt;plugin&gt;</span> <span class="nt">&lt;artifactId&gt;</span>maven-dependency-plugin<span class="nt">&lt;/artifactId&gt;</span> <span class="nt">&lt;/plugin&gt;</span> <span class="nt">&lt;plugin&gt;</span> <span class="nt">&lt;artifactId&gt;</span>maven-resources-plugin<span class="nt">&lt;/artifactId&gt;</span> <span class="nt">&lt;/plugin&gt;</span> <span class="nt">&lt;/plugins&gt;</span> <span class="nt">&lt;/build&gt;</span> <span class="nt">&lt;/project&gt;</span> </code></pre></div> <p>You should include <code>org.apache.zeppelin:zeppelin-interpreter:[VERSION]</code> as your interpreter&#39;s dependency in <code>pom.xml</code>. Bes And you should put your jars under your interpreter directory with a specific directory name. Zeppelin server reads interpreter directories recursively and initializes interpreters including your own interpreter.</p> <p>There are three locations where you can store your interpreter group, name and other information. Zeppelin server tries to find the location below. Next, Zeppelin tries to find <code>interpreter-setting.json</code> in your interpreter jar.</p> <div class="highlight"><pre><code class="text language-text" data-lang="text">{ZEPPELIN_INTERPRETER_DIR}/{YOUR_OWN_INTERPRETER_DIR}/interpreter-setting.json </code></pre></div> <p>Here is an example of <code>interpreter-setting.json</code> on your own interpreter.</p> <div class="highlight"><pre><code class="json language-json" data-lang="json"><span class="p">[</span> <span class="p">{</span> <span class="nt">&quot;group&quot;</span><span class="p">:</span> <span class="s2">&quot;your-group&quot;</span><span class="p">,</span> <span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;your-name&quot;</span><span class="p">,</span> <span class="nt">&quot;className&quot;</span><span class="p">:</span> <span class="s2">&quot;your.own.interpreter.class&quot;</span><span class="p">,</span> <span class="nt">&quot;properties&quot;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&quot;properties1&quot;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&quot;envName&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span> <span class="nt">&quot;propertyName&quot;</span><span class="p">:</span> <span class="s2">&quot;property.1.name&quot;</span><span class="p">,</span> <span class="nt">&quot;defaultValue&quot;</span><span class="p">:</span> <span class="s2">&quot;propertyDefaultValue&quot;</span><span class="p">,</span> <span class="nt">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Property description&quot;</span><span class="p">,</span> <span class="nt">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;textarea&quot;</span> <span class="p">},</span> <span class="nt">&quot;properties2&quot;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&quot;envName&quot;</span><span class="p">:</span> <span class="err">PROPERTIES_</span><span class="mi">2</span><span class="p">,</span> <span class="nt">&quot;propertyName&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span> <span class="nt">&quot;defaultValue&quot;</span><span class="p">:</span> <span class="s2">&quot;property2DefaultValue&quot;</span><span class="p">,</span> <span class="nt">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Property 2 description&quot;</span><span class="p">,</span> <span class="nt">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;textarea&quot;</span> <span class="p">},</span> <span class="err">...</span> <span class="p">},</span> <span class="nt">&quot;editor&quot;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&quot;language&quot;</span><span class="p">:</span> <span class="s2">&quot;your-syntax-highlight-language&quot;</span><span class="p">,</span> <span class="nt">&quot;editOnDblClick&quot;</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span> <span class="nt">&quot;completionKey&quot;</span><span class="p">:</span> <span class="s2">&quot;TAB&quot;</span> <span class="p">},</span> <span class="nt">&quot;config&quot;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&quot;runOnSelectionChange&quot;</span><span class="p">:</span> <span class="kc">true</span><span class="err">/</span><span class="kc">false</span><span class="p">,</span> <span class="nt">&quot;title&quot;</span><span class="p">:</span> <span class="kc">true</span><span class="err">/</span><span class="kc">false</span><span class="p">,</span> <span class="nt">&quot;checkEmpty&quot;</span><span class="p">:</span> <span class="kc">true</span><span class="err">/</span><span class="kc">false</span> <span class="p">}</span> <span class="p">},</span> <span class="p">{</span> <span class="err">...</span> <span class="p">}</span> <span class="p">]</span> </code></pre></div> <p>Finally, Zeppelin uses static initialization with the following:</p> <div class="highlight"><pre><code class="java language-java" data-lang="java"><span class="kd">static</span> <span class="o">{</span> <span class="n">Interpreter</span><span class="o">.</span><span class="na">register</span><span class="o">(</span><span class="s">&quot;MyInterpreterName&quot;</span><span class="o">,</span> <span class="n">MyClassName</span><span class="o">.</span><span class="na">class</span><span class="o">.</span><span class="na">getName</span><span class="o">());</span> <span class="o">}</span> </code></pre></div> <p><strong>Static initialization is deprecated and will be supported until 0.6.0.</strong></p> <p>The name will appear later in the interpreter name option box during the interpreter configuration process. The name of the interpreter is what you later write to identify a paragraph which should be interpreted using this interpreter.</p> <div class="highlight"><pre><code class="text language-text" data-lang="text">%MyInterpreterName some interpreter specific code... </code></pre></div> <h2>Editor setting for Interpreter</h2> <p>You can add <code>editor</code> object to <code>interpreter-setting.json</code> file to specify paragraph editor settings.</p> <h3>Language</h3> <p>If the interpreter uses a specific programming language (like Scala, Python, SQL), it is generally recommended to add a syntax highlighting supported for that to the note paragraph editor.</p> <p>To check out the list of languages supported, see the <code>mode-*.js</code> files under <code>zeppelin-web/bower_components/ace-builds/src-noconflict</code> or from <a href="https://github.com/ajaxorg/ace-builds/tree/master/src-noconflict">github.com/ajaxorg/ace-builds</a>.</p> <p>If you want to add a new set of syntax highlighting, </p> <ol> <li>Add the <code>mode-*.js</code> file to <code><a href="https://github.com/apache/zeppelin/blob/master/zeppelin-web/bower.json">zeppelin-web/bower.json</a></code> (when built, <code><a href="https://github.com/apache/zeppelin/blob/master/zeppelin-web/src/index.html">zeppelin-web/src/index.html</a></code> will be changed automatically).</li> <li><p>Add <code>language</code> field to <code>editor</code> object. Note that if you don&#39;t specify language field, your interpreter will use plain text mode for syntax highlighting. Let&#39;s say you want to set your language to <code>java</code>, then add:</p> <div class="highlight"><pre><code class="json language-json" data-lang="json"><span class="s2">&quot;editor&quot;</span><span class="err">:</span> <span class="p">{</span> <span class="nt">&quot;language&quot;</span><span class="p">:</span> <span class="s2">&quot;java&quot;</span> <span class="p">}</span> </code></pre></div></li> </ol> <h3>Edit on double click</h3> <p>If your interpreter uses mark-up language such as markdown or HTML, set <code>editOnDblClick</code> to <code>true</code> so that text editor opens on pargraph double click and closes on paragraph run. Otherwise set it to <code>false</code>.</p> <div class="highlight"><pre><code class="json language-json" data-lang="json"><span class="s2">&quot;editor&quot;</span><span class="err">:</span> <span class="p">{</span> <span class="nt">&quot;editOnDblClick&quot;</span><span class="p">:</span> <span class="kc">false</span> <span class="p">}</span> </code></pre></div> <h3>Completion key (Optional)</h3> <p>By default, <code>Ctrl+dot(.)</code> brings autocompletion list in the editor. Through <code>completionKey</code>, each interpreter can configure autocompletion key. Currently <code>TAB</code> is only available option.</p> <div class="highlight"><pre><code class="json language-json" data-lang="json"><span class="s2">&quot;editor&quot;</span><span class="err">:</span> <span class="p">{</span> <span class="nt">&quot;completionKey&quot;</span><span class="p">:</span> <span class="s2">&quot;TAB&quot;</span> <span class="p">}</span> </code></pre></div> <h3>Notebook paragraph display title (Optional)</h3> <p>The notebook paragraph does not display the title by default. You can have the title of the notebook display the title by <code>config.title=true</code>.</p> <div class="highlight"><pre><code class="json language-json" data-lang="json"><span class="s2">&quot;config&quot;</span><span class="err">:</span> <span class="p">{</span> <span class="nt">&quot;title&quot;</span><span class="p">:</span> <span class="kc">true</span> <span class="err">#</span> <span class="err">default</span><span class="p">:</span> <span class="kc">false</span> <span class="p">}</span> </code></pre></div> <h3>Notebook run on selection change (Optional)</h3> <p>The dynamic form in the notebook triggers execution when the selection is modified. You can make the dynamic form in the notebook not trigger execution after selecting the modification by setting <code>config.runOnSelectionChange=false</code>.</p> <div class="highlight"><pre><code class="json language-json" data-lang="json"><span class="s2">&quot;config&quot;</span><span class="err">:</span> <span class="p">{</span> <span class="nt">&quot;runOnSelectionChange&quot;</span><span class="p">:</span> <span class="kc">false</span> <span class="err">#</span> <span class="err">default</span><span class="p">:</span> <span class="kc">true</span> <span class="p">}</span> </code></pre></div> <h3>Check if the paragraph is empty before running (Optional)</h3> <p>The notebook&#39;s paragraph default will not run if it is empty. You can set <code>config.checkEmpty=false</code>, to run even when the paragraph of the notebook is empty.</p> <div class="highlight"><pre><code class="json language-json" data-lang="json"><span class="s2">&quot;config&quot;</span><span class="err">:</span> <span class="p">{</span> <span class="nt">&quot;checkEmpty&quot;</span><span class="p">:</span> <span class="kc">false</span> <span class="err">#</span> <span class="err">default</span><span class="p">:</span> <span class="kc">true</span> <span class="p">}</span> </code></pre></div> <h2>Install your interpreter binary</h2> <p>Once you have built your interpreter, you can place it under the interpreter directory with all its dependencies.</p> <div class="highlight"><pre><code class="text language-text" data-lang="text">[ZEPPELIN_HOME]/interpreter/[INTERPRETER_NAME]/ </code></pre></div> <h2>Configure your interpreter</h2> <p>To configure your interpreter you need to follow these steps:</p> <ol> <li><p>Start Zeppelin by running <code>./bin/zeppelin-daemon.sh start</code>.</p></li> <li><p>In the interpreter page, click the <code>+Create</code> button and configure your interpreter properties. Now you are done and ready to use your interpreter.</p></li> </ol> <blockquote> <p><strong>Note :</strong> Interpreters released with zeppelin have a <a href="https://github.com/apache/zeppelin/blob/master/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java#L397">default configuration</a> which is used when there is no <code>conf/zeppelin-site.xml</code>.</p> </blockquote> <h2>Use your interpreter</h2> <h3>0.5.0</h3> <p>Inside of a note, <code>%[INTERPRETER_NAME]</code> directive will call your interpreter. Note that the first interpreter configuration in zeppelin.interpreters will be the default one.</p> <p>For example,</p> <div class="highlight"><pre><code class="scala language-scala" data-lang="scala"><span class="o">%</span><span class="n">myintp</span> <span class="k">val</span> <span class="n">a</span> <span class="k">=</span> <span class="s">&quot;My interpreter&quot;</span> <span class="n">println</span><span class="o">(</span><span class="n">a</span><span class="o">)</span> </code></pre></div> <h3>0.6.0 and later</h3> <p>Inside of a note, <code>%[INTERPRETER_GROUP].[INTERPRETER_NAME]</code> directive will call your interpreter.</p> <p>You can omit either <code>[INTERPRETER\_GROUP]</code> or <code>[INTERPRETER\_NAME]</code>. If you omit <code>[INTERPRETER\_NAME]</code>, then first available interpreter will be selected in the <code>[INTERPRETER\_GROUP]</code>. Likewise, if you skip <code>[INTERPRETER\_GROUP]</code>, then <code>[INTERPRETER\_NAME]</code> will be chosen from default interpreter group.</p> <p>For example, if you have two interpreter <code>myintp1</code> and <code>myintp2</code> in group <code>mygrp</code>, you can call myintp1 like</p> <div class="highlight"><pre><code class="text language-text" data-lang="text">%mygrp.myintp1 codes for myintp1 </code></pre></div> <p>and you can call <code>myintp2</code> like</p> <div class="highlight"><pre><code class="text language-text" data-lang="text">%mygrp.myintp2 codes for myintp2 </code></pre></div> <p>If you omit your interpreter name, it&#39;ll select first available interpreter in the group ( <code>myintp1</code> ).</p> <div class="highlight"><pre><code class="text language-text" data-lang="text">%mygrp codes for myintp1 </code></pre></div> <p>You can only omit your interpreter group when your interpreter group is selected as a default group.</p> <div class="highlight"><pre><code class="text language-text" data-lang="text">%myintp2 codes for myintp2 </code></pre></div> <h2>Examples</h2> <p>Checkout some interpreters released with Zeppelin by default.</p> <ul> <li><a href="https://github.com/apache/zeppelin/tree/master/spark">spark</a></li> <li><a href="https://github.com/apache/zeppelin/tree/master/markdown">markdown</a></li> <li><a href="https://github.com/apache/zeppelin/tree/master/shell">shell</a></li> <li><a href="https://github.com/apache/zeppelin/tree/master/jdbc">jdbc</a></li> </ul> <h2>Contributing a new Interpreter to Zeppelin releases</h2> <p>We welcome contribution to a new interpreter. Please follow these few steps:</p> <ul> <li>First, check out the general contribution guide <a href="https://zeppelin.apache.org/contribution/contributions.html">here</a>.</li> <li>Follow the steps in <a href="#make-your-own-interpreter">Make your own Interpreter</a> section and <a href="#editor-setting-for-interpreter">Editor setting for Interpreter</a> above.</li> <li>Add your interpreter as in the <a href="#configure-your-interpreter">Configure your interpreter</a> section above; also add it to the example template <a href="https://github.com/apache/zeppelin/blob/master/conf/zeppelin-site.xml.template">zeppelin-site.xml.template</a>.</li> <li>Add tests! They are run for all changes and it is important that they are self-contained.</li> <li>Include your interpreter as a module in <a href="https://github.com/apache/zeppelin/blob/master/pom.xml"><code>pom.xml</code></a>.</li> <li>Add documentation on how to use your interpreter under <code>docs/interpreter/</code>. Follow the Markdown style as this <a href="https://github.com/apache/zeppelin/blob/master/docs/interpreter/elasticsearch.md">example</a>. Make sure you list config settings and provide working examples on using your interpreter in code boxes in Markdown. Link to images as appropriate (images should go to <code>docs/assets/themes/zeppelin/img/docs-img/</code>). And add a link to your documentation in the navigation menu (<code>docs/_includes/themes/zeppelin/_navigation.html</code>).</li> <li>Most importantly, ensure licenses of the transitive closure of all dependencies are list in <a href="https://github.com/apache/zeppelin/blob/master/zeppelin-distribution/src/bin_license/LICENSE">license file</a>.</li> <li>Commit your changes and open a <a href="https://github.com/apache/zeppelin/pulls">Pull Request</a> on the project <a href="https://github.com/apache/zeppelin">Mirror on GitHub</a>; check to make sure Travis CI build is passing.</li> </ul> </div> </div> <hr> <footer> <!-- <p>&copy; 2021 The Apache Software Foundation</p>--> </footer> </div> <script type="text/javascript"> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-45176241-5', 'zeppelin.apache.org'); ga('require', 'linkid', 'linkid.js'); ga('send', 'pageview'); </script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10