Exemplo n.º 1
0
def test_commandLineTool_job_tmpdir_prefix(tmp_path: Path) -> None:
    """Test that non-docker enabled CommandLineTool respects temp directory directives."""
    loading_context = LoadingContext({
        "metadata": {
            "cwlVersion": INTERNAL_VERSION,
            "http://commonwl.org/cwltool#original_cwlVersion":
            INTERNAL_VERSION,
        }
    })
    clt = CommandLineTool(
        cast(
            CommentedMap,
            cmap({
                "cwlVersion": INTERNAL_VERSION,
                "class": "CommandLineTool",
                "inputs": [],
                "outputs": [],
                "requirements": [],
            }),
        ),
        loading_context,
    )
    tmpdir_prefix = str(tmp_path / "1")
    tmp_outdir_prefix = str(tmp_path / "2")
    runtime_context = RuntimeContext({
        "tmpdir_prefix": tmpdir_prefix,
        "tmp_outdir_prefix": tmp_outdir_prefix,
    })
    job = next(clt.job({}, None, runtime_context))
    assert isinstance(job, JobBase)
    assert job.stagedir and job.stagedir.startswith(tmpdir_prefix)
    assert job.tmpdir and job.tmpdir.startswith(tmpdir_prefix)
    assert job.outdir and job.outdir.startswith(tmp_outdir_prefix)
Exemplo n.º 2
0
def test_input_can_be_named_pipe(tmp_path: Path, streamable: bool,
                                 streaming_allowed: bool,
                                 raise_exception: bool) -> None:
    """Test that input can be a named pipe."""
    clt = CommandLineTool(
        toolpath_object,
        loading_context,
    )

    runtime_context = RuntimeContext()
    runtime_context.streaming_allowed = streaming_allowed

    path = tmp_path / "tmp"
    os.mkfifo(path)

    joborder: CWLObjectType = {
        "inp": {
            "class": "File",
            "location": str(path),
            "streamable": streamable,
        }
    }

    job = next(clt.job(joborder, None, runtime_context))
    assert isinstance(job, JobBase)

    if raise_exception:
        with pytest.raises(WorkflowException):
            job._setup(runtime_context)
    else:
        job._setup(runtime_context)
Exemplo n.º 3
0
def test_regular_file() -> None:
    """Test that regular files do not raise any exception when they are checked in job._setup."""
    clt = CommandLineTool(
        toolpath_object,
        loading_context,
    )
    runtime_context = RuntimeContext()

    joborder: CWLObjectType = {
        "inp": {
            "class": "File",
            "location": get_data("tests/wf/whale.txt"),
        }
    }

    job = next(clt.job(joborder, None, runtime_context))
    assert isinstance(job, JobBase)

    job._setup(runtime_context)
def test_docker_commandLineTool_job_tmpdir_prefix(tmp_path: Path) -> None:
    """Test that docker enabled CommandLineTool respects temp directory directives."""
    loading_context = LoadingContext({
        "metadata": {
            "cwlVersion": INTERNAL_VERSION,
            ORIGINAL_CWLVERSION: INTERNAL_VERSION,
        }
    })
    clt = CommandLineTool(
        cast(
            CommentedMap,
            cmap({
                "cwlVersion":
                INTERNAL_VERSION,
                "class":
                "CommandLineTool",
                "inputs": [],
                "outputs": [],
                "requirements": [{
                    "class": "DockerRequirement",
                    "dockerPull": "docker.io/debian:stable",
                }],
            }),
        ),
        loading_context,
    )
    tmpdir_prefix = str(tmp_path / "1")
    tmp_outdir_prefix = str(tmp_path / "2")
    runtime_context = RuntimeContext({
        "tmpdir_prefix": tmpdir_prefix,
        "tmp_outdir_prefix": tmp_outdir_prefix,
    })
    job = next(clt.job({}, None, runtime_context))
    assert isinstance(job, JobBase)
    assert job.stagedir and job.stagedir.startswith(tmpdir_prefix)
    assert job.tmpdir and job.tmpdir.startswith(tmpdir_prefix)
    assert job.outdir and job.outdir.startswith(tmp_outdir_prefix)