-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the BlockIdManagerSelector to the list of available manager selectors. This selector returns a sorted list of managers by their block id, from greatest (newest) to least (oldest).
- Loading branch information
1 parent
2a6bd18
commit ac62e04
Showing
5 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
from parsl.executors.high_throughput.manager_record import ManagerRecord | ||
from parsl.executors.high_throughput.manager_selector import BlockIdManagerSelector | ||
|
||
|
||
@pytest.mark.local | ||
def test_sort_managers(): | ||
ready_managers = { | ||
b'manager1': {'block_id': 1}, | ||
b'manager2': {'block_id': None}, | ||
b'manager3': {'block_id': 3}, | ||
b'manager4': {'block_id': 2} | ||
} | ||
|
||
manager_list = {b'manager1', b'manager2', b'manager3', b'manager4'} | ||
expected_sorted_list = [b'manager2', b'manager1', b'manager4', b'manager3'] | ||
manager_selector = BlockIdManagerSelector() | ||
sorted_managers = manager_selector.sort_managers(ready_managers, manager_list) | ||
assert sorted_managers == expected_sorted_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import time | ||
|
||
import pytest | ||
|
||
import parsl | ||
from parsl.app.app import bash_app, python_app | ||
from parsl.channels import LocalChannel | ||
from parsl.config import Config | ||
from parsl.executors import HighThroughputExecutor | ||
from parsl.executors.high_throughput.manager_selector import ( | ||
BlockIdManagerSelector, | ||
ManagerSelector, | ||
) | ||
from parsl.launchers import WrappedLauncher | ||
from parsl.providers import LocalProvider | ||
from parsl.usage_tracking.levels import LEVEL_1 | ||
|
||
BLOCK_COUNT = 2 | ||
|
||
|
||
@parsl.python_app | ||
def get_worker_pid(): | ||
import os | ||
return os.environ.get('PARSL_WORKER_BLOCK_ID') | ||
|
||
|
||
@pytest.mark.local | ||
def test_block_id_selection(try_assert): | ||
htex = HighThroughputExecutor( | ||
label="htex_local", | ||
max_workers_per_node=1, | ||
manager_selector=BlockIdManagerSelector(), | ||
provider=LocalProvider( | ||
channel=LocalChannel(), | ||
init_blocks=BLOCK_COUNT, | ||
max_blocks=BLOCK_COUNT, | ||
min_blocks=BLOCK_COUNT, | ||
), | ||
) | ||
|
||
config = Config( | ||
executors=[htex], | ||
usage_tracking=LEVEL_1, | ||
) | ||
|
||
with parsl.load(config): | ||
blockids = [] | ||
try_assert(lambda: len(htex.connected_managers()) == BLOCK_COUNT, timeout_ms=20000) | ||
for i in range(10): | ||
future = get_worker_pid() | ||
blockids.append(future.result()) | ||
|
||
assert all(blockid == "1" for blockid in blockids) |