Skip to content

Commit

Permalink
BUG Only update LUTE_ vars
Browse files Browse the repository at this point in the history
  • Loading branch information
gadorlhiac committed Aug 8, 2024
1 parent 6337d82 commit 94bc617
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/tutorial/new_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ class RunTask(Task): # Inherit from Task

#### Using MPI for your `Task`

In the case your `Task` is written to use `MPI` a slight modification to the template above is needed. Specifically, an additional keyword argument should be passed to the base class initializer: `use_mpi=True`. This tells the base class to adjust signalling/communication behaviour appropriately for a multi-rank MPI program. Doing this prevents tricky-to-track-dow problems due to ranks starting, completing and sending messages at different times. The rest of your code can, as before, be written as you see fit. The use of this keyword argument will also synchronize the start of all ranks and wait until all ranks have finished to exit.
In the case your `Task` is written to use `MPI` a slight modification to the template above is needed. Specifically, an additional keyword argument should be passed to the base class initializer: `use_mpi=True`. This tells the base class to adjust signalling/communication behaviour appropriately for a multi-rank MPI program. Doing this prevents tricky-to-track-down problems due to ranks starting, completing and sending messages at different times. The rest of your code can, as before, be written as you see fit. The use of this keyword argument will also synchronize the start of all ranks and wait until all ranks have finished to exit.

```py
"""Task which needs to run with MPI"""
Expand Down
5 changes: 3 additions & 2 deletions lute/execution/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,9 @@ def _pre_task(self) -> None:
# Not great, but experience shows we need a bit of time to setup
# network.
time.sleep(0.1)
# Propagate any env vars setup by Communicators
self._analysis_desc.task_env.update(os.environ)
# Propagate any env vars setup by Communicators - only update LUTE_ vars
tmp: Dict[str, str] = {key: os.environ[key] for key in os.environ if "LUTE_" in key}
self._analysis_desc.task_env.update(tmp)

def _submit_task(self, cmd: str) -> subprocess.Popen:
proc: subprocess.Popen = subprocess.Popen(
Expand Down

0 comments on commit 94bc617

Please sign in to comment.