Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rqd] Feature: RQD use host env vars #1324

5 changes: 5 additions & 0 deletions rqd/rqd/rqconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
# Use the PATH environment variable from the RQD host.
RQD_USE_PATH_ENV_VAR = False

# Use the environment variables from the RQD host.
RQD_USE_HOST_ENV_VARS = False

RQD_BECOME_JOB_USER = True
RQD_CREATE_USER_IF_NOT_EXISTS = True
RQD_TAGS = ''
Expand Down Expand Up @@ -184,6 +187,8 @@
RQD_USE_IPV6_AS_HOSTNAME = config.getboolean(__section, "RQD_USE_IPV6_AS_HOSTNAME")
if config.has_option(__section, "RQD_USE_PATH_ENV_VAR"):
RQD_USE_PATH_ENV_VAR = config.getboolean(__section, "RQD_USE_PATH_ENV_VAR")
if config.has_option(__section, "RQD_USE_HOST_ENV_VARS"):
RQD_USE_HOST_ENV_VARS = config.getboolean(__section, "RQD_USE_HOST_ENV_VARS")
if config.has_option(__section, "RQD_BECOME_JOB_USER"):
RQD_BECOME_JOB_USER = config.getboolean(__section, "RQD_BECOME_JOB_USER")
if config.has_option(__section, "RQD_TAGS"):
Expand Down
11 changes: 10 additions & 1 deletion rqd/rqd/rqcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,22 @@ def __createEnvVariables(self):
if 'GPU_LIST' in self.runFrame.attributes:
self.frameEnv['CUE_GPU_CORES'] = self.runFrame.attributes['GPU_LIST']

# Add host environment variables
if rqd.rqconstants.RQD_USE_HOST_ENV_VARS:
for key, value in os.environ.items():
if "PATH" in key and key in self.frameEnv:
self.frameEnv[key] += os.pathsep + value

self.frameEnv[key] = value


def _createCommandFile(self, command):
"""Creates a file that subprocess. Popen then executes.
@type command: string
@param command: The command specified in the runFrame request
@rtype: string
@return: Command file location"""
# TODO: this should use tempfile to create the files and clean them up afterwards
# TODO: this should use tempfile to create the files and clean them up afterwards
try:
if platform.system() == "Windows":
rqd_tmp_dir = os.path.join(tempfile.gettempdir(), 'rqd')
Expand Down