@@ -176,7 +176,7 @@ def set_mock_group_infos(
176
176
}
177
177
178
178
monkeypatch .setattr (dragon_backend , "_group_infos" , group_infos )
179
- monkeypatch .setattr (dragon_backend , "_allocated_hosts" , {hosts [0 ]: "abc123-1" })
179
+ monkeypatch .setattr (dragon_backend , "_allocated_hosts" , {hosts [0 ]: { "abc123-1" } })
180
180
monkeypatch .setattr (dragon_backend , "_running_steps" , ["abc123-1" ])
181
181
182
182
return group_infos
@@ -221,8 +221,8 @@ def test_run_request(monkeypatch: pytest.MonkeyPatch) -> None:
221
221
assert dragon_backend ._running_steps == [step_id ]
222
222
assert len (dragon_backend ._queued_steps ) == 0
223
223
assert len (dragon_backend .free_hosts ) == 1
224
- assert dragon_backend ._allocated_hosts [dragon_backend .hosts [0 ]] == step_id
225
- assert dragon_backend ._allocated_hosts [dragon_backend .hosts [1 ]] == step_id
224
+ assert step_id in dragon_backend ._allocated_hosts [dragon_backend .hosts [0 ]]
225
+ assert step_id in dragon_backend ._allocated_hosts [dragon_backend .hosts [1 ]]
226
226
227
227
monkeypatch .setattr (
228
228
dragon_backend ._group_infos [step_id ].process_group , "status" , "Running"
@@ -233,8 +233,8 @@ def test_run_request(monkeypatch: pytest.MonkeyPatch) -> None:
233
233
assert dragon_backend ._running_steps == [step_id ]
234
234
assert len (dragon_backend ._queued_steps ) == 0
235
235
assert len (dragon_backend .free_hosts ) == 1
236
- assert dragon_backend ._allocated_hosts [dragon_backend .hosts [0 ]] == step_id
237
- assert dragon_backend ._allocated_hosts [dragon_backend .hosts [1 ]] == step_id
236
+ assert step_id in dragon_backend ._allocated_hosts [dragon_backend .hosts [0 ]]
237
+ assert step_id in dragon_backend ._allocated_hosts [dragon_backend .hosts [1 ]]
238
238
239
239
dragon_backend ._group_infos [step_id ].status = SmartSimStatus .STATUS_CANCELLED
240
240
@@ -316,8 +316,8 @@ def test_run_request_with_policy(monkeypatch: pytest.MonkeyPatch) -> None:
316
316
assert dragon_backend ._running_steps == [step_id ]
317
317
assert len (dragon_backend ._queued_steps ) == 0
318
318
assert len (dragon_backend ._prioritizer .unassigned ()) == 1
319
- assert dragon_backend ._allocated_hosts [dragon_backend .hosts [0 ]] == step_id
320
- assert dragon_backend ._allocated_hosts [dragon_backend .hosts [1 ]] == step_id
319
+ assert step_id in dragon_backend ._allocated_hosts [dragon_backend .hosts [0 ]]
320
+ assert step_id in dragon_backend ._allocated_hosts [dragon_backend .hosts [1 ]]
321
321
322
322
monkeypatch .setattr (
323
323
dragon_backend ._group_infos [step_id ].process_group , "status" , "Running"
@@ -328,8 +328,8 @@ def test_run_request_with_policy(monkeypatch: pytest.MonkeyPatch) -> None:
328
328
assert dragon_backend ._running_steps == [step_id ]
329
329
assert len (dragon_backend ._queued_steps ) == 0
330
330
assert len (dragon_backend ._prioritizer .unassigned ()) == 1
331
- assert dragon_backend ._allocated_hosts [dragon_backend .hosts [0 ]] == step_id
332
- assert dragon_backend ._allocated_hosts [dragon_backend .hosts [1 ]] == step_id
331
+ assert step_id in dragon_backend ._allocated_hosts [dragon_backend .hosts [0 ]]
332
+ assert step_id in dragon_backend ._allocated_hosts [dragon_backend .hosts [1 ]]
333
333
334
334
dragon_backend ._group_infos [step_id ].status = SmartSimStatus .STATUS_CANCELLED
335
335
@@ -728,3 +728,34 @@ def test_can_honor_hosts_unavailable_hosts_ok(monkeypatch: pytest.MonkeyPatch) -
728
728
assert can_honor , error_msg
729
729
# confirm failure message indicates number of nodes requested as cause
730
730
assert error_msg is None , error_msg
731
+
732
+
733
+ def test_can_honor_hosts_1_hosts_requested (monkeypatch : pytest .MonkeyPatch ) -> None :
734
+ """Verify that requesting nodes with invalid names causes number of available
735
+ nodes check to be reduced but still passes if enough valid named nodes are passed"""
736
+ dragon_backend = get_mock_backend (monkeypatch , num_cpus = 8 , num_gpus = 0 )
737
+
738
+ # let's supply 2 valid and 1 invalid hostname
739
+ actual_hosts = list (dragon_backend ._hosts )
740
+ actual_hosts [0 ] = f"x{ actual_hosts [0 ]} "
741
+
742
+ host_list = "," .join (actual_hosts )
743
+
744
+ run_req = DragonRunRequest (
745
+ exe = "sleep" ,
746
+ exe_args = ["5" ],
747
+ path = "/a/fake/path" ,
748
+ nodes = 1 , # <----- requesting 0 nodes - should be ignored
749
+ hostlist = host_list , # <--- two valid names are available
750
+ tasks = 1 ,
751
+ tasks_per_node = 1 ,
752
+ env = {},
753
+ current_env = {},
754
+ pmi_enabled = False ,
755
+ policy = DragonRunPolicy (),
756
+ )
757
+
758
+ can_honor , error_msg = dragon_backend ._can_honor (run_req )
759
+
760
+ # confirm the failure is indicated
761
+ assert can_honor , error_msg
0 commit comments