Support python function input
For example: http POST http://127.0.0.1:7070/v1/executions function_id=<FUNCTION_ID> input:='{"param1": "value1"}' X-Auth-Token:<TOKEN> Change-Id: I04ead79c22ead5720eaab58f456568a7ed9b23b4
This commit is contained in:
parent
80302f534e
commit
0d3ba2f7c8
@ -181,7 +181,7 @@ runtime/function/execution in Qinling.
|
||||
main()
|
||||
EOF
|
||||
$ pip install requests -t ~/qinling_test
|
||||
$ zip ~/qinling_test/qinling_test.zip ~/qinling_test/*
|
||||
$ zip -r ~/qinling_test/qinling_test.zip ~/qinling_test/*
|
||||
|
||||
.. end
|
||||
|
||||
|
@ -76,11 +76,12 @@ class ExecutionsController(rest.RestController):
|
||||
|
||||
db_model = db_api.create_execution(params)
|
||||
|
||||
self.engine_client.create_execution(
|
||||
db_model.id, function_id, runtime_id,
|
||||
input=params.get('input'),
|
||||
is_sync=is_sync
|
||||
)
|
||||
if not func_url:
|
||||
self.engine_client.create_execution(
|
||||
db_model.id, function_id, runtime_id,
|
||||
input=params.get('input'),
|
||||
is_sync=is_sync
|
||||
)
|
||||
|
||||
if is_sync:
|
||||
db_model = db_api.get_execution(db_model.id)
|
||||
|
@ -12,7 +12,7 @@ in their function packages through Qinling API or CLI.
|
||||
You'll need access to a Docker registry to push the image, by default it's
|
||||
docker hub. After modification, build a new image and upload to docker hub:
|
||||
|
||||
docker build -t USER/python-runtime. && docker push USER/python-runtime
|
||||
docker build -t USER/python-runtime . && docker push USER/python-runtime
|
||||
|
||||
|
||||
## Using the image in Qinling
|
||||
|
@ -33,7 +33,7 @@ file_name = ''
|
||||
def download():
|
||||
download_url = request.form['download_url']
|
||||
function_id = request.form['function_id']
|
||||
token = request.form['token']
|
||||
token = request.form.get('token')
|
||||
|
||||
headers = {}
|
||||
if token:
|
||||
@ -67,9 +67,17 @@ def execute():
|
||||
importer = zipimport.zipimporter(file_name)
|
||||
module = importer.load_module('main')
|
||||
|
||||
input = {}
|
||||
if request.form:
|
||||
# Refer to:
|
||||
# http://werkzeug.pocoo.org/docs/0.12/datastructures/#werkzeug.datastructures.MultiDict
|
||||
input = request.form.to_dict()
|
||||
|
||||
app.logger.debug('Invoking function with input: %s' % input)
|
||||
|
||||
start = time.time()
|
||||
try:
|
||||
result = module.main()
|
||||
result = module.main(**input)
|
||||
except Exception as e:
|
||||
result = str(e)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user