Skip to content

Commit

Permalink
Replacing ExecutorError with InvalidResourceSpecificationError in Wor…
Browse files Browse the repository at this point in the history
…kQueue Executor
  • Loading branch information
Harichandra-Prasath committed Oct 3, 2024
1 parent 0e0fe0d commit fd20958
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
11 changes: 6 additions & 5 deletions parsl/executors/workqueue/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from parsl.data_provider.files import File
from parsl.data_provider.staging import Staging
from parsl.errors import OptionalModuleMissing
from parsl.executors.errors import ExecutorError
from parsl.executors.errors import ExecutorError, InvalidResourceSpecificationError
from parsl.executors.status_handling import BlockProviderExecutor
from parsl.executors.workqueue import exec_parsl_function
from parsl.process_loggers import wrap_with_logs
Expand Down Expand Up @@ -419,7 +419,7 @@ def submit(self, func, resource_specification, *args, **kwargs):
message = "Task resource specification only accepts these types of resources: {}".format(
', '.join(acceptable_fields))
logger.error(message)
raise ExecutorError(self, message)
raise InvalidResourceSpecificationError(keys, message)

# this checks that either all of the required resource types are specified, or
# that none of them are: the `required_resource_types` are not actually required,
Expand All @@ -430,9 +430,10 @@ def submit(self, func, resource_specification, *args, **kwargs):
logger.error("Running with `autolabel=False`. In this mode, "
"task resource specification requires "
"three resources to be specified simultaneously: cores, memory, and disk")
raise ExecutorError(self, "Task resource specification requires "
"three resources to be specified simultaneously: cores, memory, and disk. "
"Try setting autolabel=True if you are unsure of the resource usage")
raise InvalidResourceSpecificationError(keys,
"Task resource specification requires "
"three resources to be specified simultaneously: cores, memory, and disk. "
"Try setting autolabel=True if you are unsure of the resource usage")

for k in keys:
if k == 'cores':
Expand Down
16 changes: 9 additions & 7 deletions parsl/tests/test_error_handling/test_resource_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from parsl.app.app import python_app
from parsl.executors import WorkQueueExecutor
from parsl.executors.errors import (
ExecutorError,
InvalidResourceSpecificationError,
UnsupportedFeatureError,
)
from parsl.executors.high_throughput.executor import HighThroughputExecutor
from parsl.executors.threads import ThreadPoolExecutor


@python_app
Expand All @@ -28,11 +28,12 @@ def test_resource(n=2):
try:
fut.result()
except InvalidResourceSpecificationError:
assert isinstance(executor, HighThroughputExecutor)
assert (
isinstance(executor, HighThroughputExecutor) or
isinstance(executor, WorkQueueExecutor) or
isinstance(executor, ThreadPoolExecutor))
except UnsupportedFeatureError:
assert not isinstance(executor, WorkQueueExecutor)
except Exception as e:
assert isinstance(e, ExecutorError)

# Specify resources with wrong types
# 'cpus' is incorrect, should be 'cores'
Expand All @@ -41,8 +42,9 @@ def test_resource(n=2):
try:
fut.result()
except InvalidResourceSpecificationError:
assert isinstance(executor, HighThroughputExecutor)
assert (
isinstance(executor, HighThroughputExecutor) or
isinstance(executor, WorkQueueExecutor) or
isinstance(executor, ThreadPoolExecutor))
except UnsupportedFeatureError:
assert not isinstance(executor, WorkQueueExecutor)
except Exception as e:
assert isinstance(e, ExecutorError)
6 changes: 2 additions & 4 deletions parsl/tests/test_mpi_apps/test_mpi_mode_enabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import parsl
from parsl import Config, bash_app, python_app
from parsl.executors import MPIExecutor
from parsl.executors.high_throughput.mpi_prefix_composer import (
MissingResourceSpecification,
)
from parsl.executors.errors import InvalidResourceSpecificationError
from parsl.launchers import SimpleLauncher
from parsl.providers import LocalProvider

Expand Down Expand Up @@ -185,6 +183,6 @@ def test_simulated_load(rounds: int = 100):
@pytest.mark.local
def test_missing_resource_spec():

with pytest.raises(MissingResourceSpecification):
with pytest.raises(InvalidResourceSpecificationError):
future = mock_app(sleep_dur=0.4)
future.result(timeout=10)

0 comments on commit fd20958

Please sign in to comment.