Skip to content
Snippets Groups Projects
Commit 74961b83 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Merge branch 'issue0038' into 'staging'

Issue0038

See merge request rhodes/model_server!46
parents e4dcfbfb 39e79145
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ def main(request_func, in_abspath, params):
:param params:
pixel_classifier_path: (str) absolute path to ilastik project file that defines a pixel classifier
object_classifier_path: (str) absolute path to ilastik project file that defines an object classifier
channel: (int) channel of the input image to process
channel (optional): (int) channel of the input image to process, use all channels if not specified
:return: (str) absolute path where a new object map is written
"""
......@@ -18,7 +18,7 @@ def main(request_func, in_abspath, params):
px_ilp = params['pixel_classifier_path']
ob_ilp = params['object_classifier_path']
channel = params['channel']
channel = getattr(params, 'channel', None)
mip = params.get('mip', False)
# configure input and output paths
......
......@@ -13,18 +13,27 @@ HOST = '127.0.0.1'
PORT = 6221
uri = 'http://{}:{}/'.format(HOST, PORT)
def hit_endpoint(method, endpoint, params=None, body=None):
def hit_endpoint(method, endpoint, params=None, body=None, drop_none=True):
"""
Python 2.7 implementation of HTTP client
:param method: (str) either 'GET' or 'PUT'
:param endpoint: (str) endpoint of HTTP request
:param params: (dict) of parameters that are embedded in client request URL
:param body: (dict) of parameters that JSON-encoded and attached as payload in request
:param drop_none: (bool) remove (presumably optional) parameters with value equal to None
:return: (dict) of response status and content, formatted as dict if request is successful
"""
connection = httplib.HTTPConnection(HOST, PORT)
if not method in ['GET', 'PUT']:
raise Exception('Can only handle GET and PUT requests')
k_pop = []
if drop_none and params is not None:
for k, v in params.items():
if v is None:
k_pop.append(k)
for ki in k_pop:
params.pop(ki)
if params:
url = endpoint + '?' + urllib.urlencode(params)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment