Skip to content

Commit 29f960f

Browse files
authored
Add resource specification fields to HTEX (#3638)
Adds the parameter 'priority' as a valid entry in the resource spec dict. Necessary for changing the pending_task_queue to a different structure than queue.Queue. Also passes resource spec to the interchange.
1 parent af42414 commit 29f960f

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

parsl/executors/high_throughput/executor.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,17 @@ def worker_logdir(self):
346346
return self.logdir
347347

348348
def validate_resource_spec(self, resource_specification: dict):
349-
"""HTEX does not support *any* resource_specification options and
350-
will raise InvalidResourceSpecification is any are passed to it"""
349+
"""HTEX supports the following *Optional* resource specifications:
350+
priority: lower value is higher priority"""
351351
if resource_specification:
352-
raise InvalidResourceSpecification(
353-
set(resource_specification.keys()),
354-
("HTEX does not support the supplied resource_specifications. "
355-
"For MPI applications consider using the MPIExecutor. "
356-
"For specifications for core count/memory/walltime, consider using WorkQueueExecutor.")
357-
)
352+
acceptable_fields = {'priority'}
353+
keys = set(resource_specification.keys())
354+
invalid_keys = keys - acceptable_fields
355+
if invalid_keys:
356+
message = "Task resource specification only accepts these types of resources: {}".format(
357+
', '.join(acceptable_fields))
358+
logger.error(message)
359+
raise InvalidResourceSpecification(set(invalid_keys), message)
358360
return
359361

360362
def initialize_scaling(self):
@@ -662,7 +664,7 @@ def submit(self, func, resource_specification, *args, **kwargs):
662664
except TypeError:
663665
raise SerializationError(func.__name__)
664666

665-
msg = {"task_id": task_id, "buffer": fn_buf}
667+
msg = {"task_id": task_id, "resource_spec": resource_specification, "buffer": fn_buf}
666668

667669
# Post task to the outgoing queue
668670
self.outgoing_q.put(msg)

parsl/tests/test_htex/test_resource_spec_validation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ def test_resource_spec_validation():
3030
assert ret_val is None
3131

3232

33+
@pytest.mark.local
34+
def test_resource_spec_validation_one_key():
35+
htex = HighThroughputExecutor()
36+
ret_val = htex.validate_resource_spec({"priority": 2})
37+
assert ret_val is None
38+
39+
3340
@pytest.mark.local
3441
def test_resource_spec_validation_bad_keys():
3542
htex = HighThroughputExecutor()

0 commit comments

Comments
 (0)