12
12
import pytest
13
13
from ruamel .yaml .comments import CommentedMap , CommentedSeq
14
14
from schema_salad .avro .schema import Names
15
+ from schema_salad .ref_resolver import file_uri
15
16
from schema_salad .utils import yaml_no_ts
16
17
17
18
import cwltool .load_tool
18
19
import cwltool .singularity
19
20
import cwltool .udocker
20
- from cwltool .command_line_tool import CommandLineTool
21
- from cwltool .context import LoadingContext , RuntimeContext
21
+ from cwltool .context import RuntimeContext
22
22
from cwltool .main import main
23
23
from cwltool .mpi import MpiConfig , MPIRequirementName
24
+ from cwltool .process import Process
24
25
25
26
from .util import get_data , working_directory
26
27
@@ -292,15 +293,22 @@ def schema_ext11() -> Generator[Names, None, None]:
292
293
293
294
mpiReq = CommentedMap ({"class" : MPIRequirementName , "processes" : 1 })
294
295
containerReq = CommentedMap ({"class" : "DockerRequirement" })
295
- basetool = CommentedMap ({"cwlVersion" : "v1.1" , "inputs" : CommentedSeq (), "outputs" : CommentedSeq ()})
296
+ basetool = CommentedMap (
297
+ {
298
+ "cwlVersion" : "v1.1" ,
299
+ "class" : "CommandLineTool" ,
300
+ "inputs" : CommentedSeq (),
301
+ "outputs" : CommentedSeq (),
302
+ }
303
+ )
296
304
297
305
298
306
def mk_tool (
299
307
schema : Names ,
300
308
opts : list [str ],
301
309
reqs : Optional [list [CommentedMap ]] = None ,
302
310
hints : Optional [list [CommentedMap ]] = None ,
303
- ) -> tuple [LoadingContext , RuntimeContext , CommentedMap ]:
311
+ ) -> tuple [RuntimeContext , Process ]:
304
312
tool = basetool .copy ()
305
313
306
314
if reqs is not None :
@@ -313,50 +321,52 @@ def mk_tool(
313
321
rc = RuntimeContext (vars (args ))
314
322
lc = cwltool .main .setup_loadingContext (None , rc , args )
315
323
lc .avsc_names = schema
316
- return lc , rc , tool
324
+ tool ["id" ] = file_uri (os .path .abspath ("./mktool.cwl" ))
325
+ lc .loader .idx [tool ["id" ]] = tool
326
+ return rc , cwltool .load_tool .load_tool (tool , lc )
317
327
318
328
319
329
def test_singularity (schema_ext11 : Names ) -> None :
320
- lc , rc , tool = mk_tool (schema_ext11 , ["--singularity" ], reqs = [mpiReq , containerReq ])
321
- clt = CommandLineTool ( tool , lc )
330
+ rc , clt = mk_tool (schema_ext11 , ["--singularity" ], reqs = [mpiReq , containerReq ])
331
+ clt . _init_job ({}, rc )
322
332
jr = clt .make_job_runner (rc )
323
333
assert jr is cwltool .singularity .SingularityCommandLineJob
324
334
325
335
326
336
def test_udocker (schema_ext11 : Names ) -> None :
327
- lc , rc , tool = mk_tool (schema_ext11 , ["--udocker" ], reqs = [mpiReq , containerReq ])
328
- clt = CommandLineTool ( tool , lc )
337
+ rc , clt = mk_tool (schema_ext11 , ["--udocker" ], reqs = [mpiReq , containerReq ])
338
+ clt . _init_job ({}, rc )
329
339
jr = clt .make_job_runner (rc )
330
340
assert jr is cwltool .udocker .UDockerCommandLineJob
331
341
332
342
333
343
def test_docker_hint (schema_ext11 : Names ) -> None :
334
344
# Docker hint, MPI required
335
- lc , rc , tool = mk_tool (schema_ext11 , [], hints = [containerReq ], reqs = [mpiReq ])
336
- clt = CommandLineTool ( tool , lc )
345
+ rc , clt = mk_tool (schema_ext11 , [], hints = [containerReq ], reqs = [mpiReq ])
346
+ clt . _init_job ({}, rc )
337
347
jr = clt .make_job_runner (rc )
338
348
assert jr is cwltool .job .CommandLineJob
339
349
340
350
341
351
def test_docker_required (schema_ext11 : Names ) -> None :
342
352
# Docker required, MPI hinted
343
- lc , rc , tool = mk_tool (schema_ext11 , [], reqs = [containerReq ], hints = [mpiReq ])
344
- clt = CommandLineTool ( tool , lc )
353
+ rc , clt = mk_tool (schema_ext11 , [], reqs = [containerReq ], hints = [mpiReq ])
354
+ clt . _init_job ({}, rc )
345
355
jr = clt .make_job_runner (rc )
346
356
assert jr is cwltool .docker .DockerCommandLineJob
347
357
348
358
349
359
def test_docker_mpi_both_required (schema_ext11 : Names ) -> None :
350
360
# Both required - error
351
- lc , rc , tool = mk_tool (schema_ext11 , [], reqs = [mpiReq , containerReq ])
352
- clt = CommandLineTool (tool , lc )
361
+ rc , clt = mk_tool (schema_ext11 , [], reqs = [mpiReq , containerReq ])
353
362
with pytest .raises (cwltool .errors .UnsupportedRequirement ):
354
- clt .make_job_runner (rc )
363
+ clt ._init_job ({}, rc )
364
+ clt .make_job_runner (rc )
355
365
356
366
357
367
def test_docker_mpi_both_hinted (schema_ext11 : Names ) -> None :
358
368
# Both hinted - error
359
- lc , rc , tool = mk_tool (schema_ext11 , [], hints = [mpiReq , containerReq ])
360
- clt = CommandLineTool (tool , lc )
369
+ rc , clt = mk_tool (schema_ext11 , [], hints = [mpiReq , containerReq ])
361
370
with pytest .raises (cwltool .errors .UnsupportedRequirement ):
362
- clt .make_job_runner (rc )
371
+ clt ._init_job ({}, rc )
372
+ clt .make_job_runner (rc )
0 commit comments