Skip to content

Commit

Permalink
Support ranks=-1
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Jun 30, 2024
1 parent eafc91c commit 6e7baf5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/examples/mpi-execution/mpi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Literal, Optional, Union

import os
import sys

from machinable import Execution
Expand All @@ -23,7 +24,10 @@ def on_compute_default_resources(self, executable):

ranks = executable.config.get("ranks", False)
if ranks not in [None, False]:
resources["-n"] = int(ranks)
if ranks == -1:
ranks = os.environ.get("MPI_RANKS", 0)
if int(ranks) > 0:
resources["-n"] = int(ranks)

return resources

Expand Down

0 comments on commit 6e7baf5

Please sign in to comment.