How To Add Runtime Dependencies To An AICenter/Document Understanding Airgapped Model?

Custom ML Package Failing to deploy.

For Airgapped models, provide the dependencies required in the model as they will not be able to download them from the internet at runtime.

WARNING: Built wheel for uipath-core is invalid: Metadata 1.2 mandates PEP 440 version, but 'v21.10.1.SF' is not.

Failed to build uipath-core

DEPRECATION: uipath-core was installed using the legacy 'setup.py install' method, because a wheel could not be built for it. A possible replacement is to fix the wheel build issue reported above. Find discussion regarding this at https://github.com/pypa/pip/issues/8368.

WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/pillow/

WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/pillow/

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/pillow/

ERROR: Could not find a version that satisfies the requirement pillow (from versions: none)

ERROR: No matching distribution found for pillow

Resolution: In order to add dependencies to an airgapped model, do the following,

Add the dependencies to a folder with in model zip.

  1. pip download -c constraints.txt -r requirements.txt -d <folder inside model zip>. They may have to do this twice and resolve any conflicts if requirements.txt and train_requirements.txt differ

  1. Change their requirements.txt/train-requirements.txt and add first line as
  • --no-index --find-links <wheel download folder inside model zip>

An example airgapped model is below:

MODEL_NAME=$1

MODEL_URL=$2

echo "starting execution"

function validate_last_command_executed_successfully() {

if [ $? -ne 0 ]; then

echo "$(date) $1 !!!!!"

exit 1

fi

}

echo "cleanup"

# Clean older ones if present

rm -rf "$MODEL_NAME"/

rm -rf "$MODEL_NAME".zip

validate_last_command_executed_successfully "Failed to delete old files and folders"

echo "starting model download"

wget -O "$MODEL_NAME".zip "$MODEL_URL"

validate_last_command_executed_successfully "Failed to download file"

echo "unpack"

unzip "$MODEL_NAME".zip

validate_last_command_executed_successfully "Failed to unzip file"

echo "remove zip"

rm -rf "$MODEL_NAME".zip

validate_last_command_executed_successfully "Failed to delete zip file"

echo "create installation folder in directory"

mkdir -p "$MODEL_NAME"/onpremdeps

validate_last_command_executed_successfully "Failed to create onpremdeps directory"

echo "download files using pip"

if [ -f "$MODEL_NAME"/"train_requirements.txt" ]; then

pip download -r "$MODEL_NAME"/train_requirements.txt -d "$MODEL_NAME"/onpremdeps

sed -i '1 i\--find-links onpremdeps' "$MODEL_NAME"/train_requirements.txt

sed -i '1 i\--no-index' "$MODEL_NAME"/train_requirements.txt

fi

if [ -f "$MODEL_NAME"/"requirements.txt" ]; then

pip download -r "$MODEL_NAME"/requirements.txt -d "$MODEL_NAME"/onpremdeps

sed -i '1 i\--find-links onpremdeps' "$MODEL_NAME"/requirements.txt

sed -i '1 i\--no-index' "$MODEL_NAME"/requirements.txt

fi

validate_last_command_executed_successfully "Failed to download pip packages"

echo "pack"

zip -r "$MODEL_NAME".zip "$MODEL_NAME"

validate_last_command_executed_successfully "Failed to zip file"