Skip to content

Commit bcb2aef

Browse files
conditionally quote env vars
1 parent 38327e0 commit bcb2aef

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

deepspeed/launcher/multinode_runner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import shutil
99
import subprocess
1010
import warnings
11+
import re
1112
from shlex import split
1213
from abc import ABC, abstractmethod
1314
from deepspeed.accelerator import get_accelerator
@@ -34,7 +35,10 @@ def get_cmd(self, environment, active_resources):
3435
"""Return the command to execute on node"""
3536

3637
def add_export(self, key, var):
37-
self.exports[key.strip()] = f"\"{var.strip()}\""
38+
var = var.strip()
39+
if re.search(r'[^\w@%+=:,./-]', var):
40+
var = f"\"{var}\""
41+
self.exports[key.strip()] = var
3842

3943
def parse_user_args(self):
4044
return self.args.user_args

0 commit comments

Comments
 (0)