def test_job_timeout(timeout_cl): @scannerpy.register_python_op() def timeout_fn(self, frame: FrameType) -> bytes: time.sleep(5) return bytes('what', 'utf-8') cl = timeout_cl input = NamedVideoStream(cl, 'test1') frame = cl.io.Input([input]) range_frame = cl.streams.Range(frame, ranges=[{'start': 0, 'end': 1}]) sleep_frame = cl.ops.timeout_fn(frame=range_frame) output = NamedVideoStream(cl, 'test_timeout') output_op = cl.io.Output(sleep_frame, [output]) cl.run(output_op, PerfParams.estimate(pipeline_instances_per_node=1), task_timeout=0.1, cache_mode=CacheMode.Overwrite, show_progress=False) assert not output.committed()
def test_job_blacklist(blacklist_cl): # NOTE(wcrichto): this class must NOT be at the top level. If it is, then pytest injects # some of its dependencies, and sending this class to an external Scanner process will fail # with a missing "py_test" import.. @scannerpy.register_python_op() class TestPyFail(Kernel): def execute(self, frame: FrameType) -> bytes: raise ScannerException('Test') cl = blacklist_cl input = NamedVideoStream(cl, 'test1') frame = cl.io.Input([input]) range_frame = cl.streams.Range(frame, ranges=[{'start': 0, 'end': 1}]) failed_output = cl.ops.TestPyFail(frame=range_frame) output = NamedVideoStream(cl, 'test_py_fail') output_op = cl.io.Output(failed_output, [output]) cl.run(output_op, PerfParams.estimate(pipeline_instances_per_node=1), cache_mode=CacheMode.Overwrite, show_progress=False) assert not output.committed()