Skip to content

Commit 4294a4d

Browse files
authored
Merge pull request #1650 from ax3l/fix-app-check-container
Fix App Check: Container Path
2 parents d8c05c7 + 0c9ed6f commit 4294a4d

3 files changed

Lines changed: 31 additions & 5 deletions

File tree

libensemble/executors/executor.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,16 @@ def set_worker_info(self, comm=None, workerid=None) -> None:
673673
self.workerID = workerid
674674
self.comm = comm
675675

676-
def _check_app_exists(self, full_path: str) -> None:
676+
def _check_app_exists(self, app: Application) -> None:
677677
"""Allows submit function to check if app exists and error if not"""
678-
if not os.path.isfile(full_path):
679-
raise ExecutorException(f"Application does not exist {full_path}")
678+
if app.precedent:
679+
# Could be a container call in precedent. In that case,
680+
# the executable is not available on the host system and
681+
# we just forward what the user provided.
682+
return
683+
684+
if not os.path.isfile(app.full_path):
685+
raise ExecutorException(f"Application does not exist {app.full_path}")
680686

681687
def submit(
682688
self,
@@ -745,7 +751,7 @@ def submit(
745751
task = Task(app, app_args, default_workdir, stdout, stderr, self.workerID, dry_run)
746752

747753
if not dry_run:
748-
self._check_app_exists(task.app.full_path)
754+
self._check_app_exists(task.app)
749755

750756
runline = task.app.app_cmd.split()
751757
if task.app_args is not None:

libensemble/executors/mpi_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def submit(
317317
task = Task(app, app_args, default_workdir, stdout, stderr, self.workerID, dry_run)
318318

319319
if not dry_run:
320-
self._check_app_exists(task.app.full_path)
320+
self._check_app_exists(task.app)
321321

322322
if stage_inout is not None:
323323
logger.warning("stage_inout option ignored in this " "executor - runs in-place")

libensemble/tests/unit_tests/test_executor.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,25 @@ def test_non_existent_app_mpi():
936936
assert 0
937937

938938

939+
def test_non_existent_app_precedent():
940+
"""Tests exception on non-existent app is not thrown if precedent is set.
941+
This is common when running apps in containers, where the executable is not
942+
check-able from the host system."""
943+
from libensemble.executors.executor import Executor
944+
945+
print(f"\nTest: {sys._getframe().f_code.co_name}\n")
946+
947+
exctr = Executor()
948+
949+
# Can register a non-existent app in case created as part of workflow.
950+
exctr.register_app(full_path=non_existent_app, app_name="nonexist")
951+
952+
w_exctr = Executor.executor # simulate on worker
953+
954+
# all should be ok
955+
w_exctr.submit(app_name="nonexist", dry_run=True)
956+
957+
939958
def test_man_signal_unrec_tag():
940959
print(f"\nTest: {sys._getframe().f_code.co_name}\n")
941960

@@ -990,5 +1009,6 @@ def test_man_signal_unrec_tag():
9901009
test_dry_run()
9911010
test_non_existent_app()
9921011
test_non_existent_app_mpi()
1012+
test_non_existent_app_precedent()
9931013
test_man_signal_unrec_tag()
9941014
teardown_module(__file__)

0 commit comments

Comments
 (0)