Skip to content
Merged
19 changes: 5 additions & 14 deletions .github/workflows/_run-one-click.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,11 @@ jobs:
id: get-default-params
if: ${{ inputs.deploy_method == 'k8s' }}
run: |
cd ${{ github.workspace }}
example=$(echo "${{ inputs.example }}" | cut -d'-' -f1)
PARAMS_JSON=$(python3 .github/workflows/scripts/get-params.py $example)
echo "LLM_model=$(echo "$PARAMS_JSON" | jq -r '.llm_model')" >> $GITHUB_ENV
if [ "$example" = "ChatQnA" ]; then
echo "LLM_model=$(echo "$PARAMS_JSON" | jq -r '.llm_model')" >> $GITHUB_ENV
echo "Embedding_model=$(echo "$PARAMS_JSON" | jq -r '.embed_model')" >> $GITHUB_ENV
echo "Reranking_model=$(echo "$PARAMS_JSON" | jq -r '.rerank_model')" >> $GITHUB_ENV
echo "Mount_dir=$(echo "$PARAMS_JSON" | jq -r '.mount_dir')" >> $GITHUB_ENV
elif [ "$example" = "VisualQnA" ]; then
echo "LVM_model=$(echo "$PARAMS_JSON" | jq -r '.lvm_model')" >> $GITHUB_ENV
elif [ "$example" = "AgentQnA" ]; then
echo "LLM_model=$(echo "$PARAMS_JSON" | jq -r '.gaudi.llm_model')" >> $GITHUB_ENV
fi
echo "LLM_model=" >> $GITHUB_ENV
echo "Embedding_model=" >> $GITHUB_ENV
echo "Reranking_model=" >> $GITHUB_ENV
echo "Mount_dir=" >> $GITHUB_ENV
echo "LVM_model=" >> $GITHUB_ENV

- name: deploy and test
shell: bash
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/scripts/get-params.py

This file was deleted.

13 changes: 1 addition & 12 deletions one_click_deploy/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,29 +100,26 @@
"name": "llm_model",
"prompt": "LLM Model ID",
"type": str,
"default": "meta-llama/Meta-Llama-3-8B-Instruct",
"help": "e.g., meta-llama/Meta-Llama-3-8B-Instruct",
},
{
"name": "embed_model",
"prompt": "Embedding Model ID",
"type": str,
"default": "BAAI/bge-base-en-v1.5",
"help": "e.g., BAAI/bge-base-en-v1.5",
},
{
"name": "rerank_model",
"prompt": "Reranking Model ID",
"type": str,
"default": "BAAI/bge-reranker-base",
"help": "e.g., BAAI/bge-reranker-base",
},
{
"name": "mount_dir",
"prompt": "Data Mount Directory (for Docker)",
"type": str,
"modes": ["docker"],
"default": "./data",
"modes": ["docker"],
},
],
},
Expand Down Expand Up @@ -193,7 +190,6 @@
"name": "llm_model",
"prompt": "LLM Model ID (for Code Translation)",
"type": str,
"default": "mistralai/Mistral-7B-Instruct-v0.3",
"help": "e.g., mistralai/Mistral-7B-Instruct-v0.3",
},
],
Expand Down Expand Up @@ -264,7 +260,6 @@
"name": "llm_model",
"prompt": "LLM Model ID (for DocSum)",
"type": str,
"default": "meta-llama/Meta-Llama-3-8B-Instruct",
"help": "e.g., meta-llama/Meta-Llama-3-8B-Instruct",
},
],
Expand Down Expand Up @@ -333,7 +328,6 @@
"name": "llm_model",
"prompt": "LLM Model ID (for Code Generation)",
"type": str,
"default": "Qwen/Qwen2.5-Coder-7B-Instruct",
"help": "e.g., Qwen/Qwen2.5-Coder-7B-Instruct",
},
],
Expand Down Expand Up @@ -409,7 +403,6 @@
"name": "llm_model",
"prompt": "LLM Model ID (for Audio Q&A)",
"type": str,
"default": "meta-llama/Meta-Llama-3-8B-Instruct",
"help": "e.g., meta-llama/Meta-Llama-3-8B-Instruct",
},
],
Expand Down Expand Up @@ -486,7 +479,6 @@
"name": "lvm_model",
"prompt": "LVM Model ID (for Visual Q&A)",
"type": str,
"default": "llava-hf/llava-v1.6-mistral-7b-hf",
"help": "e.g., llava-hf/llava-v1.6-mistral-7b-hf",
},
],
Expand Down Expand Up @@ -568,7 +560,6 @@
"name": "llm_model",
"prompt": "LLM Model ID",
"type": str,
"default": "meta-llama/Meta-Llama-3-8B-Instruct",
"help": "e.g., meta-llama/Meta-Llama-3-8B-Instruct",
},
],
Expand Down Expand Up @@ -659,14 +650,12 @@
"name": "llm_model",
"prompt": "LLM Model ID (for Gaudi)",
"type": str,
"default": "meta-llama/Meta-Llama-3-8B-Instruct",
"help": "e.g., meta-llama/Meta-Llama-3-8B-Instruct",
},
{
"name": "num_shards",
"prompt": "Number of Gaudi HPU cards (shards)",
"type": int,
"default": 4,
"help": "e.g., 1, 2, 4. Controls tensor parallel size.",
},
],
Expand Down
34 changes: 26 additions & 8 deletions one_click_deploy/core/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,26 +345,44 @@ def _interactive_setup_for_deploy(self):

interactive_params = self._get_device_specific_or_common_config(["interactive_params"]) or []

docker_param_map = self._get_device_specific_or_common_config(["docker_compose", "params_to_set_env"]) or {}
source_env_script = self._get_docker_set_env_script()

for param in interactive_params:
if "modes" in param and self.args.deploy_mode not in param["modes"]:
setattr(self.args, param["name"], None)
continue

static_default = param.get("default")

dynamic_default = None
env_var_name = docker_param_map.get(param["name"])
if env_var_name and source_env_script:
dynamic_default = get_var_from_shell_script(source_env_script, env_var_name)
if dynamic_default:
log_message(
"DEBUG",
f"Found default for '{param['name']}' from script '{source_env_script.name}': {dynamic_default}",
)

final_default = dynamic_default if dynamic_default is not None else static_default
prompt_text = param["prompt"]
help_text = param.get("help")
if help_text:
prompt_text = f"{prompt_text} ({help_text})"

default_value = param.get("default")
is_required = param.get("required", False)
user_input = click.prompt(prompt_text, default=final_default, type=param.get("type", str))

user_input = click.prompt(prompt_text, default=default_value, type=param.get("type", str))
value_to_set = user_input if user_input else final_default

is_required = param.get("required", False)

while is_required and (not user_input or user_input == default_value):
while is_required and not value_to_set:
log_message("WARN", f"A valid '{param['prompt']}' is required. Please provide a real value.")
user_input = click.prompt(prompt_text, type=param.get("type", str), default=None)
value_to_set = user_input if user_input else None

setattr(self.args, param["name"], user_input)
setattr(self.args, param["name"], value_to_set)

self.args.do_check_env = click.confirm("Run environment check?", default=False, show_default=True)

Expand Down Expand Up @@ -790,7 +808,7 @@ def _configure_docker(self):
updates = {
env_var: getattr(self.args, arg_name)
for arg_name, env_var in params_to_env_map.items()
if hasattr(self.args, arg_name) and getattr(self.args, arg_name) is not None
if hasattr(self.args, arg_name) and getattr(self.args, arg_name)
}

user_proxies = {p.strip() for p in self.args.no_proxy.split(",") if p.strip()}
Expand Down Expand Up @@ -834,7 +852,7 @@ def _configure_kubernetes(self):
for name, path_or_paths in params_to_values.items():
if hasattr(self.args, name):
value = getattr(self.args, name)
if value is None:
if not value:
continue

if isinstance(path_or_paths, list) and len(path_or_paths) > 0 and isinstance(path_or_paths[0], list):
Expand Down Expand Up @@ -889,7 +907,7 @@ def deploy(self):
log_message("ERROR", f"Local environment script '{local_env_file}' not found. Cannot deploy.")
return False

compose_up_cmd = " ".join(compose_base_cmd + ["up", "-d", "--remove-orphans"])
compose_up_cmd = " ".join(compose_base_cmd + ["up", "-d", "--remove-orphans", "--quiet-pull"])
if self.example_name == "ChatQnA" and self.args.device == "gaudi":
compose_up_cmd = "source .env&&" + compose_up_cmd
compose_dir = self._get_docker_compose_files()[0].parent
Expand Down
58 changes: 41 additions & 17 deletions one_click_deploy/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,28 +377,52 @@ def stop_all_kubectl_port_forwards():


def get_var_from_shell_script(script_path: pathlib.Path, var_name: str) -> str | None:
"""Gets the value of an environment variable by executing a shell script.

This method is robust as it handles scripts with functions, sourcing other files,
and conditional logic. It executes the script in a non-interactive mode.

Args:
script_path: The absolute path to the shell script.
var_name: The name of the environment variable to retrieve.

Returns:
The value of the variable as a string, or None if not found or on error.
"""
if not script_path or not script_path.exists():
log_message("DEBUG", f"Source script for variable extraction not found: {script_path}")
return None
assignment_pattern = re.compile(rf"^\s*(?:export\s+)?{re.escape(var_name)}\s*=\s*(.*)")
self_ref_pattern = re.compile(r"^\s*(\$\{?" + re.escape(var_name) + r"\}?\,?)")

command_string = f"NON_INTERACTIVE=true; " f'source "{script_path.resolve()}" > /dev/null; ' f'echo "${var_name}"'
try:
lines = script_path.read_text().splitlines()
for line in reversed(lines):
match = assignment_pattern.match(line)
if match:
value = match.group(1).strip()
value = value.split("#", 1)[0].strip()
if (value.startswith('"') and value.endswith('"')) or (value.startswith("'") and value.endswith("'")):
value = value[1:-1]
value = self_ref_pattern.sub("", value).strip()
value = value.lstrip(",")
log_message("DEBUG", f"Extracted and cleaned value for '{var_name}': {value}")
return value
log_message("DEBUG", f"Variable '{var_name}' not found in {script_path}.")
return None
result = run_command(
["bash", "-c", command_string],
cwd=script_path.parent,
capture_output=True,
check=False,
display_cmd=False,
)

if result.returncode != 0:
log_message(
"WARN",
f"Execution of '{script_path.name}' failed when trying to get var '{var_name}'. Stderr: {result.stderr.strip()}",
)
return None

value = result.stdout.strip()

if value:
log_message("DEBUG", f"Extracted value for '{var_name}' from '{script_path.name}': {value}")
return value
else:
log_message("DEBUG", f"Variable '{var_name}' was not set or is empty in '{script_path.name}'.")
return None

except Exception as e:
log_message("WARN", f"Failed to parse variable '{var_name}' from {script_path}: {e}")
log_message(
"WARN", f"An unexpected error occurred while executing {script_path.name} to get var '{var_name}': {e}"
)
return None


Expand Down
Loading