def test_python_task_execution(): fn, args, kwargs = sum, [range(5)], {} task = PythonTask(fn=fn, args=args, kwargs=kwargs, id='test-id') task = decode(encode(task)) assert task() == 10 def fn(lst1, lst2): return sum(lst1) - sum(lst2) args = [range(5), range(3)] task = PythonTask(fn=fn, args=args, id='test-id') task = decode(encode(task)) assert task() == 7
def test_decode_framework_info(): message = mesos_pb2.FrameworkInfo(id=mesos_pb2.FrameworkID(value='test')) wrapped = decode(message) assert isinstance(wrapped, MessageProxy) assert isinstance(wrapped, FrameworkInfo) assert isinstance(wrapped.id, MessageProxy) assert isinstance(wrapped.id, FrameworkID)
def test_python_task_status_decode(): data = {'arbitrary': 'data', 'lst': [1, 2, 3]} dumped = cloudpickle.dumps(data) proto = mesos_pb2.TaskStatus( data=dumped, labels=mesos_pb2.Labels(labels=[mesos_pb2.Label(key='python')])) status = decode(proto) assert isinstance(status, PythonTaskStatus) assert status['data'] == dumped assert status.data == data proto = mesos_pb2.TaskStatus(labels=mesos_pb2.Labels( labels=[mesos_pb2.Label(key='python')])) status = decode(proto) status.data = data assert isinstance(status, PythonTaskStatus) assert status.data == data assert status['data'] == dumped
def test_python_task_decode(): fn, args, kwargs = sum, [range(5)], {} data = (fn, args, kwargs) dumped = cloudpickle.dumps(data) proto = mesos_pb2.TaskInfo( data=dumped, labels=mesos_pb2.Labels(labels=[mesos_pb2.Label(key='python')])) task = decode(proto) assert isinstance(task, PythonTask) assert task['data'] == dumped assert task.data == data proto = mesos_pb2.TaskInfo(labels=mesos_pb2.Labels( labels=[mesos_pb2.Label(key='python')])) task = decode(proto) task.data = data assert isinstance(task, PythonTask) assert task.data == data assert task['data'] == dumped
def test_python_task_status_decode(): data = {'arbitrary': 'data', 'lst': [1, 2, 3]} dumped = cloudpickle.dumps(data) proto = mesos_pb2.TaskStatus( data=dumped, labels=mesos_pb2.Labels( labels=[mesos_pb2.Label(key='python')])) status = decode(proto) assert isinstance(status, PythonTaskStatus) assert status['data'] == dumped assert status.data == data proto = mesos_pb2.TaskStatus( labels=mesos_pb2.Labels( labels=[mesos_pb2.Label(key='python')])) status = decode(proto) status.data = data assert isinstance(status, PythonTaskStatus) assert status.data == data assert status['data'] == dumped
def test_python_task_decode(): fn, args, kwargs = sum, [range(5)], {} data = (fn, args, kwargs) dumped = cloudpickle.dumps(data) proto = mesos_pb2.TaskInfo( data=dumped, labels=mesos_pb2.Labels( labels=[mesos_pb2.Label(key='python')])) task = decode(proto) assert isinstance(task, PythonTask) assert task['data'] == dumped assert task.data == data proto = mesos_pb2.TaskInfo( labels=mesos_pb2.Labels( labels=[mesos_pb2.Label(key='python')])) task = decode(proto) task.data = data assert isinstance(task, PythonTask) assert task.data == data assert task['data'] == dumped