def _multi_dataurl_op(self, urls, ops, model=None, local_ids=None, meta=None,
payload=None, **kwargs):
""" If sending image_url or image_file strings, then we can send as json directly instead of the
multipart form. """
if urls is not None: # for feedback, this might not be required.
if not isinstance(urls, list):
urls = [urls]
self._check_batch_size(urls)
if not isinstance(urls[0], basestring):
raise Exception("urls must be strings")
data = self._setup_multi_data(ops, len(urls), model, local_ids, meta, **kwargs)
# Add some addition url specific stuff to data dict:
if urls is not None:
data['url'] = urls
if payload:
assert isinstance(payload, dict), "Addition payload must be a dict"
for (k, v) in iteritems(payload):
data[k] = v
url = self._url_for_op(ops)
kwargs = {'data': data}
raw_response = self._get_raw_response(
self._get_json_headers, self._get_json_response, url, kwargs)
return self._parse_response(raw_response)
评论列表
文章目录