Skip to content

Commit

Permalink
Move the backup/restore of writable job dirs to from command builder …
Browse files Browse the repository at this point in the history
…to job script.

This allows for Pulsar to perform the prepare dirs step but override
for its own paths and differing `working_directory`.
  • Loading branch information
natefoo committed Feb 14, 2025
1 parent 2bf7c7e commit 6d4b345
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/galaxy/jobs/command_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
YIELD_CAPTURED_CODE = 'sh -c "exit $return_code"'
SETUP_GALAXY_FOR_METADATA = """
[ "$GALAXY_VIRTUAL_ENV" = "None" ] && GALAXY_VIRTUAL_ENV="$_GALAXY_VIRTUAL_ENV"; _galaxy_setup_environment True"""
PREPARE_DIRS = """mkdir -p working outputs configs
if [ -d _working ]; then
rm -rf working/ outputs/ configs/; cp -R _working working; cp -R _outputs outputs; cp -R _configs configs
else
cp -R working _working; cp -R outputs _outputs; cp -R configs _configs
fi
cd working"""


def build_command(
Expand Down Expand Up @@ -125,12 +118,9 @@ def build_command(
# Don't need to create a separate tool working directory for Pulsar
# jobs - that is handled by Pulsar.
if create_tool_working_directory:
# usually working will already exist, but it will not for task
# split jobs.

# Copy working and outputs before job submission so that these can be restored on resubmission
# xref https://github.com/galaxyproject/galaxy/issues/3289
commands_builder.prepend_command(PREPARE_DIRS)
# Working (and outputs, configs) are backed up and restored in the job script for both Galaxy and Pulsar jobs,
# but Pulsar automatically changes into the working dir, whereas Galaxy does not.
commands_builder.prepend_command("cd working")

__handle_remote_command_line_building(commands_builder, job_wrapper, for_pulsar=for_pulsar)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export TEMP
export TMPDIR

GALAXY_PYTHON=`command -v python`
$prepare_dirs_statement
cd $working_directory
$memory_statement
$instrument_pre_commands
Expand Down
11 changes: 11 additions & 0 deletions lib/galaxy/jobs/runners/util/job_script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
fi
"""

# Copy working, outputs, and configs before tool execution so that these can be restored on job resubmission
# xref https://github.com/galaxyproject/galaxy/issues/3289
PREPARE_DIRS = """mkdir -p working outputs configs
if [ -d _working ]; then
rm -rf working/ outputs/ configs/; cp -R _working working; cp -R _outputs outputs; cp -R _configs configs
else
cp -R working _working; cp -R outputs _outputs; cp -R configs _configs
fi
"""

INTEGRITY_SYNC_COMMAND = "/bin/sync"
DEFAULT_INTEGRITY_CHECK = True
DEFAULT_INTEGRITY_COUNT = 35
Expand All @@ -58,6 +68,7 @@
"shell": DEFAULT_SHELL,
"preserve_python_environment": True,
"tmp_dir_creation_statement": '""',
"prepare_dirs_statement": PREPARE_DIRS,
}


Expand Down

0 comments on commit 6d4b345

Please sign in to comment.