From 27263a29bb53fa690ab402920813f73278d49b9e Mon Sep 17 00:00:00 2001 From: jerryzhuang Date: Fri, 20 Dec 2024 15:24:50 +1100 Subject: [PATCH] fix: side effect when determining model changes don't switch current working git branch Signed-off-by: jerryzhuang --- .../kind-cluster/determine_models.py | 28 ++++++++++--------- .../workspace/models/supported_models.yaml | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/kind-cluster/determine_models.py b/.github/workflows/kind-cluster/determine_models.py index 92b3d7a6c..7b5d3e333 100644 --- a/.github/workflows/kind-cluster/determine_models.py +++ b/.github/workflows/kind-cluster/determine_models.py @@ -24,7 +24,11 @@ def read_yaml(file_path): KAITO_REPO_URL = "https://github.com/kaito-project/kaito.git" def set_multiline_output(name, value): - with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: + if not os.getenv('GITHUB_OUTPUT'): + print(f"Not in github env, skip writing to $GITHUB_OUTPUT .") + return + + with open(os.getenv('GITHUB_OUTPUT'), 'a') as fh: delimiter = uuid.uuid1() print(f'{name}<<{delimiter}', file=fh) print(value, file=fh) @@ -51,9 +55,11 @@ def run_command(command): def get_yaml_from_branch(branch, file_path): """Read YAML from a branch""" - subprocess.run(['git', 'fetch', 'origin', branch], check=True) - subprocess.run(['git', 'checkout', 'origin/' + branch], check=True) - return read_yaml(file_path) + subprocess.run(['git', 'fetch', 'ciupstream', branch], check=True) + subprocess.run(['git', 'checkout', 'ciupstream/' + branch], check=True) + content = read_yaml(file_path) + subprocess.run(['git', 'checkout', '-'], check=True) + return content def detect_changes_in_yaml(yaml_main, yaml_pr): """Detecting relevant changes in support_models.yaml""" @@ -97,20 +103,16 @@ def check_modified_models(pr_branch): if repo_dir.exists(): shutil.rmtree(repo_dir) - run_command(f"git clone {KAITO_REPO_URL} {repo_dir}") - os.chdir(repo_dir) - - run_command("git checkout --detach") - run_command("git fetch origin main:main") - run_command(f"git fetch origin {pr_branch}:{pr_branch}") run_command(f"git checkout {pr_branch}") + run_command(f"git remote add ciupstream {KAITO_REPO_URL}") + run_command("git fetch ciupstream") - files = run_command("git diff --name-only origin/main") # Returns each file on newline + files = run_command("git diff --name-only ciupstream/main") # Returns each file on newline files = files.split("\n") - os.chdir(Path.cwd().parent) + print("Files Changed: ", files) modified_models = models_to_build(files) - + print("Modified Models (Images to build): ", modified_models) return modified_models diff --git a/presets/workspace/models/supported_models.yaml b/presets/workspace/models/supported_models.yaml index 99a61a10e..473a086d2 100644 --- a/presets/workspace/models/supported_models.yaml +++ b/presets/workspace/models/supported_models.yaml @@ -139,7 +139,7 @@ models: type: text-generation version: https://huggingface.co/microsoft/Phi-3-medium-128k-instruct/commit/fa7d2aa4f5ea69b2e36b20d050cdae79c9bfbb3f runtime: tfs - tag: 0.0.3 + tag: 0.0.4 # Tag history: # 0.0.3 - Support VLLM runtime # 0.0.2 - Add Logging & Metrics Server