简体   繁体   English

将带有参数的 python 脚本发送到 Apache Livy

[英]Sending python script with arguments to Apache Livy

I am trying to send python script with arguments to Apache Livy.我正在尝试将带有参数的 python 脚本发送到 Apache Livy。 Already I have a code which sends content of file ( file_content ) to Livy using following python code:我已经有一个代码,它使用以下 python 代码将文件内容 ( file_content ) 发送到 Livy:

data = {
        'code': file_content
}
headers = {'Content-Type': 'application/json'}
r = requests.post(host + '/sessions/' + session_number + '/statements', data=json.dumps(data), headers=headers)

Now I would like to send python script with arguments injected into file for example on unix system this would look like this: python add_two_numbers.py 1 2 but using Apache Livy.现在我想发送带有注入文件的参数的 python 脚本,例如在 unix 系统上,这看起来像这样: python add_two_numbers.py 1 2但使用 Apache Livy。 So far I was not successful with finding a solution.到目前为止,我没有成功找到解决方案。 I would be thankful for any tips.我将不胜感激任何提示。

for your case, livy json will be "args": [1, 2]对于您的情况,livy json 将是"args": [1, 2]

if your python command is like python add_two_numbers.py --first 1 --second 2如果你的 python 命令类似于python add_two_numbers.py --first 1 --second 2

livy json will be "args": ["--first=1", "--second=2"] livy json 将是"args": ["--first=1", "--second=2"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM