8000 Normalize the taxonomy path and make sure the taxonomy by vishnoianil · Pull Request #638 · instructlab/ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Normalize the taxonomy path and make sure the taxonomy #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 58 additions & 7 deletions installers/podman/ilab-ui-native-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ usage_uninstall() {
# Check if Podman is installed
check_podman() {
if ! command -v podman &>/dev/null; then
echo -e "${red}Podman is not installed!.${reset}\n"
echo -e "${red}Podman is not installed!. Podman is mandatory requirement for UI.${reset}\n"
exit 1
fi
}

check_git() {
if ! command -v git &>/dev/null; then
echo -e "${red}Git is not installed!. Git is mandatory requirement for UI${reset}\n"
exit 1
fi
}
Expand Down Expand Up @@ -147,11 +154,11 @@ verify_user_taxonomy() {
echo -e "${red}and it's not same as provided by the user - $USER_TAXONOMY_DIR${reset}\n"
echo -e "${blue}It's recommended to use the taxonomy repo configured for the ilab CLI.${reset}\n"
echo -e "${blue}In case you do not choose ilab configured taxonomy, data generation and fine tune features will not work.${reset}\n"
echo -e "${blue}But skill and knowledge contribution features should work as expected.${reset}\n"
echo -e "${blue}But skills and knowledge contribution features should work as expected.${reset}\n"
echo -e "${red}Please choose the taxonomy repo you would like to use with InstructLab UI:${reset}"
echo -e "${red}1. ilab Taxonomy - $DISCOVERED_TAXONOMY_DIR${reset}"
echo -e "${red}2. Provided Taxonomy - $USER_TAXONOMY_DIR${reset}"
read -r -p "Please choose the taxonomy repo you would like to use with InstructLab UI? (1/2): " CHOICE
echo -e "${red}2. User provided Taxonomy - $USER_TAXONOMY_DIR${reset}"
read -r -p "Use following taxonomy repo with InstructLab UI (1/2): " CHOICE
if [[ "$CHOICE" == "1" ]]; then
SELECTED_TAXONOMY_DIR=$DISCOVERED_TAXONOMY_DIR
else
Expand All @@ -166,6 +173,30 @@ verify_user_taxonomy() {
SELECTED_TAXONOMY_DIR=$USER_TAXONOMY_DIR
}

# Check if the selected taxonomy is empty. If not, make sure it's git initialized repository.
check_taxonomy_readiness() {
local TAXONOMY_DIR="$1"
# Check if the directory exists
if [ ! -d "$TAXONOMY_DIR" ]; then
echo -e "${red}Selected taxonomy repository directory does not exist. Taxonomy repository is a mandatory requirement for UI installation.${reset}\n"
exit 1
fi

# Check if the directory is empty
if [ -z "$(ls -A "$TAXONOMY_DIR" 2>/dev/null)" ]; then
echo -e "${red}Selected taxonomy repository directory is empty. Seems like taxonomy repository is not cloned?.${reset}\n"
exit 1
fi

# Check if the directory is a Git repository
if git -C "$TAXONOMY_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo -e "${green}Selected taxonomy repository directory is properly setup and ready for use.${reset}\n"
else
echo -e "${red}Selected taxonomy repository directory is not a git repository. Seems like taxonomy repository is not cloned?.${reset}\n"
exit 1
fi
}

# Discover python virtual environments on host
discover_pyenv() {
echo -e "${green}Discovering python vi 8000 rtual environment present on the host...${reset}\n"
Expand Down Expand Up @@ -240,6 +271,17 @@ discover_ilab() {

}

normalize_taxonomy_path() {
if [[ "$USER_TAXONOMY_DIR" != /* ]]; then
if ! command -v realpath &>/dev/null; then
USER_TAXONOMY_DIR=$(realpath "$USER_TAXONOMY_DIR" 2>/dev/null)
else
USER_TAXONOMY_DIR="$(cd "$(dirname "$USER_TAXONOMY_DIR")" && pwd)/$(basename "$USER_TAXONOMY_DIR")"
fi
echo -e "${blue} Taxonomy path normalized to absolute path $USER_TAXONOMY_DIR${reset}\n"
fi
}

# Parse input arguments
if [[ $# -lt 1 ]]; then
usage
Expand All @@ -261,6 +303,7 @@ if [[ "$COMMAND" == "install" ]]; then
;;
--taxonomy-dir)
USER_TAXONOMY_DIR=$(echo "$2" | sed 's/^ *//;s/ *$//')
normalize_taxonomy_path
shift 2
;;
--auth-url)
Expand Down Expand Up @@ -297,6 +340,7 @@ if [[ "$COMMAND" == "install" ]]; then
fi

check_podman
check_git
check_ports
check_ui_stack

Expand All @@ -305,16 +349,20 @@ if [[ "$COMMAND" == "install" ]]; then
verify_user_pyenv
else
discover_ilab
echo -e "\n${blue}NOTE: If you are using python virtual environment for InstructLab setup, you can use --python-venv-dir option to skip the discovery.${reset}\n"
if [[ "$DISCOVERED_PYENV_DIR" == "" ]]; then
IS_ILAB_INSTALLED="false"
else
echo -e "\n${blue}NOTE: If you are using python virtual environment for InstructLab setup, you can use --python-venv-dir option to skip the discovery.${reset}\n"
fi
fi

# ilab is not set up and the user didn't provide that taxonomy info as well. Exit with warning info.
if [[ "$IS_ILAB_INSTALLED" == "false" ]]; then
if [[ "$USER_TAXONOMY_DIR" == "" ]]; then
echo -e "${red}Given that ilab is not set up on the host, taxonomy repo is not discovered.${reset}\n"
echo -e "${red}To proceed with the installation please do one of the following:${reset}"
echo -e "${red}1. Clone the taxonomy repo and provide the path to the directory using '--taxonomy-dir' option.${reset}"
echo -e "${red}2. Set up the ilab. If using virtual environment to set up the ilab, use --python-venv-dir option to virtual environment directory.${reset}"
echo -e "${red}1. Clone the taxonomy repo and provide the absolute path to the directory using '--taxonomy-dir' option.${reset}"
echo -e "${red}2. Set up the ilab. If using virtual environment to set up the ilab, use --python-venv-dir option to provide virtual environment directory.${reset}"
exit 1
fi
fi
Expand Down Expand Up @@ -343,6 +391,9 @@ if [[ "$COMMAND" == "install" ]]; then
fi
fi

echo -e "${green}Check readiness for taxonomy repository directory : $SELECTED_TAXONOMY_DIR${reset}\n"
check_taxonomy_readiness "$SELECTED_TAXONOMY_DIR"

echo -e "${green}Starting InstructLab UI installation...${reset}\n"
echo -e "${green}InstructLab UI will be set up with taxonomy present in $SELECTED_TAXONOMY_DIR.${reset}\n"

Expand Down
0