def get_request_args()

in src/ab/controllers/algorithm.py [0:0]


def get_request_args(algorithm_name):
    body = {'args': {}}

    if request.is_json:
        body.update(request.get_json())
    if request.args:
        body['args'].update(multi_dict_to_flat_dict(request.args))

    if request.method == 'POST':
        if request.form:
            body['args'].update(multi_dict_to_flat_dict(request.form))
        if request.files:
            # bugfix: py3.5, d.update(request.files) get {k: [v]}, while py3.6 get {k: v}
            body['args'].update(multi_dict_to_flat_dict(request.files))

    # data source from config
    if app.config.FORCE_DATA_SOURCE and body.get('data_source'):
        logger.warning('config.FORCE_DATA_SOURCE is set, "data_source" in request body ignored')


    # data source piority.
    # 0. force: app.config.FORCE_DATA_SOURCE
    # 1. request : body.get('data_source')
    # 2. decorator: it's extracted from `algo params`, return object if it's a datasource, else return None
    # 3. config : app.config.DATA_SOURCE
    data_source = app.config.FORCE_DATA_SOURCE \
                  or body.get('data_source') \
                  or DataSource.retrieve_datasource_object(algorithm_util.retrieve_algorithm_params(algorithm_name)) \
                  or app.config.DATA_SOURCE
    if data_source:
        body['data_source'] = data_source

    # parse response format
    f = request.path[-4:]
    if f == ".zip":
        body['format'] = "gzip"
    else:
        body['format'] = "identity"
    return body