Beispiel #1
0
def test_context_dir():
    with tempdir() as d1:
        with context_dir(d1 / "foo") as d2:
            foo = d2 / "foo"
            with open(foo, "wt") as out:
                out.write("foo")

        assert foo.exists()

        with context_dir() as d3:
            bar = d3 / "bar"
            with open(bar, "wt") as out:
                out.write("bar")

        assert not bar.exists()

        d4 = d1 / "blorf"
        assert not d4.exists()
        with context_dir(d4):
            assert d4.exists()
        with context_dir(d4, cleanup=True):
            pass
        assert not d4.exists()

    assert not foo.exists()
Beispiel #2
0
 def _run_test(_executor_name):
     executor = create_executor(_executor_name, import_dir_paths,
                                user_config)
     with context_dir(user_config.default_execution_dir,
                      change_dir=True):
         executor.run_workflow(wdl_path,
                               inputs=inputs,
                               expected=expected,
                               **kwargs)
Beispiel #3
0
 def _run_workflow(wdl_script: Union[str, Path],
                   workflow_name: Optional[str] = None,
                   inputs: Optional[dict] = None,
                   expected: Optional[dict] = None,
                   executor_name: str = "cromwell",
                   **kwargs):
     executor_class = EXECUTORS.get(executor_name)
     if not executor_class:
         raise RuntimeError(
             f"{executor_name} executor plugin is not installed")
     executor = executor_class(
         project_root=project_root,
         import_dirs=import_dirs,
         **user_config.get_executor_defaults(executor_name))
     with context_dir(user_config.default_execution_dir, change_dir=True):
         executor.run_workflow(wdl_script, workflow_name, inputs, expected,
                               **kwargs)
Beispiel #4
0
    def _run_test(self,
                  executor_name: str,
                  wdl_path: Path,
                  inputs: Optional[dict] = None,
                  expected: Optional[dict] = None,
                  callback: Optional[Callable[[str, Path, dict], None]] = None,
                  **kwargs) -> dict:
        executor = create_executor(executor_name, self._import_dirs,
                                   self._user_config)

        with context_dir(self._user_config.default_execution_dir,
                         change_dir=True) as execution_dir:
            outputs = executor.run_workflow(wdl_path,
                                            inputs=inputs,
                                            expected=expected,
                                            **kwargs)

            if callback:
                callback(executor_name, execution_dir, outputs)

            return outputs