如何从命令行运行Zeppelin Notebook(自动) [英] How to run zeppelin notebook from command line (automatically)
问题描述
-
我们如何从命令行运行笔记本?
How do we run the notebook from command line?
进一步到1,如何将命令行参数传递到笔记本中? IE.从笔记本代码中访问命令行参数?
Further to 1, how would I pass command line arguments into the notebook? I.e. access the command line args from within the notebook code?
推荐答案
所以我遇到了同样的问题,并设法找出如何使用API使用curl来运行笔记本.至于传递命令行参数,则认为根本无法做到这一点-您将不得不在服务器上使用某种共享状态(例如,让笔记本从文件中读取并修改文件).
So I had the same issue and managed to work out how to use the API to run a notebook using curl. As for passing in command line arguments think there is simply no way to do that - you will have to use some sort of shared state on the server (e.g. have the notebook read from a file, and modify the file).
无论如何,这是我设法运行笔记本的方式,它假定已安装jq
.相当参与:(
Anyway this is how I managed to run a notebook, it assumes jq
is installed. Pretty involved :(
curl -XGET http://${ip}:8080/api/interpreter/setting | jq '.body[] | .id'
interpreter_settings_ids=`curl -XGET http://${ip}:8080/api/interpreter/setting | jq '.body[] | .id'`
id_array="["`echo ${interpreter_settings_ids} | tr ' ' ','`"]"
curl -XPUT -d $id_array http://${ip}:8080/api/notebook/interpreter/bind/${notebook_id}
curl -XPOST http://${ip}:8080/api/notebook/job/${notebook_id}
如果有人手动单击了解释器绑定的保存"按钮,则仅需要最后一个命令.
If someone has manually clicked the "save" button for the interpreter binding then only the last command is required.
更新:
好的,我认为您可以循环以检查正在运行的笔记本的状态以确定笔记本是否失败,请参见:
OK I think you can loop to probe the status of the running notebook to determine if the notebook failed, see: https://github.com/eBay/Zeppelin/blob/master/docs/rest-api/rest-notebook.md
例如
function job_success {
num_cells=`curl -XGET http://${ip}:8080/api/notebook/job/${notebook_id} 2>/dev/null | jq '.body[] | .status' | wc -l`
num_successes=`curl -XGET http://${ip}:8080/api/notebook/job/${notebook_id} 2>/dev/null | jq '.body[] | .status' | grep FINISHED | wc -l`
test ${num_cells} = ${num_successes}
}
function job_fail {
curl -XGET http://${ip}:8080/api/notebook/job/${notebook_id} 2>/dev/null | jq '.body[] | .status' | grep ERROR
}
until job_success || job_fail
do
sleep 10
done
这篇关于如何从命令行运行Zeppelin Notebook(自动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!