10
10
from mlcube .shell import Shell
11
11
12
12
_HAVE_DOCKER : bool = Shell .run (["docker" , "--version" ], on_error = "ignore" ) == 0
13
+ _HAVE_PODMAN : bool = Shell .run (["podman" , "--version" ], on_error = "ignore" ) == 0
14
+
13
15
14
16
_MLCUBE_DEFAULT_ENTRY_POINT = """
15
17
docker:
@@ -54,13 +56,13 @@ def setUp(self) -> None:
54
56
def tearDown (self ) -> None :
55
57
Shell .sync_workspace = self .sync_workspace
56
58
57
- @unittest .skipUnless (_HAVE_DOCKER , reason = "No docker available." )
58
- def test_mlcube_default_entrypoints (self ):
59
+ def default_entry_points (self , executable : str ) -> None :
59
60
with patch ("io.open" , mock_open (read_data = _MLCUBE_DEFAULT_ENTRY_POINT )):
60
61
mlcube : DictConfig = MLCubeConfig .create_mlcube_config (
61
62
"/some/path/to/mlcube.yaml" ,
62
63
runner_config = Config .DEFAULT ,
63
64
runner_cls = DockerRun ,
65
+ mlcube_cli_args = OmegaConf .create ({"docker" : {"docker" : executable }}),
64
66
)
65
67
self .assertEqual (mlcube .runner .image , "ubuntu:18.04" )
66
68
self .assertDictEqual (
@@ -76,13 +78,13 @@ def test_mlcube_default_entrypoints(self):
76
78
DockerRun (mlcube , task = "ls" ).run ()
77
79
DockerRun (mlcube , task = "pwd" ).run ()
78
80
79
- @unittest .skipUnless (_HAVE_DOCKER , reason = "No docker available." )
80
- def test_mlcube_custom_entrypoints (self ):
81
+ def custom_entry_points (self , executable : str ) -> None :
81
82
with patch ("io.open" , mock_open (read_data = _MLCUBE_CUSTOM_ENTRY_POINTS )):
82
83
mlcube : DictConfig = MLCubeConfig .create_mlcube_config (
83
84
"/some/path/to/mlcube.yaml" ,
84
85
runner_config = Config .DEFAULT ,
85
86
runner_cls = DockerRun ,
87
+ mlcube_cli_args = OmegaConf .create ({"docker" : {"docker" : executable }}),
86
88
)
87
89
self .assertEqual (mlcube .runner .image , "ubuntu:18.04" )
88
90
self .assertDictEqual (
@@ -100,3 +102,19 @@ def test_mlcube_custom_entrypoints(self):
100
102
self ._check_inspect_output (DockerRun (mlcube , task = None ).inspect ())
101
103
DockerRun (mlcube , task = "ls" ).run ()
102
104
DockerRun (mlcube , task = "free" ).run ()
105
+
106
+ @unittest .skipUnless (_HAVE_PODMAN , reason = "No podman available." )
107
+ def test_default_entrypoints_with_podman (self ):
108
+ self .default_entry_points ("podman" )
109
+
110
+ @unittest .skipUnless (_HAVE_DOCKER , reason = "No docker available." )
111
+ def test_default_entrypoints_with_docker (self ):
112
+ self .default_entry_points ("docker" )
113
+
114
+ @unittest .skipUnless (_HAVE_PODMAN , reason = "No podman available." )
115
+ def test_custom_entrypoints_with_podman (self ):
116
+ self .custom_entry_points ("podman" )
117
+
118
+ @unittest .skipUnless (_HAVE_DOCKER , reason = "No docker available." )
119
+ def test_custom_entrypoints_with_docker (self ):
120
+ self .custom_entry_points ("docker" )
0 commit comments