Skip to content
Merged
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
3 changes: 2 additions & 1 deletion jax/_src/clusters/slurm_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class SlurmCluster(clusters.ClusterEnv):

@classmethod
def is_env_present(cls) -> bool:
return _JOBID_PARAM in os.environ
return all(var in os.environ for var in
(_JOBID_PARAM, _NODE_LIST, _PROCESS_COUNT, _PROCESS_ID, _LOCAL_PROCESS_ID))
Comment on lines +33 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Checking for the existence of all these environment variables might be too strict. Consider whether the application can gracefully handle the absence of some of these variables, or provide a mechanism to configure which variables are required. If some variables are optional, the all() check should be adjusted accordingly to avoid preventing the cluster from being detected when it could still function.

For example, if _NODE_LIST is sometimes optional, you might want to remove it from the all() check, or have a separate check for it.

Suggested change
return all(var in os.environ for var in
(_JOBID_PARAM, _NODE_LIST, _PROCESS_COUNT, _PROCESS_ID, _LOCAL_PROCESS_ID))
return _JOBID_PARAM in os.environ and all(
var in os.environ for var in (_NODE_LIST, _PROCESS_COUNT, _PROCESS_ID, _LOCAL_PROCESS_ID)
)


@classmethod
def get_coordinator_address(cls, timeout_secs: int | None) -> str:
Expand Down