Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raising UnsupportedFeatureError instead of InvalidResourceSpecification on passing resource_specification to HTEX #3618

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions parsl/executors/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ def __init__(self, executor, exception):
class UnsupportedFeatureError(ExecutorError):
"""Error raised when attemping to use unsupported feature in an Executor"""

def __init__(self, feature, current_executor, target_executor):
def __init__(self, feature, current_executor, suggestion):
self.feature = feature
self.current_executor = current_executor
self.target_executor = target_executor
self.suggestion = suggestion

def __str__(self):
if self.target_executor:
if self.suggestion:
return "The {} feature is unsupported in {}. \
Please checkout {} for this feature".format(self.feature,
self.current_executor,
self.target_executor)
Suggestion: \
{}".format(self.feature,
self.current_executor,
self.target_executor)
else:
return "The {} feature is unsupported in {}.".format(self.feature,
self.current_executor)
Expand Down
18 changes: 7 additions & 11 deletions parsl/executors/high_throughput/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
from parsl.addresses import get_all_addresses
from parsl.app.errors import RemoteExceptionWrapper
from parsl.data_provider.staging import Staging
from parsl.executors.errors import BadMessage, ScalingFailed
from parsl.executors.errors import BadMessage, ScalingFailed, UnsupportedFeatureError
from parsl.executors.high_throughput import zmq_pipes
from parsl.executors.high_throughput.errors import CommandClientTimeoutError
from parsl.executors.high_throughput.manager_selector import (
ManagerSelector,
RandomManagerSelector,
)
from parsl.executors.high_throughput.mpi_prefix_composer import (
InvalidResourceSpecification,
)
from parsl.executors.status_handling import BlockProviderExecutor
from parsl.jobs.states import TERMINAL_STATES, JobState, JobStatus
from parsl.process_loggers import wrap_with_logs
Expand Down Expand Up @@ -341,14 +338,13 @@ def worker_logdir(self):

def validate_resource_spec(self, resource_specification: dict):
"""HTEX does not support *any* resource_specification options and
will raise InvalidResourceSpecification is any are passed to it"""
will raise UnsupportedFeatureError if any are passed to it"""
if resource_specification:
raise InvalidResourceSpecification(
set(resource_specification.keys()),
("HTEX does not support the supplied resource_specifications."
"For MPI applications consider using the MPIExecutor. "
"For specifications for core count/memory/walltime, consider using WorkQueueExecutor. ")
)
raise UnsupportedFeatureError(
"resource specification",
"HTEX",
"For MPI applications consider using the MPIExecutor. "
"For specifications for core count/memory/walltime, consider using WorkQueueExecutor.")
return

def initialize_scaling(self):
Expand Down
10 changes: 3 additions & 7 deletions parsl/tests/test_error_handling/test_resource_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from parsl.executors import WorkQueueExecutor
from parsl.executors.errors import ExecutorError, UnsupportedFeatureError
from parsl.executors.high_throughput.executor import HighThroughputExecutor
from parsl.executors.high_throughput.mpi_prefix_composer import (
InvalidResourceSpecification,
)
from parsl.executors.threads import ThreadPoolExecutor


@python_app
Expand All @@ -26,9 +24,8 @@ def test_resource(n=2):
fut = double(n, parsl_resource_specification=spec)
try:
fut.result()
except InvalidResourceSpecification:
assert isinstance(executor, HighThroughputExecutor)
except UnsupportedFeatureError:
assert isinstance(executor, HighThroughputExecutor) or isinstance(executor, ThreadPoolExecutor)
assert not isinstance(executor, WorkQueueExecutor)
except Exception as e:
assert isinstance(e, ExecutorError)
Expand All @@ -39,9 +36,8 @@ def test_resource(n=2):
fut = double(n, parsl_resource_specification=spec)
try:
fut.result()
except InvalidResourceSpecification:
assert isinstance(executor, HighThroughputExecutor)
except UnsupportedFeatureError:
assert isinstance(executor, HighThroughputExecutor) or isinstance(executor, ThreadPoolExecutor)
assert not isinstance(executor, WorkQueueExecutor)
except Exception as e:
assert isinstance(e, ExecutorError)
6 changes: 2 additions & 4 deletions parsl/tests/test_htex/test_resource_spec_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import pytest

from parsl.executors import HighThroughputExecutor
from parsl.executors.high_throughput.mpi_prefix_composer import (
InvalidResourceSpecification,
)
from parsl.executors.errors import UnsupportedFeatureError


def double(x):
Expand Down Expand Up @@ -36,5 +34,5 @@ def test_resource_spec_validation():
def test_resource_spec_validation_bad_keys():
htex = HighThroughputExecutor()

with pytest.raises(InvalidResourceSpecification):
with pytest.raises(UnsupportedFeatureError):
htex.validate_resource_spec({"num_nodes": 2})
3 changes: 2 additions & 1 deletion parsl/tests/test_mpi_apps/test_resource_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest

from parsl.app.app import python_app
from parsl.executors.errors import UnsupportedFeatureError
from parsl.executors.high_throughput.executor import HighThroughputExecutor
from parsl.executors.high_throughput.mpi_executor import MPIExecutor
from parsl.executors.high_throughput.mpi_prefix_composer import (
Expand Down Expand Up @@ -137,5 +138,5 @@ def test_mpi_resource_spec_passed_to_htex(resource_spec: dict):
htex = HighThroughputExecutor()
htex.outgoing_q = mock.Mock(spec=queue.Queue)

with pytest.raises(InvalidResourceSpecification):
with pytest.raises(UnsupportedFeatureError):
htex.validate_resource_spec(resource_spec)
Loading