Skip to content

Commit

Permalink
swancustomenvironments: Better prevention of errors when install requ…
Browse files Browse the repository at this point in the history
…irements

Prevents UV errors like `No solution found when resolving dependencies:`
  • Loading branch information
rodrigo-sobral authored and etejedor committed Dec 9, 2024
1 parent 8fbd6e4 commit f7e254e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ if [ "${RESOLVED_REQ}" = true ]; then
# Use the same pip configuration as the Acc-Py default pip
ACCPY_PIP_CONF="-i $(pip config get global.index-url) --allow-insecure-host $(pip config get global.trusted-host)"
uv pip install ${ACCPY_PIP_CONF} -r "${REQ_PATH}" 2>&1
if [ $? -ne 0 ]; then
return 1
fi
# Enforce installation of our version of ipykernel and its dependencies
uv pip install ${ACCPY_PIP_CONF} ${IPYKERNEL} 2>&1
else
pip install -r "${REQ_PATH}" 2>&1
if [ $? -ne 0 ]; then
return 1
fi
# Enforce installation of our version of ipykernel and its dependencies
pip install ${IPYKERNEL} 2>&1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Create the environment, install packages and the same ipykernel that the Jupyter server uses
mamba create -p ${ENV_PATH} --file ${REQ_PATH} ${IPYKERNEL} -y
if [ $? -ne 0 ]; then
exit 1
return 1
fi

# Activate the environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ eval "${ACTIVATE_ENV_CMD}"
_log "Installing packages from ${REQ_PATH}..."
if [ "${RESOLVED_REQ}" = true ]; then
uv pip install -r "${REQ_PATH}" 2>&1
if [ $? -ne 0 ]; then
return 1
fi
# Enforce installation of our version of ipykernel and its dependencies
uv pip install ${IPYKERNEL} 2>&1
else
pip install -r "${REQ_PATH}" 2>&1
if [ $? -ne 0 ]; then
return 1
fi
# Enforce installation of our version of ipykernel and its dependencies
pip install ${IPYKERNEL} 2>&1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ _log "Creating environment ${ENV_NAME} using ${BUILDER}${BUILDER_VERSION:+ (${BU
# To prevent builders (e.g. mamba) from caching files on EOS, which slows down the creation of the environment,
# configure HOME to be the user's local directory
HOME=/home/$USER source "${BUILDER_PATH}"
if [ $? -ne 0 ]; then
_log "ERROR: Failed to create the environment." && exit 1
fi

# Install environment kernel.
# Setting JUPYTER_PATH prevents ipykernel installation from complaining about non-found kernelspec
Expand Down

0 comments on commit f7e254e

Please sign in to comment.