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

DM-39885: Fully substitute symbolic environment variables in symbolic filenames #17

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/DM-39885.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Resolve nested symbolic names correctly
17 changes: 15 additions & 2 deletions python/lsst/ctrl/bps/parsl/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,21 @@ def evaluate_command_line(self, command: str) -> str:
Command ready for execution on a worker.
"""
command = command.format(**self.generic.cmdvals) # BPS variables
command = re.sub(_env_regex, r"${\g<1>}", command) # Environment variables
command = re.sub(_file_regex, lambda match: self.file_paths[match.group(1)], command) # Files

# Make sure *all* symbolic names are resolved.
#
# In general, actual values for some symbolic names may contain other
# symbolic names. As a result, more than one iteration may be required
# to resolve all symbolic names. For example, an actual value for
# a filename may contain a symbolic name for an environment variable.
prev_command = command
while True:
command = re.sub(_env_regex, r"${\g<1>}", command) # Environment variables
command = re.sub(_file_regex, lambda match: self.file_paths[match.group(1)], command) # Files
if prev_command == command:
break
prev_command = command

return command

def get_resources(self) -> dict[str, Any]:
Expand Down