Skip to content

Commit

Permalink
fix: side effect when determining model changes
Browse files Browse the repository at this point in the history
don't switch current working git branch

Signed-off-by: jerryzhuang <[email protected]>
  • Loading branch information
zhuangqh committed Dec 20, 2024
1 parent 53319e0 commit 27263a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/kind-cluster/determine_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion presets/workspace/models/supported_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 27263a2

Please sign in to comment.