From ba187d67385354a35202463a730d5b78d4d9d37e Mon Sep 17 00:00:00 2001 From: Yong Zheng Date: Thu, 20 Mar 2025 03:56:25 -0500 Subject: [PATCH] Add CLI dependency update option --- polaris | 30 +++++++++++++++++++++++++----- regtests/polaris-reg-test | 30 +++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/polaris b/polaris index 4200e5b731..ebf018ee2f 100755 --- a/polaris +++ b/polaris @@ -19,17 +19,37 @@ # SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -if [ ! -d ${SCRIPT_DIR}/polaris-venv ]; then - echo "Performing first-time setup for the Python client..." - python3 -m venv ${SCRIPT_DIR}/polaris-venv +UPDATE=false +for arg in "$@"; do + if [ "$arg" == "--update" ]; then + UPDATE=true + shift + break + fi +done + +if [ ! -d ${SCRIPT_DIR}/polaris-venv ] || [ "$UPDATE" == true ]; then + if [ ! -d ${SCRIPT_DIR}/polaris-venv ]; then + echo "Performing first-time setup for the Python client..." + python3 -m venv ${SCRIPT_DIR}/polaris-venv + else + echo "Updating dependencies for the Python client..." + fi + . ${SCRIPT_DIR}/polaris-venv/bin/activate - pip install -r regtests/requirements.txt + pip install --upgrade pip + pip install --upgrade -r regtests/requirements.txt cp ${SCRIPT_DIR}/regtests/client/python/pyproject.toml ${SCRIPT_DIR} pushd $SCRIPT_DIR && poetry install ; popd deactivate - echo "First time setup complete." + + if [ ! -d ${SCRIPT_DIR}/polaris-venv ]; then + echo "First time setup complete." + else + echo "Dependencies updated." + fi fi pushd $SCRIPT_DIR > /dev/null diff --git a/regtests/polaris-reg-test b/regtests/polaris-reg-test index 0b996a4d54..908ce2772a 100755 --- a/regtests/polaris-reg-test +++ b/regtests/polaris-reg-test @@ -31,13 +31,28 @@ if [ $(basename ${SCRIPT_DIR}) == "regtests" ]; then exit 1 fi +UPDATE=false +for arg in "$@"; do + if [ "$arg" == "--update" ]; then + UPDATE=true + shift + break + fi +done + # Check if the virtual environment directory 'polaris-venv' exists. # If it does not, perform the first-time setup for the Python client -if [ ! -d ${SCRIPT_DIR}/polaris-venv ]; then - echo "Performing first-time setup for the Python client..." - python3 -m venv ${SCRIPT_DIR}/polaris-venv +if [ ! -d ${SCRIPT_DIR}/polaris-venv ] || [ "$UPDATE" == true ]; then + if [ ! -d ${SCRIPT_DIR}/polaris-venv ]; then + echo "Performing first-time setup for the Python client..." + python3 -m venv ${SCRIPT_DIR}/polaris-venv + else + echo "Updating dependencies for the Python client..." + fi + . ${SCRIPT_DIR}/polaris-venv/bin/activate - pip install -f requirements.txt + pip install --upgrade pip + pip install --upgrade -r regtests/requirements.txt cp ${SCRIPT_DIR}/regtests/client/python/pyproject.toml ${SCRIPT_DIR} @@ -47,7 +62,12 @@ if [ ! -d ${SCRIPT_DIR}/polaris-venv ]; then cd $CURRENT_DIR deactivate - echo "First time setup complete." + + if [ ! -d ${SCRIPT_DIR}/polaris-venv ]; then + echo "First time setup complete." + else + echo "Dependencies updated." + fi fi # Save the current directory