예제 #1
0
 def test_full_name_config(self):
     conf = {
         SimplestTask.task_definition.full_task_family: {
             "simplest_param": "from_config"
         }
     }
     with config(conf):
         assert SimplestTask().simplest_param == "from_config"
예제 #2
0
    def test_ttask(self):
        class TTaskImpl(TTask):
            t_input = data

            def run(self):
                pass  # will faile

        bad_task_impl = TTaskImpl(t_input=SimplestTask())

        assert bad_task_impl

        class TTaskImpl(TTask):
            t_input = data
            # should not fail as we don't override input

        task = TTaskImpl(t_input=SimplestTask())
        assert_run_task(task)
        assert task
예제 #3
0
    def test_simple_task(self):
        t = SimplestTask(simplest_param=1)
        t.dbnd_run()

        t2 = SimplestTask(simplest_param=2)
        assert str(t2.simplest_output) != str(t.simplest_output)

        t3 = SimplestTask(task_band=t.task_band)

        assert str(t3.simplest_output) == str(t.simplest_output)
예제 #4
0
    def test_foreign_context_should_not_fail(self):
        with new_dbnd_context():
            t = SimplestTask()
            t.dbnd_run()

        TTaskWithInput(t_input=t).dbnd_run()
예제 #5
0
    x.join()


class TestRunFromThread(object):
    def test_thread_external_task_cmd_line(self):
        with new_dbnd_context(conf={RunConfig.task_executor_type: "local"}):

            def run():
                ttask_simple.dbnd_run()

            main_thread = Thread(target=run)
            main_thread.start()
            main_thread.join()
            t = ttask_simple.task()
            assert t._complete()

    def test_thread_safe_signal_handling(self, capsys):
        _run_in_thread(_dbnd_exception_handling)

    def test_thread_task_run(self):
        t = TTask()
        _run_in_thread(t.dbnd_run)

    def test_subprocess_inplace_run(self):
        run_dbnd_subprocess(
            [sys.executable, CURRENT_PY_FILE, "new_dbnd_context"])


if __name__ == "__main__":
    SimplestTask(task_env="local").dbnd_run()
예제 #6
0
 def test_parameter_config(self):
     conf = {SimplestTask.simplest_param: "from_config"}
     with config(conf):
         assert SimplestTask().simplest_param == "from_config"
예제 #7
0
def e_wrong_task_constructor():
    return SimplestTask(not_existing_param=1)
예제 #8
0
 def band(self):
     self.t1 = SimplestTask()
예제 #9
0
 def simple_task_with_serialization():
     run = SimplestTask().dbnd_run()
     run.run_executor.save_run_pickle(self.target("t.pickle"))