@@ -71,7 +71,7 @@ def test_submit_dryrun(self) -> None:
71
71
app = _test_app ()
72
72
with patch ("torchx.schedulers.docker_scheduler.make_unique" ) as make_unique_ctx :
73
73
make_unique_ctx .return_value = "app_name_42"
74
- info = self .scheduler ._submit_dryrun (app , cfg = {})
74
+ info = self .scheduler .submit_dryrun (app , cfg = {})
75
75
76
76
want = DockerJob (
77
77
"app_name_42" ,
@@ -109,6 +109,7 @@ def test_submit_dryrun(self) -> None:
109
109
},
110
110
"mem_limit" : "3000m" ,
111
111
"shm_size" : "3000m" ,
112
+ "privileged" : False ,
112
113
"name" : "app_name_42-trainer-0" ,
113
114
"hostname" : "app_name_42-trainer-0" ,
114
115
"nano_cpus" : int (2e9 ),
@@ -137,7 +138,7 @@ def test_volume_mounts(self) -> None:
137
138
specs .VolumeMount (src = "name" , dst_path = "/tmp" , read_only = True ),
138
139
]
139
140
140
- info = self .scheduler ._submit_dryrun (app , cfg = {})
141
+ info = self .scheduler .submit_dryrun (app , cfg = {})
141
142
want = [
142
143
Mount (
143
144
target = "/tmp" ,
@@ -154,15 +155,15 @@ def test_device_mounts(self) -> None:
154
155
specs .DeviceMount (src_path = "foo" , dst_path = "bar" ),
155
156
]
156
157
157
- info = self .scheduler ._submit_dryrun (app , cfg = {})
158
+ info = self .scheduler .submit_dryrun (app , cfg = {})
158
159
self .assertEqual (info .request .containers [0 ].kwargs ["devices" ], ["foo:bar:rwm" ])
159
160
160
161
def test_resource_devices (self ) -> None :
161
162
app = _test_app ()
162
163
app .roles [0 ].mounts = []
163
164
app .roles [0 ].resource .devices = {"vpc.amazonaws.com/efa" : 1 }
164
165
165
- info = self .scheduler ._submit_dryrun (app , cfg = {})
166
+ info = self .scheduler .submit_dryrun (app , cfg = {})
166
167
self .assertEqual (
167
168
info .request .containers [0 ].kwargs ["devices" ],
168
169
["/dev/infiniband/uverbs0:/dev/infiniband/uverbs0:rwm" ],
@@ -174,7 +175,7 @@ def test_copy_env(self) -> None:
174
175
cfg = DockerOpts ({"copy_env" : ["FOO_*" , "BAR_*" ]})
175
176
with patch ("torchx.schedulers.docker_scheduler.make_unique" ) as make_unique_ctx :
176
177
make_unique_ctx .return_value = "app_name_42"
177
- info = self .scheduler ._submit_dryrun (app , cfg )
178
+ info = self .scheduler .submit_dryrun (app , cfg )
178
179
self .assertEqual (
179
180
info .request .containers [0 ].kwargs ["environment" ],
180
181
{
@@ -190,7 +191,7 @@ def test_env(self) -> None:
190
191
cfg = DockerOpts ({"env" : {"FOO_1" : "BAR_1" }})
191
192
with patch ("torchx.schedulers.docker_scheduler.make_unique" ) as make_unique_ctx :
192
193
make_unique_ctx .return_value = "app_name_42"
193
- info = self .scheduler ._submit_dryrun (app , cfg )
194
+ info = self .scheduler .submit_dryrun (app , cfg )
194
195
self .assertEqual (
195
196
info .request .containers [0 ].kwargs ["environment" ],
196
197
{
@@ -200,13 +201,21 @@ def test_env(self) -> None:
200
201
},
201
202
)
202
203
204
+ def test_privileged (self ) -> None :
205
+ app = _test_app ()
206
+ cfg = DockerOpts ({"privileged" : True })
207
+ with patch ("torchx.schedulers.docker_scheduler.make_unique" ) as make_unique_ctx :
208
+ make_unique_ctx .return_value = "app_name_42"
209
+ info = self .scheduler .submit_dryrun (app , cfg )
210
+ self .assertTrue (info .request .containers [0 ].kwargs ["privileged" ])
211
+
203
212
def test_long_hostname (self ) -> None :
204
213
app = _test_app ()
205
214
for role in app .roles :
206
215
role .name = "ethology_explore_magic_calliope_divisive_whirl_dealt_lotus_oncology_facet_deerskin_blum_elective_spill_trammel_trainer"
207
216
with patch ("torchx.schedulers.docker_scheduler.make_unique" ) as make_unique_ctx :
208
217
make_unique_ctx .return_value = "ethology_explore_magic_calliope_divisive_whirl_dealt_lotus_oncology_facet_deerskin_blum_elective_spill_trammel_12345"
209
- info = self .scheduler ._submit_dryrun (app , DockerOpts ())
218
+ info = self .scheduler .submit_dryrun (app , DockerOpts ())
210
219
for container in info .request .containers :
211
220
assert "name" in container .kwargs
212
221
name = container .kwargs ["name" ]
0 commit comments