11import pytest
2- from .. task import ShellTask
3- from . .submitter import Submitter
2+ from pydra . engine . specs import ShellDef
3+ from pydra . engine .submitter import Submitter
44from fileformats .generic import File
5- from . .environments import Docker
5+ from pydra . engine .environments import Docker
66from pydra .design import shell , workflow
7+ from pydra .engine .core import Task
78from .utils import no_win , need_docker , result_submitter , result_no_submitter
89
910
@@ -14,13 +15,19 @@ def test_docker_1_nosubm():
1415 no submitter
1516 """
1617 cmd = "whoami"
17- docky = shell .define (cmd )(environment = Docker (image = "busybox" ))
18- assert docky .environment .image == "busybox"
19- assert docky .environment .tag == "latest"
20- assert isinstance (docky .environment , Docker )
21- assert docky .cmdline == cmd
18+ Docky = shell .define (cmd )
19+ docky = Docky ()
20+ docky_task = Task (
21+ definition = docky ,
22+ name = "docky" ,
23+ submitter = Submitter (environment = Docker (image = "busybox" )),
24+ )
25+ assert docky_task .environment .image == "busybox"
26+ assert docky_task .environment .tag == "latest"
27+ assert isinstance (docky_task .environment , Docker )
28+ assert docky_task .cmdline == cmd
2229
23- res = docky ()
30+ res = docky_task ()
2431 assert res .output .stdout == "root\n "
2532 assert res .output .return_code == 0
2633
@@ -32,14 +39,14 @@ def test_docker_1(plugin):
3239 using submitter
3340 """
3441 cmd = "whoami"
35- docky = shell .define (cmd )(environment = Docker (image = "busybox" ))
42+ Docky = shell .define (cmd )
43+ docky = Docky ()
3644
37- with Submitter (worker = plugin ) as sub :
38- docky ( submitter = sub )
45+ with Submitter (environment = Docker ( image = "busybox" ) ) as sub :
46+ res = sub ( docky )
3947
40- res = docky .result ()
41- assert res .output .stdout == "root\n "
42- assert res .output .return_code == 0
48+ assert res .outputs .stdout == "root\n "
49+ assert res .outputs .return_code == 0
4350
4451
4552@no_win
@@ -50,7 +57,8 @@ def test_docker_2(results_function, plugin):
5057 with and without submitter
5158 """
5259 cmdline = "echo hail pydra"
53- docky = shell .define (cmdline )(environment = Docker (image = "busybox" ))
60+ Docky = shell .define (cmdline )
61+ docky = Docky ()
5462 # cmdline doesn't know anything about docker
5563 assert docky .cmdline == cmdline
5664 res = results_function (docky , plugin )
@@ -68,13 +76,9 @@ def test_docker_2a(results_function, plugin):
6876 cmd_exec = "echo"
6977 cmd_args = ["hail" , "pydra" ]
7078 # separate command into exec + args
71- docky = ShellTask (
72- name = "docky" ,
73- executable = cmd_exec ,
74- args = cmd_args ,
75- environment = Docker (image = "busybox" ),
76- )
77- assert docky .definition .executable == "echo"
79+ Docky = shell .define (" " .join ([cmd_exec ] + cmd_args ))
80+ docky = Docky ()
81+ assert docky .executable == "echo"
7882 assert docky .cmdline == f"{ cmd_exec } { ' ' .join (cmd_args )} "
7983
8084 res = results_function (docky , plugin )
@@ -93,9 +97,9 @@ def test_docker_st_1(results_function, plugin):
9397 splitter = executable
9498 """
9599 cmd = ["pwd" , "whoami" ]
96- docky = ShellTask ( name = "docky" , environment = Docker ( image = "busybox" )). split (
97- " executable" , executable = cmd
98- )
100+ Docky = shell . define ( "placeholder" )
101+ docky = Docky (). split ( executable = cmd )
102+
99103 assert docky .state .splitter == "docky.executable"
100104
101105 res = results_function (docky , plugin )
0 commit comments