Skip to content

Commit

Permalink
feat: generic tasks: support startup hooks (#8840)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioga authored Feb 13, 2024
1 parent ca80022 commit b0fa7dc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions master/static/srv/generic-task-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ source /run/determined/task-setup.sh

set -e

STARTUP_HOOK="startup-hook.sh"
export PATH="/run/determined/pythonuserbase/bin:$PATH"

# If HOME is not explicitly set for a container, libcontainer (Docker) will
# try to guess it by reading /etc/password directly, which will not work with
# our libnss_determined plugin (or any user-defined NSS plugin in a container).
# The default is "/", but HOME must be a writable location for distributed
# training, so we try to query the user system for a valid HOME, or default to
# the working directory otherwise.
if [ "$HOME" = "/" ]; then
HOME="$(
set -o pipefail
getent passwd "$(whoami)" | cut -d: -f6
)" || HOME="$PWD"
export HOME
fi

if [ -z "$DET_PYTHON_EXECUTABLE" ]; then
export DET_PYTHON_EXECUTABLE="python3"
fi
Expand All @@ -14,6 +31,10 @@ fi
# to register the proxy with the Determined master.
"$DET_PYTHON_EXECUTABLE" -m determined.exec.prep_container --proxy --download_context_directory

set -x
test -f "${STARTUP_HOOK}" && source "${STARTUP_HOOK}"
set +x

if [ "$#" -eq 1 ]; then
exec /bin/sh -c "$@"
else
Expand Down

0 comments on commit b0fa7dc

Please sign in to comment.